diff --git a/BUILD.gn b/BUILD.gn
index ad48b1216bade8fa5935fb363c0606b81d9edee5..5ef86eac4a54a62f48d2610bcd73a3e8326661ac 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -67,6 +67,7 @@ lite_subsystem("kernel") {
}
} else {
deps = [ ":make" ]
+ deps += [ "//kernel/liteos_a/testsuites/unittest:unittest" ]
}
}
diff --git a/Kconfig b/Kconfig
index 50750d11c19675f7f7098b5527dc5cadda690a46..ccf86320393b5f0a0195cc9330a9060f91167c27 100644
--- a/Kconfig
+++ b/Kconfig
@@ -303,6 +303,7 @@ source "../../kernel/liteos_a/bsd/dev/usb/Kconfig"
source "../../drivers/adapter/khdf/liteos/Kconfig"
source "drivers/char/mem/Kconfig"
+source "drivers/char/quickstart/Kconfig"
source "drivers/char/random/Kconfig"
source "../../drivers/liteos/tzdriver/Kconfig"
source "drivers/char/video/Kconfig"
diff --git a/arch/arm/arm/include/los_hw_cpu.h b/arch/arm/arm/include/los_hw_cpu.h
index 02c7ea4dd2ddf7359cfbaf0f56e7bf69840e842d..f6fc4460b7c5fa36f6a77467e14d59da7cec4efd 100644
--- a/arch/arm/arm/include/los_hw_cpu.h
+++ b/arch/arm/arm/include/los_hw_cpu.h
@@ -189,6 +189,24 @@ STATIC INLINE UINT32 ArchIntUnlock(VOID)
return intSave;
}
+STATIC INLINE VOID ArchIrqDisable(VOID)
+{
+ __asm__ __volatile__(
+ "cpsid i "
+ :
+ :
+ : "memory", "cc");
+}
+
+STATIC INLINE VOID ArchIrqEnable(VOID)
+{
+ __asm__ __volatile__(
+ "cpsie i "
+ :
+ :
+ : "memory", "cc");
+}
+
#else
STATIC INLINE UINT32 ArchIntLock(VOID)
diff --git a/arch/arm/arm/src/los_arch_mmu.c b/arch/arm/arm/src/los_arch_mmu.c
index 39ef435f4975c9e5e7ffdf997883337e9a51792c..edb22e4745344d8af9779f176539f97a34055eae 100644
--- a/arch/arm/arm/src/los_arch_mmu.c
+++ b/arch/arm/arm/src/los_arch_mmu.c
@@ -892,9 +892,9 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
length = sizeof(mmuKernelMappings) / sizeof(LosArchMmuInitMapping);
for (i = 0; i < length; i++) {
kernelMap = &mmuKernelMappings[i];
- if (uncached) {
- flags |= VM_MAP_REGION_FLAG_UNCACHED;
- }
+ if (uncached) {
+ kernelMap->flags |= VM_MAP_REGION_FLAG_UNCACHED;
+ }
status = LOS_ArchMmuMap(&kSpace->archMmu, kernelMap->virt, kernelMap->phys,
kernelMap->size >> MMU_DESCRIPTOR_L2_SMALL_SHIFT, kernelMap->flags);
if (status != (kernelMap->size >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
diff --git a/arch/arm/arm/src/los_exc.c b/arch/arm/arm/src/los_exc.c
index 7d8e9e7f60b607df12b1f7378ecf3db86fe6f059..42573a492e87532c8974e627508558c56aec578d 100644
--- a/arch/arm/arm/src/los_exc.c
+++ b/arch/arm/arm/src/los_exc.c
@@ -181,18 +181,29 @@ STATIC INT32 OsDecodeDataFSR(UINT32 regDFSR)
#ifdef LOSCFG_KERNEL_VM
UINT32 OsArmSharedPageFault(UINT32 excType, PageFaultContext *frame, UINT32 far, UINT32 fsr)
{
- PRINT_INFO("page fault entry!!!\n");
- BOOL instruction_fault = FALSE;
+ BOOL instructionFault = FALSE;
UINT32 pfFlags = 0;
UINT32 fsrFlag;
BOOL write = FALSE;
+ UINT32 ret;
+ PRINT_INFO("page fault entry!!!\n");
if (OsGetSystemStatus() == OS_SYSTEM_EXC_CURR_CPU) {
return LOS_ERRNO_VM_NOT_FOUND;
}
-
+#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION)
+ BOOL irqEnable = !(LOS_SpinHeld(&g_taskSpin) && (OsPercpuGet()->taskLockCnt != 0));
+ if (irqEnable) {
+ ArchIrqEnable();
+ } else {
+ PrintExcInfo("[ERR][%s] may be held scheduler lock when entering [%s]\n",
+ OsCurrTaskGet()->taskName, __FUNCTION__);
+ }
+#else
+ ArchIrqEnable();
+#endif
if (excType == OS_EXCEPT_PREFETCH_ABORT) {
- instruction_fault = TRUE;
+ instructionFault = TRUE;
} else {
write = !!BIT_GET(fsr, WNR_BIT);
}
@@ -210,13 +221,23 @@ UINT32 OsArmSharedPageFault(UINT32 excType, PageFaultContext *frame, UINT32 far,
BOOL user = (frame->CPSR & CPSR_MODE_MASK) == CPSR_MODE_USR;
pfFlags |= write ? VM_MAP_PF_FLAG_WRITE : 0;
pfFlags |= user ? VM_MAP_PF_FLAG_USER : 0;
- pfFlags |= instruction_fault ? VM_MAP_PF_FLAG_INSTRUCTION : 0;
+ pfFlags |= instructionFault ? VM_MAP_PF_FLAG_INSTRUCTION : 0;
pfFlags |= VM_MAP_PF_FLAG_NOT_PRESENT;
- return OsVmPageFaultHandler(far, pfFlags, frame);
+ ret = OsVmPageFaultHandler(far, pfFlags, frame);
+ break;
}
default:
- return LOS_ERRNO_VM_NOT_FOUND;
+ ret = LOS_ERRNO_VM_NOT_FOUND;
+ break;
+ }
+#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION)
+ if (irqEnable) {
+ ArchIrqDisable();
}
+#else
+ ArchIrqDisable();
+#endif
+ return ret;
}
#endif
diff --git a/arch/arm/arm/src/los_hw_exc.S b/arch/arm/arm/src/los_hw_exc.S
index 82d64ffe4a5178e2824e21b8f9a7b961e1c2ad77..afd98b5a2bf797490d2e4c46e88fc6ac9272b211 100644
--- a/arch/arm/arm/src/los_hw_exc.S
+++ b/arch/arm/arm/src/los_hw_exc.S
@@ -365,9 +365,6 @@ _osExceptFiqHdl:
MOV R3, #0
STMFD SP!, {R2-R3}
- MOV R0, #OS_EXCEPT_FIQ @ Set exception ID to OS_EXCEPT_FIQ.
- B _osExceptDispatch @ Branch to global exception handler.
-
@ Description: Exception handler
@ Parameter : R0 Exception Type
@ Regs Hold : R3 Exception`s CPSR
diff --git a/arch/arm/arm/src/startup/reset_vector_mp.S b/arch/arm/arm/src/startup/reset_vector_mp.S
index 893316928b082c062fb91edadebd9c29a85991ee..2ac92e1a77e10085fad2207a13da88d93afa677e 100644
--- a/arch/arm/arm/src/startup/reset_vector_mp.S
+++ b/arch/arm/arm/src/startup/reset_vector_mp.S
@@ -107,9 +107,9 @@ __exception_handlers:
.global reset_vector
.type reset_vector,function
-#ifdef LOSCFG_QUICK_START
+#ifdef LOSCFG_BOOTENV_RAM
__quickstart_args_start:
- .fill 512,1,0
+ .fill LOSCFG_BOOTENV_RAMSIZE,1,0
__quickstart_args_end:
.global OsGetArgsAddr
diff --git a/compat/posix/src/mqueue.c b/compat/posix/src/mqueue.c
index 85a924d7f4a79a3bb77688a3f24ba19db63cc03a..9f1f0318fe507f432cf715378c0dcb4bb918376a 100644
--- a/compat/posix/src/mqueue.c
+++ b/compat/posix/src/mqueue.c
@@ -739,11 +739,8 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
(VOID)pthread_mutex_lock(&g_mqueueMutex);
privateMqPersonal = MqGetPrivDataBuff(personal);
- if (privateMqPersonal == NULL) {
- goto ERROUT_UNLOCK;
- }
- OS_MQ_GOTO_ERROUT_UNLOCK_IF(privateMqPersonal->mq_status != MQ_USE_MAGIC, EBADF);
+ OS_MQ_GOTO_ERROUT_UNLOCK_IF(privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC, EBADF);
mqueueCB = privateMqPersonal->mq_posixdes;
OS_MQ_GOTO_ERROUT_UNLOCK_IF(msgLen > (size_t)(mqueueCB->mqcb->queueSize - sizeof(UINT32)), EMSGSIZE);
@@ -786,10 +783,7 @@ ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen, unsigned int *
(VOID)pthread_mutex_lock(&g_mqueueMutex);
privateMqPersonal = MqGetPrivDataBuff(personal);
- if (privateMqPersonal == NULL) {
- goto ERROUT_UNLOCK;
- }
- if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
+ if (privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC) {
errno = EBADF;
goto ERROUT_UNLOCK;
}
diff --git a/drivers/char/quickstart/Kconfig b/drivers/char/quickstart/Kconfig
new file mode 100644
index 0000000000000000000000000000000000000000..5ff73fe5ce00598aae9029e0600bcdc77ddf8f80
--- /dev/null
+++ b/drivers/char/quickstart/Kconfig
@@ -0,0 +1,6 @@
+config DRIVERS_QUICKSTART
+ bool "Enable QUICKSTART"
+ default y
+ depends on DRIVERS && FS_VFS
+ help
+ Answer Y to enable LiteOS support quickstart frame dev.
diff --git a/drivers/char/quickstart/include/los_dev_quickstart.h b/drivers/char/quickstart/include/los_dev_quickstart.h
new file mode 100644
index 0000000000000000000000000000000000000000..de3937621dd9f3a198f597e13b9789a0964965a7
--- /dev/null
+++ b/drivers/char/quickstart/include/los_dev_quickstart.h
@@ -0,0 +1,89 @@
+/*
+ * 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_DEV_QUICKSTART_H__
+#define __LOS_DEV_QUICKSTART_H__
+
+#include "los_typedef.h"
+#include "sys/ioctl.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+typedef enum {
+ QS_STAGE1 = 1, /* 1: start from stage1, 0 is already called in kernel process */
+ QS_STAGE2, /* system init stage No 2 */
+ QS_STAGE3, /* system init stage No 3 */
+ QS_STAGE_LIMIT
+} QuickstartStage;
+
+typedef enum {
+ QS_UNREGISTER = QS_STAGE_LIMIT, /* quickstart dev unregister */
+ QS_NOTIFY, /* quickstart notify */
+ QS_LISTEN, /* quickstart listen */
+ QS_CTL_LIMIT
+} QuickstartConctrl;
+
+typedef struct {
+ unsigned int pid;
+ unsigned int events;
+} QuickstartMask;
+
+#define QUICKSTART_IOC_MAGIC 'T'
+#define QUICKSTART_UNREGISTER _IO(QUICKSTART_IOC_MAGIC, QS_UNREGISTER)
+#define QUICKSTART_NOTIFY _IO(QUICKSTART_IOC_MAGIC, QS_NOTIFY)
+#define QUICKSTART_LISTEN _IOR(QUICKSTART_IOC_MAGIC, QS_LISTEN, QuickstartMask)
+#define QUICKSTART_STAGE(x) _IO(QUICKSTART_IOC_MAGIC, (x))
+
+#define QUICKSTART_NODE "/dev/quickstart"
+
+#define QS_STAGE_CNT (QS_STAGE_LIMIT - QS_STAGE1)
+
+typedef void (*SysteminitHook)(void);
+
+typedef struct {
+ SysteminitHook func[QS_STAGE_CNT];
+} LosSysteminitHook;
+
+extern void QuickstartHookRegister(LosSysteminitHook hooks);
+
+extern int QuickstartDevRegister(void);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif
diff --git a/drivers/char/quickstart/src/quickstart.c b/drivers/char/quickstart/src/quickstart.c
index 7a920206d25a25492827f024217c42975e3e47be..22451f874df3d23ad3b1fb9294572ae2cf802de7 100644
--- a/drivers/char/quickstart/src/quickstart.c
+++ b/drivers/char/quickstart/src/quickstart.c
@@ -29,16 +29,15 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_quick_start_pri.h"
-#include "bits/ioctl.h"
+#include "los_dev_quickstart.h"
#include "fcntl.h"
#include "linux/kernel.h"
+#include "los_process_pri.h"
-#define QUICKSTART_IOC_MAGIC 'T'
-#define QUICKSTART_INITSTEP2 _IO(QUICKSTART_IOC_MAGIC, 0)
-#define QUICKSTART_UNREGISTER _IO(QUICKSTART_IOC_MAGIC, 1)
-#define QUICKSTART_NODE "/dev/quickstart"
+EVENT_CB_S g_qsEvent;
+static SysteminitHook g_systemInitFunc[QS_STAGE_CNT] = {0};
+static char g_callOnce[QS_STAGE_CNT] = {0};
static int QuickstartOpen(struct file *filep)
{
@@ -50,21 +49,54 @@ static int QuickstartClose(struct file *filep)
return 0;
}
-static void SystemInitStep2(void)
+static int QuickstartNotify(unsigned int events)
{
- static int once = 0;
- /* Only one call is allowed */
- if (once != 0) {
- return;
+ unsigned int pid = LOS_GetCurrProcessID();
+ /* 16:low 16 bits for eventMask, high 16 bits for pid */
+ unsigned int notifyEvent = (pid << 16) | events;
+ int ret = LOS_EventWrite((PEVENT_CB_S)&g_qsEvent, notifyEvent);
+ if (ret != 0) {
+ PRINT_ERR("%s,%d:0x%x\n", __FUNCTION__, __LINE__, ret);
+ ret = -EINVAL;
}
- once = 1;
+ return ret;
+}
+
+static int QuickstartListen(unsigned long arg)
+{
+ QuickstartMask listenMask;
+ if (copy_from_user(&listenMask, (struct QuickstartMask __user *)arg, sizeof(QuickstartMask)) != LOS_OK) {
+ PRINT_ERR("%s,%d\n", __FUNCTION__, __LINE__);
+ return -EINVAL;
+ }
+ /* 16:low 16 bits for eventMask, high 16 bits for pid */
+ unsigned int mask = (listenMask.pid << 16) | listenMask.events;
+ int ret = LOS_EventRead((PEVENT_CB_S)&g_qsEvent, mask, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ if (ret != mask) {
+ PRINT_ERR("%s,%d:0x%x\n", __FUNCTION__, __LINE__, ret);
+ ret = -EINVAL;
+ }
+ return ret;
+}
- unsigned int ret = OsSystemInitStep2();
- if (ret != LOS_OK) {
- PRINT_ERR("systemInitStep2 failed\n");
+void QuickstartHookRegister(LosSysteminitHook hooks)
+{
+ for (int i = 0; i < QS_STAGE_CNT; i++) {
+ g_systemInitFunc[i] = hooks.func[i];
}
}
+static int QuickstartStageWorking(unsigned int level)
+{
+ if ((level < QS_STAGE_CNT) && (g_callOnce[level] == 0) && (g_systemInitFunc[level] != NULL)) {
+ g_callOnce[level] = 1; /* 1: Already called */
+ g_systemInitFunc[level]();
+ } else {
+ PRINT_WARN("Trigger quickstart,but doing nothing!!\n");
+ }
+ return 0;
+}
+
static int QuickstartDevUnregister(void)
{
return unregister_driver(QUICKSTART_NODE);
@@ -72,18 +104,27 @@ static int QuickstartDevUnregister(void)
static ssize_t QuickstartIoctl(struct file *filep, int cmd, unsigned long arg)
{
+ ssize_t ret;
+ if (cmd == QUICKSTART_NOTIFY) {
+ return QuickstartNotify(arg);
+ }
+
+ if (OsGetUserInitProcessID() != LOS_GetCurrProcessID()) {
+ PRINT_ERR("Permission denios!\n");
+ return -EACCES;
+ }
switch (cmd) {
- case QUICKSTART_INITSTEP2:
- SystemInitStep2();
- break;
case QUICKSTART_UNREGISTER:
- QuickstartDevUnregister();
+ ret = QuickstartDevUnregister();
+ break;
+ case QUICKSTART_LISTEN:
+ ret = QuickstartListen(arg);
break;
-
default:
+ ret = QuickstartStageWorking(cmd - QUICKSTART_STAGE(QS_STAGE1)); /* ioctl cmd converted to stage level */
break;
}
- return 0;
+ return ret;
}
static const struct file_operations_vfs g_quickstartDevOps = {
@@ -100,8 +141,9 @@ static const struct file_operations_vfs g_quickstartDevOps = {
NULL, /* unlink */
};
-int DevQuickStartRegister(void)
+int QuickstartDevRegister(void)
{
- return register_driver(QUICKSTART_NODE, &g_quickstartDevOps, 0666, 0); /* 0666: file mode */
+ LOS_EventInit(&g_qsEvent);
+ return register_driver(QUICKSTART_NODE, &g_quickstartDevOps, 0644, 0); /* 0644: file mode */
}
diff --git a/fs/fat/os_adapt/fatfs.c b/fs/fat/os_adapt/fatfs.c
index 46843f2fdc980142b943e06ae4f330990e710c10..ee39d65391740f2cb7c910abc8b6c0cdf56bb171 100644
--- a/fs/fat/os_adapt/fatfs.c
+++ b/fs/fat/os_adapt/fatfs.c
@@ -93,10 +93,13 @@ int fatfs_2_vfs(int result)
case FR_NO_FILE:
case FR_NO_PATH:
- case FR_NO_FILESYSTEM:
status = ENOENT;
break;
+ case FR_NO_FILESYSTEM:
+ status = ENOTSUP;
+ break;
+
case FR_INVALID_NAME:
status = EINVAL;
break;
diff --git a/fs/fat/os_adapt/format.c b/fs/fat/os_adapt/format.c
index 72a1a6f0135cbd6a0c6e856c26697a813ed0a7f8..e2b3458cc4f243148df413bb5eba830e10670dca 100644
--- a/fs/fat/os_adapt/format.c
+++ b/fs/fat/os_adapt/format.c
@@ -78,6 +78,7 @@ int format(const char *dev, int sectors, int option)
}
err = fatfs_mkfs(device, sectors, option);
if (err < 0) {
+ VnodeDrop();
set_errno(-err);
return -1;
}
diff --git a/fs/include/fs/fs_operation.h b/fs/include/fs/fs_operation.h
index ab9287bf774588edfc85a740e0e39ca1c287be79..0f1e6967e1dec19d1aa25f39ebf26f03d2a32128 100644
--- a/fs/include/fs/fs_operation.h
+++ b/fs/include/fs/fs_operation.h
@@ -163,30 +163,6 @@ void clear_fd(int fd);
extern char *rindex(const char *s, int c);
-/**
- * @ingroup fs
- * @brief list directory contents.
- *
- * @par Description:
- * Get the volume label of the FAT partition.
- *
- * @attention
- *
- * - The function support FAT filesystem only.
- * - The label must allocated more than 11 charactors space first
- *
- *
- * @param target [IN] Type #const char* The file pathname.
- * @param label [OUT] Type #const char* The string pointer transform the label massge back.
- *
- * @retval #int Point the status which is successed or failed.
- *
- * @par Dependency:
- * - fs.h: the header file that contains the API declaration.
- */
-
-int getlabel(const char *target, char *label);
-
/**
* @ingroup fs
*
@@ -349,40 +325,6 @@ int fscheck(const char *path);
extern int virstatfs(const char *path, struct statfs *buf);
-/**
- * @ingroup fs
- * @set the virtual partition information.
- *
- * @par Description:
- * The los_set_virpartparam() function use for set virtual partition parameter.
- * The parameter include virtual partition number, virtual partition percent, virtual partition name
- * and the partition path which need mount virtual partition.
- *
- * @attention
- *
- * - This function only support for FAT32.
- * - This function only support for the virtual partition feature.
- * - This function only can be used before mount function.
- * - The function can be invoked once before umount partition.
- * - Now support set single partition,the partition information will be replaced
- * if it used for set another partition name.
- * - The function has no effert if virtual partition information is already in the partition.
- *
- *
- * @param virtualinfo [IN] Type #virpartinfo The struct which include virtual partition information.
- *
- * @retval #0 los_set_virpartparam success.
- * @retval #-1 los_set_virpartparam failed.
- *
- * @par Dependency:
- * - fs.h: the header file that contains the API declaration.
- * @see
- *
- */
-#ifdef VFS_IMPL_LATER
-int los_set_virpartparam(virpartinfo virtualinfo);
-#endif
-
#endif
/**
diff --git a/fs/include/fs/vnode.h b/fs/include/fs/vnode.h
index 6c4bf4e8fd8b122d9ec25e7733a2750583d2ee10..0312b5ea259f076bc77ed7b877a42a862a10f695 100644
--- a/fs/include/fs/vnode.h
+++ b/fs/include/fs/vnode.h
@@ -111,16 +111,16 @@ int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags);
int VnodeHold(void);
int VnodeDrop(void);
void VnodeRefDec(struct Vnode *vnode);
-int VnodeFreeIter(struct Vnode *vnode);
-int VnodeFreeAll(struct Mount *mnt);
+int VnodeFreeAll(const struct Mount *mnt);
int VnodeHashInit(void);
uint32_t VfsHashIndex(struct Vnode *vnode);
int VfsHashGet(const struct Mount *mount, uint32_t hash, struct Vnode **vnode, VfsHashCmp *fun, void *arg);
void VfsHashRemove(struct Vnode *vnode);
int VfsHashInsert(struct Vnode *vnode, uint32_t hash);
void ChangeRoot(struct Vnode *newRoot);
-BOOL VnodeInUseIter(struct Vnode *vnode);
+BOOL VnodeInUseIter(const struct Mount *mount);
struct Vnode *VnodeGetRoot(void);
void VnodeMemoryDump(void);
+int VnodeDestory(struct Vnode *vnode);
#endif /* !_VNODE_H_ */
diff --git a/fs/vfs/disk/disk.c b/fs/vfs/disk/disk.c
index 07be82c60cf12f4e74d20a045aeed13ef2d19aa8..071b1d90779df055352dbb2526fcad446d98d202 100644
--- a/fs/vfs/disk/disk.c
+++ b/fs/vfs/disk/disk.c
@@ -1148,15 +1148,16 @@ ERROR_HANDLE:
INT32 los_disk_cache_clear(INT32 drvID)
{
INT32 result;
+ los_part *part = get_part(drvID);
los_disk *disk = NULL;
- result = OsSdSync(drvID);
+ result = OsSdSync(part->disk_id);
if (result != 0) {
PRINTK("[ERROR]disk_cache_clear SD sync failed!\n");
return result;
}
- disk = get_disk(drvID);
+ disk = get_disk(part->disk_id);
if (disk == NULL) {
return -1;
}
diff --git a/fs/vfs/operation/fs_getlabel.c b/fs/vfs/operation/fs_getlabel.c
deleted file mode 100644
index b36ad19525f5f4ee5dfe2e042417542f1568d795..0000000000000000000000000000000000000000
--- a/fs/vfs/operation/fs_getlabel.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * 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.
- */
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include "vfs_config.h"
-
-#include "sys/mount.h"
-#include "errno.h"
-#include "fs/fs.h"
-
-#include "stdlib.h"
-
-#include "string.h"
-#include "disk.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Variables
- ****************************************************************************/
-
-/****************************************************************************
- * Public Variables
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: getlabel()
- *
- * Description:
- * getlabel() get the volume label of partition(disk) from FAT filesystem by
- * the 'target' path
- *
- * Parameters:
- * target : the path which is the mount point of FAT filesystem device.
- * label : the string var pointer, by which passed out label string.
- *
- * Return:
- * Zero is returned on success; -1 is returned on an error and errno is
- * set appropriately:
- *
- * ENOMEM There is no memory for allocated space for var.
- * EFAULT The pointer 'target' does not pass in corretly.
- * ENOENT The pointer 'target' pointed to a wrong location.
- * EPERM The pointer 'target' does not point to a mount inode.
- * EINVAL The pointer 'label' does not pass in correctly.
- * EACCES The filesystem which 'target' point to is not supported.
- *
- ****************************************************************************/
-
-int getlabel(const char *target, char *label)
-{
-#ifdef VFS_IMPL_LATER
- struct inode *mountpt_inode = NULL;
- int errcode = OK;
- int status;
- char *fullpath = NULL;
- struct inode_search_s desc;
- int ret;
- /* Verify required pointer arguments */
-
- if (target == NULL || label == NULL) {
- errcode = EFAULT;
- goto errout;
- }
-
- /* Get a absolute path */
-
- errcode = vfs_normalize_path((const char *)NULL, target, &fullpath);
- if (errcode < 0) {
- errcode = -errcode;
- goto errout;
- }
-
- /* Find the mountpt */
- SETUP_SEARCH(&desc, fullpath, false);
- ret = inode_find(&desc);
- if (ret < 0) {
- errcode = EACCES;
- goto errout_with_fullpath;
- }
- mountpt_inode = desc.node;
-
- /* Verfy the path is a mountpoint path or file path */
-
- if (!INODE_IS_MOUNTPT(mountpt_inode) && !INODE_IS_BLOCK(mountpt_inode)) {
- errcode = EPERM;
- goto errout_with_release;
- }
-
- if (mountpt_inode->u.i_mops) {
- status = LOS_OK;
- if (status < 0) {
- /* The inode is unhappy with the blkdrvr for some reason */
-
- errcode = -status;
- goto errout_with_release;
- }
- inode_release(mountpt_inode);
- free(fullpath);
- return OK;
- } else {
- errcode = EACCES;
- goto errout_with_release;
- }
-
- /* A lot of goto's! But they make the error handling much simpler */
-
-errout_with_release:
- inode_release(mountpt_inode);
-errout_with_fullpath:
- free(fullpath);
-errout:
- set_errno(errcode);
- return VFS_ERROR;
-#endif
- return 0;
-}
diff --git a/fs/vfs/operation/fs_virstatfs.c b/fs/vfs/operation/fs_virstatfs.c
index e9363e4ddc939f3e05ef4b065f1d7add05f0ce0f..2028faaa2c5da877878cad1d6fef2f19e88d45db 100644
--- a/fs/vfs/operation/fs_virstatfs.c
+++ b/fs/vfs/operation/fs_virstatfs.c
@@ -53,101 +53,7 @@
#ifdef LOSCFG_FS_FAT_VIRTUAL_PARTITION
int virstatfs(const char *path, struct statfs *buf)
{
-#ifdef VFS_IMPL_LATER
- struct inode *inode = NULL;
- int ret = OK;
- char *fullpath = NULL;
- struct inode_search_s desc;
-
- /* Sanity checks */
-
- if (!path || !buf)
- {
- ret = EFAULT;
- goto errout;
- }
-
- if (!path[0])
- {
- ret = ENOENT;
- goto errout;
- }
-
- ret = vfs_normalize_path((const char *)NULL, path, &fullpath);
- if (ret < 0)
- {
- ret = -ret;
- goto errout;
- }
-
- /* Get an inode for this file */
- SETUP_SEARCH(&desc, fullpath, false);
- ret = inode_find(&desc);
- if (ret < 0)
- {
- /* This name does not refer to a psudeo-inode and there is no
- * mountpoint that includes in this path.
- */
-
- ret = EACCES;
- free(fullpath);
- goto errout;
- }
- inode = desc.node;
-
- /* The way we handle the statfs depends on the type of inode that we
- * are dealing with.
- */
-
-#ifndef CONFIG_DISABLE_MOUNTPOINT
- if (INODE_IS_MOUNTPT(inode))
- {
- /* The node is a file system mointpoint. Verify that the mountpoint
- * supports the statfs() method
- */
-
- if (inode->u.i_mops)
- {
- /* Perform the statfs() operation */
-
- ret = LOS_OK;
- }
- else
- {
- ret = EINVAL;
- goto errout_with_inode;
- }
- }
- else
-#endif
- {
- ret = EINVAL;
- goto errout_with_inode;
- }
-
- /* Check if the statfs operation was successful */
-
- if (ret < 0)
- {
- ret = -ret;
- goto errout_with_inode;
- }
-
- /* Successfully statfs'ed the file */
-
- inode_release(inode);
- free(fullpath);
- return OK;
-
- /* Failure conditions always set the errno appropriately */
-
-errout_with_inode:
- inode_release(inode);
- free(fullpath);
-errout:
- set_errno(ret);
- return VFS_ERROR;
-#endif
- return 0;
+ //currently not implemented
+ return LOS_OK;
}
#endif
diff --git a/fs/vfs/path_cache.c b/fs/vfs/path_cache.c
index b60975edf3d1a69055f17ffa14a2be72a4f54380..2d607e2cddd48c444859424752c0ae3799bfa83a 100644
--- a/fs/vfs/path_cache.c
+++ b/fs/vfs/path_cache.c
@@ -64,16 +64,18 @@ void PathCacheDump(void)
void PathCacheMemoryDump(void)
{
int pathCacheNum = 0;
+ int nameSum = 0;
for (int i = 0; i < LOSCFG_MAX_PATH_CACHE_SIZE; i++) {
LIST_HEAD *dhead = &g_pathCacheHashEntrys[i];
struct PathCache *dent = NULL;
LOS_DL_LIST_FOR_EACH_ENTRY(dent, dhead, struct PathCache, hashEntry) {
pathCacheNum++;
+ nameSum += dent->nameLen;
}
}
PRINTK("pathCache number = %d\n", pathCacheNum);
- PRINTK("pathCache memory size = %d(B)\n", pathCacheNum * sizeof(struct PathCache));
+ PRINTK("pathCache memory size = %d(B)\n", pathCacheNum * sizeof(struct PathCache) + nameSum);
}
static uint32_t NameHash(const char *name, int len, struct Vnode *dvp)
diff --git a/fs/vfs/vfs_cmd/vfs_shellcmd.c b/fs/vfs/vfs_cmd/vfs_shellcmd.c
index 0c95699ea140a9daef76f2446fc1b94c57eb0860..29aa4bd08683fe29766328b1fdcb873c266c5ab2 100644
--- a/fs/vfs/vfs_cmd/vfs_shellcmd.c
+++ b/fs/vfs/vfs_cmd/vfs_shellcmd.c
@@ -837,6 +837,10 @@ static int os_shell_cmd_do_rmdir(const char *pathname)
return remove(pathname);
}
d = opendir(pathname);
+ if (d == NULL)
+ {
+ return -1;
+ }
while (1)
{
dirent = readdir(d);
diff --git a/fs/vfs/vnode.c b/fs/vfs/vnode.c
index af4971e0c14ab491ec42b397e0d1b046b341d177..fd72631fc25116245e637e7559d272f0084e25b3 100644
--- a/fs/vfs/vnode.c
+++ b/fs/vfs/vnode.c
@@ -47,7 +47,6 @@ static struct VnodeOps g_devfsOps;
#define ENTRY_TO_VNODE(ptr) LOS_DL_LIST_ENTRY(ptr, struct Vnode, actFreeEntry)
#define VNODE_LRU_COUNT 10
#define DEV_VNODE_MODE 0755
-#define MAX_ITER_TIMES 10
int VnodesInit(void)
{
@@ -98,8 +97,8 @@ struct Vnode *VnodeReclaimLru(void)
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, &g_vnodeCurrList, struct Vnode, actFreeEntry) {
if ((item->useCount > 0) ||
- (item->flag & VNODE_FLAG_MOUNT_NEW) ||
- (item->flag & VNODE_FLAG_MOUNT_ORIGIN)) {
+ (item->flag & VNODE_FLAG_MOUNT_ORIGIN) ||
+ (item->flag & VNODE_FLAG_MOUNT_NEW)) {
continue;
}
@@ -169,29 +168,21 @@ int VnodeFree(struct Vnode *vnode)
if (vnode == NULL) {
return LOS_OK;
}
- struct PathCache *item = NULL;
- struct PathCache *nextItem = NULL;
VnodeHold();
if (vnode->useCount > 0) {
VnodeDrop();
return -EBUSY;
}
- LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, &vnode->childPathCaches, struct PathCache, childEntry) {
- PathCacheFree(item);
- }
-
- LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, &vnode->parentPathCaches, struct PathCache, parentEntry) {
- PathCacheFree(item);
- }
+ VnodePathCacheFree(vnode);
LOS_ListDelete(&(vnode->hashEntry));
+ LOS_ListDelete(&vnode->actFreeEntry);
if (vnode->vop->Reclaim) {
vnode->vop->Reclaim(vnode);
}
- LOS_ListDelete(&vnode->actFreeEntry);
memset_s(vnode, sizeof(struct Vnode), 0, sizeof(struct Vnode));
LOS_ListAdd(&g_vnodeFreeList, &vnode->actFreeEntry);
@@ -201,83 +192,35 @@ int VnodeFree(struct Vnode *vnode)
return LOS_OK;
}
-int VnodeFreeIter(struct Vnode *vnode)
+int VnodeFreeAll(const struct Mount *mount)
{
- struct Vnode *vp = NULL;
- struct PathCache *item = NULL;
- struct PathCache *nextItem = NULL;
- int ret;
-
- LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, &vnode->childPathCaches, struct PathCache, childEntry) {
- vp = item->childVnode;
- if (vp == NULL) {
- continue;
- }
- ret = VnodeFreeIter(vp);
- if (ret != LOS_OK) {
- return ret;
- }
- }
- return VnodeFree(vnode);
-}
-
-int VnodeFreeAll(struct Mount *mnt)
-{
- struct Vnode *vp = NULL;
- struct Vnode *mountptVnode = mnt->vnodeCovered;
- struct PathCache *item = NULL;
- struct PathCache *nextItem = NULL;
+ struct Vnode *vnode = NULL;
+ struct Vnode *nextVnode = NULL;
int ret;
- LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, &mountptVnode->childPathCaches, struct PathCache, childEntry) {
- vp = item->childVnode;
- if (vp == NULL) {
- continue;
- }
- ret = VnodeFreeIter(vp);
- if (ret != LOS_OK) {
- return ret;
+ LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(vnode, nextVnode, &g_vnodeCurrList, struct Vnode, actFreeEntry) {
+ if ((vnode->originMount == mount) && !(vnode->flag & VNODE_FLAG_MOUNT_NEW)) {
+ ret = VnodeFree(vnode);
+ if (ret != LOS_OK) {
+ return ret;
+ }
}
}
- return 0;
-}
-static VOID VnodeIterDump(struct Vnode *vnode, int increase)
-{
- static int count = 0;
- LIST_ENTRY *list = &vnode->parentPathCaches;
- struct PathCache *pathCache = LOS_DL_LIST_ENTRY(list->pstNext, struct PathCache, parentEntry);
- count += increase;
- if (count >= MAX_ITER_TIMES) {
- PRINTK("########## Vnode In Use Iteration ##########\n");
- PRINTK("Iteration times: %d\n", count);
- PRINTK("%p -- %s --> %p\n", vnode->parent, pathCache->name, vnode);
- PathCacheDump();
- }
+ return LOS_OK;
}
-BOOL VnodeInUseIter(struct Vnode *vnode)
+BOOL VnodeInUseIter(const struct Mount *mount)
{
- struct Vnode *vp = NULL;
- struct PathCache *item = NULL;
- struct PathCache *nextItem = NULL;
+ struct Vnode *vnode = NULL;
- VnodeIterDump(vnode, 1);
- if (vnode->useCount > 0) {
- VnodeIterDump(vnode, -1);
- return TRUE;
- }
- LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, &vnode->childPathCaches, struct PathCache, childEntry) {
- vp = item->childVnode;
- if (vp == NULL) {
- continue;
- }
- if (VnodeInUseIter(vp) == TRUE) {
- VnodeIterDump(vnode, -1);
- return TRUE;
+ LOS_DL_LIST_FOR_EACH_ENTRY(vnode, &g_vnodeCurrList, struct Vnode, actFreeEntry) {
+ if (vnode->originMount == mount) {
+ if ((vnode->useCount > 0) || (vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)) {
+ return TRUE;
+ }
}
}
- VnodeIterDump(vnode, -1);
return FALSE;
}
@@ -335,7 +278,7 @@ static int PreProcess(const char *originPath, struct Vnode **startVnode, char **
static struct Vnode *ConvertVnodeIfMounted(struct Vnode *vnode)
{
- if ((vnode == NULL) || !(vnode->flag & VNODE_FLAG_MOUNT_NEW)) {
+ if ((vnode == NULL) || !(vnode->flag & VNODE_FLAG_MOUNT_ORIGIN)) {
return vnode;
}
return vnode->newMount->vnodeCovered;
@@ -487,7 +430,7 @@ static void ChangeRootInternal(struct Vnode *rootOld, char *dirname)
mnt->vnodeBeCovered = nodeInFs;
nodeInFs->newMount = mnt;
- nodeInFs->flag |= VNODE_FLAG_MOUNT_NEW;
+ nodeInFs->flag |= VNODE_FLAG_MOUNT_ORIGIN;
break;
}
@@ -600,7 +543,7 @@ int VnodeDevInit()
return -ENOMEM;
}
devMount->vnodeCovered = devNode;
- devMount->vnodeBeCovered->flag |= VNODE_FLAG_MOUNT_NEW;
+ devMount->vnodeBeCovered->flag |= VNODE_FLAG_MOUNT_ORIGIN;
return LOS_OK;
}
@@ -668,8 +611,8 @@ void VnodeMemoryDump(void)
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, &g_vnodeCurrList, struct Vnode, actFreeEntry) {
if ((item->useCount > 0) ||
- (item->flag & VNODE_FLAG_MOUNT_NEW) ||
- (item->flag & VNODE_FLAG_MOUNT_ORIGIN)) {
+ (item->flag & VNODE_FLAG_MOUNT_ORIGIN) ||
+ (item->flag & VNODE_FLAG_MOUNT_NEW)) {
continue;
}
@@ -679,3 +622,27 @@ void VnodeMemoryDump(void)
PRINTK("Vnode number = %d\n", vnodeCount);
PRINTK("Vnode memory size = %d(B)\n", vnodeCount * sizeof(struct Vnode));
}
+
+int VnodeDestory(struct Vnode *vnode)
+{
+ if (vnode == NULL || vnode->vop != &g_devfsOps) {
+ /* destory only support dev vnode */
+ return -EINVAL;
+ }
+
+ VnodeHold();
+ if (vnode->useCount > 0) {
+ VnodeDrop();
+ return -EBUSY;
+ }
+
+ VnodePathCacheFree(vnode);
+ LOS_ListDelete(&(vnode->hashEntry));
+ LOS_ListDelete(&vnode->actFreeEntry);
+
+ free(vnode->data);
+ free(vnode);
+ VnodeDrop();
+
+ return LOS_OK;
+}
diff --git a/fs/vfs/vnode_hash.c b/fs/vfs/vnode_hash.c
index c50733dd49712af2020eb1bf057796939e7bb92a..9a97bfaddb9fb99e00c915e4314f2c65a5e961cd 100644
--- a/fs/vfs/vnode_hash.c
+++ b/fs/vfs/vnode_hash.c
@@ -134,4 +134,4 @@ int VfsHashInsert(struct Vnode *vnode, uint32_t hash)
LOS_ListHeadInsert(VfsHashBucket(vnode->originMount, hash), &vnode->hashEntry);
(void)LOS_MuxUnlock(&g_vnodeHashMux);
return LOS_OK;
-}
+}
\ No newline at end of file
diff --git a/kernel/base/core/los_sortlink.c b/kernel/base/core/los_sortlink.c
index bca4e57023cf846630b660d960e09ae94db09c7e..8a997e50863767b1709a1b462101536c117e696f 100644
--- a/kernel/base/core/los_sortlink.c
+++ b/kernel/base/core/los_sortlink.c
@@ -55,10 +55,14 @@ STATIC INLINE VOID OsAddNode2SortLink(SortLinkAttribute *sortLinkHeader, SortLin
}
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(head->pstNext, SortLinkList, sortLinkNode);
- if (listSorted->responseTime >= sortList->responseTime) {
+ if (listSorted->responseTime > sortList->responseTime) {
LOS_ListAdd(head, &sortList->sortLinkNode);
sortLinkHeader->nodeNum++;
return;
+ } else if (listSorted->responseTime == sortList->responseTime) {
+ LOS_ListAdd(head->pstNext, &sortList->sortLinkNode);
+ sortLinkHeader->nodeNum++;
+ return;
}
LOS_DL_LIST *prevNode = head->pstPrev;
diff --git a/kernel/base/include/los_vm_map.h b/kernel/base/include/los_vm_map.h
index 32d6038dc68d60bc44a1e8b8e6dabcfd332d9c94..4d99823115758861163959f1d14645e22a0f5855 100644
--- a/kernel/base/include/los_vm_map.h
+++ b/kernel/base/include/los_vm_map.h
@@ -107,9 +107,8 @@ struct VmMapRegion {
typedef struct VmSpace {
LOS_DL_LIST node; /**< vm space dl list */
- LOS_DL_LIST regions; /**< region dl list */
LosRbTree regionRbTree; /**< region red-black tree root */
- LosMux regionMux; /**< region list mutex lock */
+ LosMux regionMux; /**< region red-black tree mutex lock */
VADDR_T base; /**< vm space base addr */
UINT32 size; /**< vm space size */
VADDR_T heapBase; /**< vm space heap base address */
diff --git a/kernel/base/vm/los_vm_filemap.c b/kernel/base/vm/los_vm_filemap.c
index 860703027b386b2522912e9908834b817dded042..9447b3daa6ef6f8c6660c2f1d373c5b7d8057555 100644
--- a/kernel/base/vm/los_vm_filemap.c
+++ b/kernel/base/vm/los_vm_filemap.c
@@ -123,149 +123,6 @@ VOID OsDeletePageCacheLru(LosFilePage *page)
OsPageCacheDel(page);
}
-#if VFS_IMPL_LATER
-STATIC LosFilePage *OsPagecacheGetPageAndFill(struct file *filp, VM_OFFSET_T pgOff, size_t *readSize, VADDR_T *kvaddr)
-{
- LosFilePage *page = NULL;
- struct page_mapping *mapping = filp->f_mapping;
-
- page = OsFindGetEntry(mapping, pgOff);
- if (page != NULL) {
- OsSetPageLocked(page->vmPage);
- OsPageRefIncLocked(page);
- *kvaddr = (VADDR_T)(UINTPTR)OsVmPageToVaddr(page->vmPage);
- *readSize = PAGE_SIZE;
- } else {
- page = OsPageCacheAlloc(mapping, pgOff);
- if (page == NULL) {
- VM_ERR("Failed to alloc a page frame");
- return page;
- }
- OsSetPageLocked(page->vmPage);
- *kvaddr = (VADDR_T)(UINTPTR)OsVmPageToVaddr(page->vmPage);
-
- file_seek(filp, pgOff << PAGE_SHIFT, SEEK_SET);
- /* "ReadPage" func exists definitely in this procedure */
- *readSize = filp->f_vnode->u.i_mops->readpage(filp, (char *)(UINTPTR)*kvaddr, PAGE_SIZE);
- if (*readSize == 0) {
- VM_ERR("read 0 bytes");
- OsCleanPageLocked(page->vmPage);
- }
- OsAddToPageacheLru(page, mapping, pgOff);
- }
-
- return page;
-}
-
-
-ssize_t OsMappingRead(struct file *filp, char *buf, size_t size)
-{
- INT32 ret;
- vaddr_t kvaddr = 0;
- UINT32 intSave;
- struct stat bufStat;
- size_t readSize = 0;
- size_t readTotal = 0;
- size_t readLeft = size;
- LosFilePage *page = NULL;
- VM_OFFSET_T pos = file_seek(filp, 0, SEEK_CUR);
- VM_OFFSET_T pgOff = pos >> PAGE_SHIFT;
- INT32 offInPage = pos % PAGE_SIZE;
- struct page_mapping *mapping = filp->f_mapping;
- INT32 nPages = (ROUNDUP(pos + size, PAGE_SIZE) - ROUNDDOWN(pos, PAGE_SIZE)) >> PAGE_SHIFT;
-
- ret = stat(filp->f_path, &bufStat);
- if (ret != OK) {
- VM_ERR("Get file size failed. (filepath=%s)", filp->f_path);
- return 0;
- }
-
- if (pos >= bufStat.st_size) {
- PRINT_INFO("%s filp->f_pos >= bufStat.st_size (pos=%ld, fileSize=%ld)\n", filp->f_path, pos, bufStat.st_size);
- return 0;
- }
-
- LOS_SpinLockSave(&mapping->list_lock, &intSave);
-
- for (INT32 i = 0; (i < nPages) && readLeft; i++, pgOff++) {
- page = OsPagecacheGetPageAndFill(filp, pgOff, &readSize, &kvaddr);
- if ((page == NULL) || (readSize == 0)) {
- break;
- }
- if (readSize < PAGE_SIZE) {
- readLeft = readSize;
- }
-
- readSize = MIN2((PAGE_SIZE - offInPage), readLeft);
-
- (VOID)memcpy_s((VOID *)buf, readLeft, (char *)(UINTPTR)kvaddr + offInPage, readSize);
- buf += readSize;
- readLeft -= readSize;
- readTotal += readSize;
-
- offInPage = 0;
-
- OsCleanPageLocked(page->vmPage);
- }
-
- LOS_SpinUnlockRestore(&mapping->list_lock, intSave);
- file_seek(filp, pos + readTotal, SEEK_SET);
-
- return readTotal;
-}
-#endif
-
-ssize_t OsMappingWrite(struct file *filp, const char *buf, size_t size)
-{
- VADDR_T kvaddr;
- UINT32 intSave;
- INT32 writeSize = 0;
- size_t writeLeft = size;
- VM_OFFSET_T pos = file_seek(filp, 0, SEEK_CUR);
- VM_OFFSET_T pgOff = pos >> PAGE_SHIFT;
- INT32 offInPage = pos % PAGE_SIZE;
- LosFilePage *page = NULL;
- struct page_mapping *mapping = filp->f_mapping;
- INT32 nPages = (ROUNDUP(pos + size, PAGE_SIZE) - ROUNDDOWN(pos, PAGE_SIZE)) >> PAGE_SHIFT;
-
- LOS_SpinLockSave(&mapping->list_lock, &intSave);
-
- for (INT32 i = 0; i < nPages; i++, pgOff++) {
- page = OsFindGetEntry(mapping, pgOff);
- if (page) {
- kvaddr = (VADDR_T)(UINTPTR)OsVmPageToVaddr(page->vmPage);
- OsSetPageLocked(page->vmPage);
- OsPageRefIncLocked(page);
- } else {
- page = OsPageCacheAlloc(mapping, pgOff);
- if (page == NULL) {
- VM_ERR("Failed to alloc a page frame");
- break;
- }
- kvaddr = (VADDR_T)(UINTPTR)OsVmPageToVaddr(page->vmPage);
- OsAddToPageacheLru(page, mapping, pgOff);
- OsSetPageLocked(page->vmPage);
- }
-
- writeSize = MIN2((PAGE_SIZE - offInPage), writeLeft);
-
- (VOID)memcpy_s((char *)(UINTPTR)kvaddr + offInPage, writeLeft, buf, writeSize);
- buf += writeSize;
- writeLeft -= writeSize;
-
- OsMarkPageDirty(page, NULL, offInPage, writeSize);
-
- offInPage = 0;
-
- OsCleanPageLocked(page->vmPage);
- }
-
- LOS_SpinUnlockRestore(&mapping->list_lock, intSave);
-
- file_seek(filp, pos + size - writeLeft, SEEK_SET);
- return (size - writeLeft);
-}
-
STATIC VOID OsPageCacheUnmap(LosFilePage *fpage, LosArchMmu *archMmu, VADDR_T vaddr)
{
UINT32 intSave;
diff --git a/kernel/base/vm/los_vm_map.c b/kernel/base/vm/los_vm_map.c
index 89790369e20fa9a4e82bc727b68065a148160baa..9524279605d9dadbbf40d441d6b2bfd302093587 100644
--- a/kernel/base/vm/los_vm_map.c
+++ b/kernel/base/vm/los_vm_map.c
@@ -132,7 +132,6 @@ STATIC BOOL OsVmSpaceInitCommon(LosVmSpace *vmSpace, VADDR_T *virtTtb)
{
LOS_RbInitTree(&vmSpace->regionRbTree, OsRegionRbCmpKeyFn, OsRegionRbFreeFn, OsRegionRbGetKeyFn);
- LOS_ListInit(&vmSpace->regions);
status_t retval = LOS_MuxInit(&vmSpace->regionMux, NULL);
if (retval != LOS_OK) {
VM_ERR("Create mutex for vm space failed, status: %d", retval);
@@ -239,34 +238,6 @@ STATIC BOOL OsVmSpaceParamCheck(LosVmSpace *vmSpace)
return TRUE;
}
-LosVmMapRegion *OsShareRegionClone(LosVmMapRegion *oldRegion)
-{
- /* no need to create vm object */
- LosVmMapRegion *newRegion = LOS_MemAlloc(m_aucSysMem0, sizeof(LosVmMapRegion));
- if (newRegion == NULL) {
- VM_ERR("malloc new region struct failed.");
- return NULL;
- }
-
- /* todo: */
- *newRegion = *oldRegion;
- return newRegion;
-}
-
-LosVmMapRegion *OsPrivateRegionClone(LosVmMapRegion *oldRegion)
-{
- /* need to create vm object */
- LosVmMapRegion *newRegion = LOS_MemAlloc(m_aucSysMem0, sizeof(LosVmMapRegion));
- if (newRegion == NULL) {
- VM_ERR("malloc new region struct failed.");
- return NULL;
- }
-
- /* todo: */
- *newRegion = *oldRegion;
- return newRegion;
-}
-
STATUS_T LOS_VmSpaceClone(LosVmSpace *oldVmSpace, LosVmSpace *newVmSpace)
{
LosVmMapRegion *oldRegion = NULL;
@@ -841,11 +812,6 @@ STATUS_T OsIsRegionCanExpand(LosVmSpace *space, LosVmMapRegion *region, size_t s
return LOS_NOK;
}
- /* if next node is head, then we can expand */
- if (OsIsVmRegionEmpty(space) == TRUE) {
- return LOS_OK;
- }
-
nextRegion = (LosVmMapRegion *)LOS_RbSuccessorNode(&space->regionRbTree, ®ion->rbNode);
/* if the gap is larger than size, then we can expand */
if ((nextRegion != NULL) && ((nextRegion->range.base - region->range.base) >= size)) {
diff --git a/kernel/base/vm/shm.c b/kernel/base/vm/shm.c
index 9de9d54ecbcaae5da29c72946f2ddb9bbf28b850..aadca5f1c248b1d93015c626dd17fff3ea732ab6 100644
--- a/kernel/base/vm/shm.c
+++ b/kernel/base/vm/shm.c
@@ -435,11 +435,6 @@ INT32 ShmGet(key_t key, size_t size, INT32 shmflg)
INT32 shmid;
SYSV_SHM_LOCK();
- if (!((UINT32)shmflg & IPC_CREAT) &&
- ((UINT32)shmflg & IPC_EXCL)) {
- ret = -EINVAL;
- goto ERROR;
- }
if (key == IPC_PRIVATE) {
ret = ShmAllocSeg(key, size, shmflg);
@@ -454,6 +449,11 @@ INT32 ShmGet(key_t key, size_t size, INT32 shmflg)
}
} else {
shmid = ret;
+ if (((UINT32)shmflg & IPC_CREAT) &&
+ ((UINT32)shmflg & IPC_EXCL)) {
+ ret = -EEXIST;
+ goto ERROR;
+ }
ret = ShmPermCheck(ShmFindSeg(shmid), (UINT32)shmflg & ACCESSPERMS);
if (ret != 0) {
ret = -ret;
diff --git a/kernel/common/Kconfig b/kernel/common/Kconfig
index 66af51a10954d51e0e65b14bc2a1930e1b1d6da7..000bccd5eed6cde45107a3d3aebe0d2a35d187b8 100644
--- a/kernel/common/Kconfig
+++ b/kernel/common/Kconfig
@@ -28,8 +28,23 @@ endchoice
config BOOTENV_ADDR
int "Address of boot command line (KB)"
- depends on PLATFORM_ROOTFS
+ depends on PLATFORM_ROOTFS && (STORAGE_SPINOR || STORAGE_SPINAND || STORAGE_EMMC)
range 0 1024
default 512
help
Boot command line addr, range from 0 to 1MB.
+
+config BOOTENV_RAM
+ bool "Read bootenv from RAM"
+ default n
+ depends on PLATFORM_ROOTFS
+ help
+ Answer Y to read bootenv from ram. Need boot copy to RAM.
+
+config BOOTENV_RAMSIZE
+ int "Size of boot environment in RAM (Byte)"
+ depends on PLATFORM_ROOTFS && BOOTENV_RAM
+ range 128 1024
+ default 512
+ help
+ Boot environment in Ram space size, range from 128 to 1024 byte.
diff --git a/kernel/common/los_config.c b/kernel/common/los_config.c
index f67921fcbd4f02fcae14b265d4a5f446f549daa7..d593007f7bce97af80c37adb1187c1f112e64091 100644
--- a/kernel/common/los_config.c
+++ b/kernel/common/los_config.c
@@ -117,10 +117,6 @@
#include "los_hilog.h"
#endif
-#ifdef LOSCFG_QUICK_START
-#include "los_quick_start_pri.h"
-#endif
-
STATIC SystemRebootFunc g_rebootHook = NULL;
@@ -388,13 +384,6 @@ STATIC UINT32 OsSystemInitTaskCreate(VOID)
return LOS_TaskCreate(&taskID, &sysTask);
}
-#ifdef LOSCFG_QUICK_START
-UINT32 OsSystemInitStep2(VOID)
-{
- SystemInit2();
- return 0;
-}
-#endif
UINT32 OsSystemInit(VOID)
{
diff --git a/kernel/common/los_rootfs.c b/kernel/common/los_rootfs.c
index 3457826c8e9d5acad2b63cf2b672d1e37a597648..9db34881802d75440e12f31d999cd096296cfba1 100644
--- a/kernel/common/los_rootfs.c
+++ b/kernel/common/los_rootfs.c
@@ -219,7 +219,7 @@ STATIC const CHAR *GetDevName(const CHAR *rootType, INT32 rootAddr, INT32 rootSi
#ifndef LOSCFG_SECURITY_BOOT
STATIC INT32 GetArgs(CHAR **args)
{
-#ifdef LOSCFG_QUICK_START
+#ifdef LOSCFG_BOOTENV_RAM
*args = OsGetArgsAddr();
return LOS_OK;
@@ -387,7 +387,7 @@ STATIC INT32 GetRootType(CHAR **rootType, CHAR **fsType, INT32 *rootAddr, INT32
PRINT_ERR("Cannot get bootargs!\n");
return LOS_NOK;
}
-#ifndef LOSCFG_QUICK_START
+#ifndef LOSCFG_BOOTENV_RAM
CHAR *argsBak = NULL;
argsBak = args;
#endif
@@ -399,7 +399,7 @@ STATIC INT32 GetRootType(CHAR **rootType, CHAR **fsType, INT32 *rootAddr, INT32
p = strsep(&args, " ");
}
if ((*fsType != NULL) && (*rootType != NULL)) {
-#ifndef LOSCFG_QUICK_START
+#ifndef LOSCFG_BOOTENV_RAM
free(argsBak);
#endif
return LOS_OK;
@@ -415,7 +415,7 @@ ERROUT:
free(*fsType);
*fsType = NULL;
}
-#ifndef LOSCFG_QUICK_START
+#ifndef LOSCFG_BOOTENV_RAM
free(argsBak);
#endif
return LOS_NOK;
@@ -444,7 +444,7 @@ STATIC VOID OsMountUserdata(const CHAR *fsType)
return;
}
err = get_errno();
- if (err == ENOENT) {
+ if (err == ENOTSUP) {
#ifdef LOSCFG_FS_FAT
ret = format(emmcUserdataDev, 0, FM_FAT32);
if (ret != LOS_OK) {
diff --git a/kernel/common/los_rootfs.h b/kernel/common/los_rootfs.h
index c73813b8e0659fab6bd40827ce4b1c1e02aa931c..f2de0986d83a202b4664ac2042a91512bfe8e9b0 100644
--- a/kernel/common/los_rootfs.h
+++ b/kernel/common/los_rootfs.h
@@ -76,7 +76,7 @@ INT32 OsMountRootfs(VOID);
VOID OsSetCmdLineAddr(UINT64 addr);
UINT64 OsGetCmdLineAddr(VOID);
-#ifdef LOSCFG_QUICK_START
+#ifdef LOSCFG_BOOTENV_RAM
CHAR *OsGetArgsAddr(VOID);
#endif
#endif /* _LOS_ROOTFS_H */
diff --git a/testsuites/Kconfig b/testsuites/Kconfig
new file mode 100644
index 0000000000000000000000000000000000000000..b93b9a8912974e55d09ad38f5cd0d7c7ddcd0b78
--- /dev/null
+++ b/testsuites/Kconfig
@@ -0,0 +1,50 @@
+# 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.
+
+
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+mainmenu "Huawei LiteOS Configuration"
+
+menu "Enable Kernel TestSuit"
+
+config KERNEL_TEST
+ bool "Enable Kernel Testsuit"
+
+config TEST
+ bool "Enable Auto TestSuit"
+ default y
+ depends on KERNEL_TEST
+
+source "./kernel/Kconfig"
+source "./kernel/Kconfig_case"
+endmenu
+
diff --git a/testsuites/LICENSE b/testsuites/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..b6ffd6e677539292acb8b9223daf0688e63fbab6
--- /dev/null
+++ b/testsuites/LICENSE
@@ -0,0 +1,28 @@
+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.
diff --git a/testsuites/Makefile b/testsuites/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..4b3d7ee8bc3405bba6ed79804f9dcb6d323dbf4f
--- /dev/null
+++ b/testsuites/Makefile
@@ -0,0 +1,127 @@
+# 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.
+
+LITEOSTESTTOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
+export OS=$(shell uname -s)
+ifneq ($(OS), Linux)
+LITEOSTESTTOPDIR := $(shell dirname $(subst \,/,$(LITEOSTESTTOPDIR))/./)
+endif
+
+LITEOSTOPDIR := $(LITEOSTESTTOPDIR)/..
+export LITEOSTOPDIR
+export LITEOSTESTTOPDIR
+
+-include $(LITEOSTESTTOPDIR)/config.mk
+
+RM = -rm -rf
+MAKE = make
+__LIBS = libs
+APPS = apps
+KERNEL = kernel
+TEST = test
+TEST_KERNEL = test_kernel
+TEST_APPS = test_apps
+ROOTFSDIR = rootfsdir
+ROOTFS = rootfs
+HIDE := @
+
+LITEOS_TEST_TARGET = liteos_ktest
+LITEOS_TEST_LIBC = test_libs
+LITEOS_LIBS_TARGET = libs_target
+
+LITEOS_TEST_AUTOCONFIG_H = $(LITEOSTESTTOPDIR)/include/generated/autoconf.h
+LITEOS_TEST_KERNEL_MENUCONFIG_H = $(LITEOSTESTTOPDIR)/kernel/include
+#######LITEOS_TEST_USER_MENUCONFIG_H = $(LITEOSTESTTOPDIR)/apps/include
+ifeq ($(LOSCFG_KERNEL_TEST), y)
+LITEOS_TEST_MENUCONFIG_H = $(LITEOS_TEST_KERNEL_MENUCONFIG_H)/test_menuconfig.h
+#######else
+#######LITEOS_TEST_MENUCONFIG_H = $(LITEOS_TEST_USER_MENUCONFIG_H)/test_menuconfig.h
+endif
+
+ifeq ($(LOSCFG_STORAGE_SPINOR), y)
+FSTYPE = jffs2
+endif
+ifeq ($(LOSCFG_STORAGE_EMMC), y)
+FSTYPE = vfat
+endif
+ROOTFS_DIR = $(OUT)/rootfs
+ROOTFS_ZIP = $(OUT)/rootfs.zip
+VERSION =
+
+LITEOS_LIBDEP := $(LITEOS_BASELIB)
+
+$(TEST_KERNEL): $(LITEOS_TEST_TARGET)
+
+$(LITEOS_TEST_TARGET): $(LITEOS_TEST_LIBC)
+ $(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) $(LITEOS_DYNLDFLAGS) -Map=$(OUT)/$@.map -o $(OUT)/$@ --start-group $(LITEOS_LIBDEP) --end-group
+ $(OBJCOPY) -O binary $(OUT)/$@ $(LITEOS_TARGET_DIR)/$@.bin
+ $(OBJDUMP) -t $(OUT)/$@ |sort >$(OUT)/$@.sym.sorted
+ $(OBJDUMP) -d $(OUT)/$@ >$(OUT)/$@.asm
+
+$(LITEOS_TEST_LIBC): $(KERNEL)
+ $(HIDE)for dir in $(TESTLIB_SUBDIRS); \
+ do $(MAKE) -C $$dir all || exit 1; \
+ done
+ $(HIDE)echo "=============== make lib done ==============="
+
+$(KERNEL): $(LITEOS_TEST_AUTOCONFIG_H)
+ $(HIDE)$(MAKE) -C ../ lib || exit 1
+ #echo "LITEOS_CFLAGS : $(LITEOS_CFLAGS)"
+
+##### make test menuconfig #####
+export CONFIG_=LOSCFG_
+MENUCONFIG_PATH = $(LITEOSTOPDIR)/tools/menuconfig
+TEST_KCONFIG_FILE_PATH = $(LITEOSTESTTOPDIR)/Kconfig
+
+menuconfig:$(MENUCONFIG_PATH)/mconf
+ $< $(TEST_KCONFIG_FILE_PATH)
+
+genconfig:$(MENUCONFIG_PATH)/conf
+ $(HIDE)mkdir -p include/config include/generated
+ $< --silentoldconfig $(TEST_KCONFIG_FILE_PATH)
+ mv -f $(LITEOS_TEST_AUTOCONFIG_H) $(LITEOS_TEST_MENUCONFIG_H)
+
+##### menuconfig end #######
+
+genconfig:$(MENUCONFIG_PATH)/conf
+
+$(LITEOS_TEST_AUTOCONFIG_H):
+ifneq ($(LITEOS_TEST_MENUCONFIG_H), $(wildcard $(LITEOS_TEST_MENUCONFIG_H)))
+ $(HIDE)$(MAKE) genconfig
+endif
+
+clean:
+ $(HIDE)$(MAKE) -C ../ clean || exit 1
+ $(HIDE)for dir in $(TESTLIB_SUBDIRS); \
+ do $(MAKE) -C $$dir clean || exit 1; \
+ done
+ $(HIDE)$(RM) include
+ $(HIDE)$(RM) $(LITEOS_TEST_MENUCONFIG_H)
+ $(HIDE)$(RM) $(OUT)
+.PHONY: test_apps test_kernel clean
diff --git a/testsuites/build/los_test_config.mk b/testsuites/build/los_test_config.mk
new file mode 100644
index 0000000000000000000000000000000000000000..18d8808d2382b41c36d2ad9fa4f341ec4aae7e16
--- /dev/null
+++ b/testsuites/build/los_test_config.mk
@@ -0,0 +1,43 @@
+# 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.
+
+
+TESTLIB_SUBDIRS :=
+
+-include $(LITEOSTESTTOPDIR)/.config
+ifeq ($(LOSCFG_KERNEL_TEST), y)
+-include $(LITEOSTESTTOPDIR)/kernel/test.mk
+endif
+
+ifeq ($(LOSCFG_LLTREPORT) ,y)
+# -fprofile-arcs may introduce false alarm on 'maybe-uninitialized'
+LITEOS_GCOV_OPTS := -fprofile-arcs -ftest-coverage -Wno-maybe-uninitialized
+LITEOS_BASELIB += -lgcov
+endif
+
diff --git a/testsuites/config.mk b/testsuites/config.mk
new file mode 100644
index 0000000000000000000000000000000000000000..ed3df669dd12992704e580097204664869cf46e2
--- /dev/null
+++ b/testsuites/config.mk
@@ -0,0 +1,49 @@
+# 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 $(LITEOSTOPDIR)/tools/build/config.mk
+-include $(LITEOSTESTTOPDIR)/build/los_test_config.mk
+LITEOS_CFLAGS += -I $(LITEOSTOPDIR)/lib/libc/musl/include \
+ -I $(LITEOSTOPDIR)/lib/libc/musl/obj/include \
+ -I $(LITEOSTOPDIR)/lib/libc/musl/arch/arm \
+ -I $(LITEOSTOPDIR)/lib/libc/musl/arch/generic \
+ -I $(LITEOSTHIRDPARTY)/bounds_checking_function/include \
+ -I $(LITEOSTOPDIR)/security/cap/ \
+ -I $(LITEOSTOPDIR)/security/vid/ \
+ -I $(LITEOSTOPDIR)/platform/include \
+ -I $(LITEOSTOPDIR)/kernel/base/include\
+ -I $(LITEOSTOPDIR)/kernel/include \
+ -I $(LITEOSTOPDIR)/kernel/extended/include \
+ -I $(LITEOSTOPDIR)/fs/vfs \
+ -I $(LITEOSTHIRDPARTY)/FatFs/source \
+ -I $(LITEOSTOPDIR)/fs/proc/include \
+ -I $(LITEOSTOPDIR)/fs/jffs2/os_adapt \
+ -I $(LITEOSTHIRDPARTY)/NuttX/fs/nfs/ \
+ -I $(LITEOSTOPDIR)/bsd/compat/linuxkpi/include
diff --git a/testsuites/kernel/BUILD.gn b/testsuites/kernel/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..77a11a8775ee096487c2b8774ae330ba1e75e870
--- /dev/null
+++ b/testsuites/kernel/BUILD.gn
@@ -0,0 +1,142 @@
+# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+import("//build/lite/config/component/lite_component.gni")
+
+static_library("test_base") {
+
+ sources = [
+ "src/ChipTest.c",
+ "src/iCunit.c",
+ "src/osTest.c",
+ "src/testrun_shellcmd.c",
+ "src/testusb_shellcmd.c",
+ ]
+
+ include_dirs = [
+ "../kernel/base/includ",
+ "../kernel/include",
+ "../kernel/extended/include",
+ "include",
+ "../fs/vfs",
+ "../fs/proc/include",
+ "../fs/jffs2/include",
+ "../fs/nfs/include",
+ "../bsd/compat/linuxkpi/include",
+ ]
+}
+
+lite_component("test") {
+ features = [ ":test_base" ]
+
+# KERNEL BASE TEST
+ if (LOSCFG_TEST_KERNEL_BASE_IPC) {
+ features += [ "sample/kernel_base/ipc:test_ipc" ]
+ }
+ if (LOSCFG_TEST_KERNEL_BASE_CORE) {
+ features += [ "sample/kernel_base/core:test_core" ]
+ }
+ if (LOSCFG_TEST_KERNEL_BASE_MP) {
+ features += [ "sample/kernel_base/mp:test_mp" ]
+ }
+ if (LOSCFG_TEST_KERNEL_BASE_MEM) {
+ features += [ "sample/kernel_base/mem:test_mem" ]
+ }
+ if (LOSCFG_TEST_KERNEL_BASE_MISC) {
+ features += [ "sample/kernel_base/misc:test_misc" ]
+ }
+ if (LOSCFG_TEST_KERNEL_BASE_OM) {
+ features += [ "sample/kernel_base/om:test_om" ]
+ }
+ if (LOSCFG_TEST_KERNEL_BASE_ATOMIC) {
+ features += [ "sample/kernel_base/atomic:test_atomic" ]
+ }
+
+# KERNEL EXTEND TEST
+ if (LOSCFG_TEST_KERNEL_EXTEND_CPP) {
+ features += [ "sample/kernel_extend/cpp:test_cpp" ]
+ }
+ if (LOSCFG_TEST_KERNEL_EXTEND_CPUP) {
+ features += [ "sample/kernel_extend/cpup:test_cpup" ]
+ }
+ if (LOSCFG_TEST_KERNEL_EXTEND_MMU) {
+ features += [ "sample/kernel_extend/mmu:test_mmu" ]
+ }
+
+# COMPAT TEST
+ if (LOSCFG_TEST_POSIX) {
+ features += [
+ "sample/posix:test_posix",
+ # "sample/posix/smp:test_posix_smp",
+ ]
+ }
+ # if (LOSCFG_TEST_POSIX_MEM) {
+ # features += [ "sample/posix/mem:test_posix_mem" ]
+ # }
+ # if (LOSCFG_TEST_POSIX_MQUEUE) {
+ # features += [ "sample/posix/mqueue:test_posix_mqueue" ]
+ # }
+ # if (LOSCFG_TEST_POSIX_MUTEX) {
+ # features += [ "sample/posix/mutex:test_posix_mutex" ]
+ # }
+ # if (LOSCFG_TEST_POSIX_PTHREAD) {
+ # features += [ "sample/posix/pthread:test_posix_pthread" ]
+ # }
+ # if (LOSCFG_TEST_POSIX_SCHED) {
+ # features += [ "sample/posix/sched:test_posix_sched" ]
+ # }
+ # if (LOSCFG_TEST_POSIX_SEM) {
+ # features += [ "sample/posix/sem:test_posix_sem" ]
+ # }
+ # if (LOSCFG_TEST_POSIX_SWTMR) {
+ # features += [ "sample/posix/swtmr:test_posix_swtmr" ]
+ # }
+ if (LOSCFG_TEST_LINUX) {
+ features += [ "sample/linux:test_linux" ]
+ }
+ #if (LOSCFG_TEST_LINUX_HRTIMER) {
+ # features += [ "sample/linux/hrtimer:test_linux_hrtimer" ]
+ #}
+
+# LIBC TEST
+ if (LOSCFG_TEST_LIBC) {
+ features += [ "sample/libc:test_libc" ]
+ }
+
+# LIBM TEST
+ if (LOSCFG_TEST_LIBM) {
+ features += [ "sample/libm:test_libm" ]
+ }
+
+# SHELL TEST
+ if (LOSCFG_TEST_SHELL) {
+ features += [ "sample/shell:test_shell" ]
+ }
+}
diff --git a/testsuites/kernel/Kconfig b/testsuites/kernel/Kconfig
new file mode 100644
index 0000000000000000000000000000000000000000..e6165afab2ae53a45a203fcfc71a039ce7af3a30
--- /dev/null
+++ b/testsuites/kernel/Kconfig
@@ -0,0 +1,426 @@
+# 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.
+
+
+config TEST_LEVEL
+ bool "Enable Test Level"
+ default y
+ depends on TEST
+
+config TEST_SMOKE
+ bool "Enable Test smoke"
+ default y
+ depends on TEST && TEST_LEVEL
+
+config TEST_FULL
+ bool "Enable Test full"
+ default y
+ depends on TEST && TEST_LEVEL
+
+config TEST_PRESSURE
+ bool "Enable Test Pressure"
+ default n
+ depends on TEST && TEST_LEVEL
+
+config TEST_LLT
+ bool "Enable Test LLT"
+ default n
+ depends on TEST && TEST_LEVEL
+
+config TEST_MUTIL
+ bool "Enable Multi Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST
+config TEST_KERNEL_BASE
+ bool "Enable Kernel Testsuit"
+ default y
+ depends on KERNEL_TEST && TEST
+config TEST_KERNEL_BASE_IPC
+ bool "Enable IPC Testsuit"
+ default y
+ depends on KERNEL_TEST && TEST_KERNEL_BASE && TEST
+config TEST_KERNEL_BASE_CORE
+ bool "Enable CORE Testsuit"
+ default y
+ depends on KERNEL_TEST && TEST_KERNEL_BASE && TEST
+config TEST_KERNEL_BASE_MP
+ bool "Enable MP Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_BASE && TEST && KERNEL_SMP
+config TEST_KERNEL_BASE_MEM
+ bool "Enable MEM Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_BASE && TEST
+config TEST_KERNEL_BASE_VM
+ bool "Enable VM Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_BASE && TEST
+config TEST_KERNEL_BASE_MISC
+ bool "Enable MISC Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_BASE && TEST
+config TEST_KERNEL_BASE_OM
+ bool "Enable OM Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_BASE && TEST
+config TEST_KERNEL_BASE_ATOMIC
+ bool "Enable ATOMIC Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_BASE && TEST
+config TEST_KERNEL_EXTEND
+ bool "Enable Extended Kernel Testsuit"
+ default y
+ depends on KERNEL_TEST && TEST
+config TEST_KERNEL_EXTEND_CPP
+ bool "Enable CPP Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_EXTEND && TEST
+config TEST_KERNEL_EXTEND_CPUP
+ bool "Enable CPUP Testsuit"
+ default y
+ depends on KERNEL_TEST && TEST_KERNEL_EXTEND && TEST
+config TEST_KERNEL_EXTEND_EXC
+ bool "Enable EXC Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_EXTEND && TEST
+config TEST_KERNEL_EXTEND_UNALIGNACCESS
+ bool "Enable UNALIGNACCESS Testsuit"
+ default n
+ depends on KERNEL_TEST && DO_ALIGN && TEST_KERNEL_EXTEND && TEST
+config TEST_KERNEL_EXTEND_MMU
+ bool "Enable MMU Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_EXTEND && TEST
+config TEST_KERNEL_EXTEND_DYNLOAD
+ bool "Enable DYNLOAD Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_EXTEND && TEST
+config TEST_KERNEL_EXTEND_MPU
+ bool "Enable MPU Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_EXTEND && TEST
+config TEST_KERNEL_EXTEND_RUNSTOP
+ bool "Enable RUNSTOP Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_EXTEND && KERNEL_RUNSTOP && TEST
+config TEST_KERNEL_EXTEND_SCATTER
+ bool "Enable SCATTER Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_EXTEND && KERNEL_SCATTER && TEST
+config TEST_KERNEL_EXTEND_TICKLESS
+ bool "Enable TICKLESS Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_EXTEND && TEST
+config TEST_KERNEL_EXTEND_TRACE
+ bool "Enable TRACE Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_KERNEL_EXTEND && TEST
+config TEST_POSIX
+ bool "Enable Posix Testsuit"
+ default y
+ depends on KERNEL_TEST && TEST
+config TEST_POSIX_MEM
+ bool "Enable Mem Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_POSIX && TEST
+config TEST_POSIX_MQUEUE
+ bool "Enable Mqueue Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_POSIX && TEST
+config TEST_POSIX_MUTEX
+ bool "Enable Mutex Testsuit"
+ default y
+ depends on KERNEL_TEST && TEST_POSIX && TEST
+config TEST_POSIX_PTHREAD
+ bool "Enable Pthread Testsuit"
+ default y
+ depends on KERNEL_TEST && TEST_POSIX && TEST
+config TEST_POSIX_SCHED
+ bool "Enable Sched Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_POSIX && TEST
+config TEST_POSIX_SEM
+ bool "Enable Sem Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_POSIX && TEST
+config TEST_POSIX_SWTMR
+ bool "Enable Swtmr Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_POSIX && TEST
+config TEST_LINUX
+ bool "Enable Linux Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST
+config TEST_LINUX_HRTIMER
+ bool "Enable Hrtimer Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_LINUX && TEST
+config TEST_FS
+ bool "Enable FS Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST
+
+config TEST_FS_VFS
+ bool "Enable VFS Test"
+ default n
+ depends on KERNEL_TEST && TEST_FS && TEST
+config TEST_FS_JFFS
+ bool "Enable JFFS Test"
+ default n
+ depends on KERNEL_TEST && TEST_FS && TEST
+config TEST_FS_RAMFS
+ bool "Enable RAMFS Test"
+ default n
+ depends on KERNEL_TEST && TEST_FS && TEST
+
+config TEST_FS_FAT
+ bool "Enable FAT Test"
+ default n
+ depends on KERNEL_TEST && TEST_FS && TEST
+config TEST_FS_FAT_FAT32
+ bool "Enable FAT32 Test"
+ default n
+ depends on KERNEL_TEST && TEST_FS_FAT && TEST
+config TEST_FAT32_FSCK
+ bool "Enable FAT32 Fsck Test"
+ default n
+ depends on KERNEL_TEST && TEST_FS_FAT && TEST
+
+config TEST_FS_VIRPART
+ bool "Enable FAT virtual partition test"
+ default n
+ depends on KERNEL_TEST && FS_FAT_VIRTUAL_PARTITION && TEST_FS && TEST
+config TEST_FS_PROC
+ bool "Enable PROC Test"
+ default n
+ depends on KERNEL_TEST && TEST_FS && TEST
+config TEST_FS_NFS
+ bool "Enable NFS Test"
+ default n
+ depends on KERNEL_TEST && TEST_FS && TEST
+config TEST_MTD
+ bool "Enable MTD Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST
+
+config TEST_MTD_JFFS
+ bool "Enable JFFS MTD Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_MTD && TEST
+
+config TEST_MTD_FAT
+ bool "Enable FAT MTD Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_MTD && !FS_FAT_VIRTUAL_PARTITION && TEST
+
+config TEST_MTD_DISK
+ bool "Enable FAT MTD DISK Test"
+ default n
+ depends on KERNEL_TEST && TEST_MTD && !FS_FAT_VIRTUAL_PARTITION && TEST
+
+config TEST_MTD_FAT_VIRPART
+ bool "Enable FAT virtual partition MTD test"
+ default n
+ depends on KERNEL_TEST && TEST_MTD && FS_FAT_VIRTUAL_PARTITION && TEST
+
+config TEST_DRIVERBASE
+ bool "Enable DriverBase Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST
+config TEST_LIBC
+ bool "Enable LIBC Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST
+config TEST_LIBM
+ bool "Enable LIBM Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST
+
+config TEST_SHELL
+ bool "Enable Shell Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST
+config TEST_USB
+ bool "Enable Usb Manual Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST && DRIVERS_USB
+ help
+
+config TEST_HOST_MASS_DEVICE
+ bool "Enable Host Mass Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && DRIVERS_USB_MASS_STORAGE && TEST
+config TEST_HOST_UVC
+ bool "Enable Host UVC Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && DRIVERS_USB_HOST_UVC && TEST
+
+config TEST_DEVICE_MASS_GADGET
+ bool "Enable Device Mass Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && DRIVERS_USB_MASS_STORAGE_GADGET && TEST
+config TEST_UVC_GADGET
+ bool "Enable UVC Gadget Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && DRIVERS_USB_UVC_GADGET && TEST
+config TEST_UAC_GADGET
+ bool "Enable UAC Gadget Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && DRIVERS_USB_UAC_GADGET && TEST
+
+config TEST_CAMERA_GADGET
+ bool "Enable Camera Gadget Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && DRIVERS_USB_CAMERA_GADGET && TEST
+config TEST_HUB_GADGET
+ bool "Enable HUB Gadget Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && TEST
+config TEST_SERIAL_GADGET
+ bool "Enable Serial Gadget Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && DRIVERS_USB_SERIAL_GADGET && TEST
+config TEST_HID_GADGET
+ bool "Enable HID Gadget Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && DRIVERS_USB_HID_GADGET && TEST
+config TEST_ETHERNET_GADGET
+ bool "Enable Ethernet Gadget Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && DRIVERS_USB_ETHERNET_GADGET && TEST
+config TEST_MULTI_GADGET
+ bool "Enable Ethernet & Serial Gadget Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && DRIVERS_USB_ETH_SER_GADGET && TEST
+config TEST_DFU_GADGET
+ bool "Enable Drivers DFU Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && DRIVERS_USB_DFU_GADGET && TEST
+config TEST_MUTILDEVICE_GADGET
+ bool "Enable Drivers Multidevices Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && TEST
+config TEST_SMP_USB
+ bool "Enable Usb SMP Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && TEST && KERNEL_SMP
+config TEST_HOST_ETH
+ bool "Enable Host Eth Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_USB && TEST
+
+config TEST_AUTO_USB
+ bool "Enable Usb Auto Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST && DRIVERS_USB
+
+config TEST_MMC
+ bool "Enable MMC Testsuit"
+ default n
+ depends on KERNEL_TEST && DRIVERS_MMC && TEST
+
+config TEST_SD
+ bool "Enable SD Testsuit"
+ default n
+ depends on KERNEL_TEST && DRIVERS_MMC && TEST_MMC && TEST
+
+config TEST_SDIO
+ bool "Enable SDIO Testsuit"
+ default n
+ depends on KERNEL_TEST && DRIVERS_MMC && TEST_MMC && TEST
+
+comment "Only one platform can be selected"
+ depends on KERNEL_TEST && DRIVERS_MMC && TEST_MMC && TEST && TEST_SDIO
+config TEST_SDIO_1131S
+ depends on KERNEL_TEST && DRIVERS_MMC && TEST_MMC && TEST && TEST_SDIO
+ bool "1131s"
+config TEST_SDIO_RTL8189
+ depends on KERNEL_TEST && DRIVERS_MMC && TEST_MMC && TEST && TEST_SDIO
+ bool "RTL8189"
+
+config TEST_PERFORMANCE
+ bool "Enable Performance Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST
+config TEST_PERFORMANCE_CORE
+ bool "Enable Performance CORE Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_PERFORMANCE && TEST
+config TEST_PERFORMANCE_MEM
+ bool "Enable Performance MEM Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_PERFORMANCE && TEST
+config TEST_PERFORMANCE_FS
+ bool "Enable Performance FS Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_PERFORMANCE && TEST
+config TEST_PERFORMANCE_USB
+ bool "Enable Performance USB Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_PERFORMANCE && TEST
+config TEST_PERFORMANCE_NET
+ bool "Enable Performance NET Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_PERFORMANCE && TEST
+
+config TEST_NET
+ bool "Enable NET Test"
+ default n
+ depends on KERNEL_TEST && TEST
+ help
+ Attention: if this option turns on, other test suits will be ignored.
+config TEST_LWIP
+ bool "Enable LWIP Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST_NET && TEST
+config AR6K3_WIFI_TEST
+ bool "Enable AR6K3_WIFI Test"
+ default n
+ depends on KERNEL_TEST && TEST && DRIVERS_WIFI_QRD
+ help
+ Attention: if this option turns on, other test suits will be ignored.
+config BCM_WIFI_TEST
+ bool "Enable BCM_WIFI Test"
+ default n
+ depends on KERNEL_TEST && TEST && DRIVERS_WIFI_BCM
+ help
+ Attention: if this option turns on, other test suits will be ignored.
+
+config TEST_PLATFORM
+ bool "Enable Platform Testsuit"
+ default n
+ depends on KERNEL_TEST && TEST
+config 3RDPARTY_TEST
+ bool "Enable 3rdParty Test"
+ default n
+ depends on KERNEL_TEST && TEST && 3RDPARTY
+ help
+ Attention: 3rdParty tools and libs test
+
+
diff --git a/testsuites/kernel/Kconfig_case b/testsuites/kernel/Kconfig_case
new file mode 100644
index 0000000000000000000000000000000000000000..45d67d478e77940b3499a5ce476e6c763921705b
--- /dev/null
+++ b/testsuites/kernel/Kconfig_case
@@ -0,0 +1,387 @@
+# 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.
+
+config LOSCFG_TEST_LEVEL
+ int "Test Level"
+ default 2
+ depends on LOSCFG_TESTSUIT_SHELL
+ help
+ Attention:
+ 0:smoke test
+ 1:llt test
+ 2:full test
+ 3:presssure test
+config LOSCFG_TEST_KERNEL_BASE
+ bool "Enable Kernel Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_BASE_IPC
+ bool "Enable IPC Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_BASE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_BASE_CORE
+ bool "Enable CORE Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_BASE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_BASE_MEM
+ bool "Enable MEM Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_BASE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_BASE_VM
+ bool "Enable VM Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_BASE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_BASE_MISC
+ bool "Enable MISC Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_BASE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_BASE_OM
+ bool "Enable OM Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_BASE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_BASE_ATOMIC
+ bool "Enable ATOMIC Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_BASE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_EXTEND
+ bool "Enable Extended Kernel Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_EXTEND_CPP
+ bool "Enable CPP Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_EXTEND && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_EXTEND_CPUP
+ bool "Enable CPUP Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_EXTEND && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_EXTEND_EXC
+ bool "Enable EXC Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_EXTEND && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_EXTEND_UNALIGNACCESS
+ bool "Enable UNALIGNACCESS Testsuit"
+ default n
+ depends on LOSCFG_DO_ALIGN && LOSCFG_TEST_KERNEL_EXTEND && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_EXTEND_MMU
+ bool "Enable MMU Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_EXTEND && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_EXTEND_DYNLOAD
+ bool "Enable DYNLOAD Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_EXTEND && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_KERNEL_EXTEND_MPU
+ bool "Enable MPU Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_EXTEND && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_KERNEL_EXTEND_TICKLESS
+ bool "Enable TICKLESS Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_EXTEND && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_KERNEL_EXTEND_TRACE
+ bool "Enable TRACE Testsuit"
+ default n
+ depends on LOSCFG_TEST_KERNEL_EXTEND && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_POSIX
+ bool "Enable Posix Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_POSIX_MEM
+ bool "Enable Mem Testsuit"
+ default n
+ depends on LOSCFG_TEST_POSIX && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_POSIX_MQUEUE
+ bool "Enable Mqueue Testsuit"
+ default n
+ depends on LOSCFG_TEST_POSIX && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_POSIX_MUTEX
+ bool "Enable Mutex Testsuit"
+ default n
+ depends on LOSCFG_TEST_POSIX && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_POSIX_PTHREAD
+ bool "Enable Pthread Testsuit"
+ default n
+ depends on LOSCFG_TEST_POSIX && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_POSIX_SCHED
+ bool "Enable Sched Testsuit"
+ default n
+ depends on LOSCFG_TEST_POSIX && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_POSIX_SEM
+ bool "Enable Sem Testsuit"
+ default n
+ depends on LOSCFG_TEST_POSIX && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_POSIX_SWTMR
+ bool "Enable Swtmr Testsuit"
+ default n
+ depends on LOSCFG_TEST_POSIX && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_LINUX
+ bool "Enable Linux Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_LINUX_HRTIMER
+ bool "Enable Hrtimer Testsuit"
+ default n
+ depends on LOSCFG_TEST_LINUX && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_FS
+ bool "Enable FS Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_FS_VFS
+ bool "Enable VFS Test"
+ default n
+ depends on LOSCFG_TEST_FS && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_FS_JFFS
+ bool "Enable JFFS Test"
+ default n
+ depends on LOSCFG_TEST_FS && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_FS_RAMFS
+ bool "Enable RAMFS Test"
+ default n
+ depends on LOSCFG_TEST_FS && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_FS_FAT
+ bool "Enable FAT Test"
+ default n
+ depends on LOSCFG_TEST_FS && !LOSCFG_FS_FAT_VIRTUAL_PARTITION && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_FS_FAT_FAT32
+ bool "Enable FAT32 Test"
+ default n
+ depends on LOSCFG_TEST_FS_FAT && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_FS_FAT_EXFAT
+ bool "Enable exFAT Test"
+ default n
+ depends on LOSCFG_TEST_FS_FAT && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_FAT32_FSCK
+ bool "Enable FAT32 Fsck Test"
+ default n
+ depends on LOSCFG_TEST_FS_FAT && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_FS_VIRPART
+ bool "Enable FAT virtual partition test"
+ default n
+ depends on LOSCFG_FS_FAT_VIRTUAL_PARTITION && LOSCFG_TEST_FS && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_FS_PROC
+ bool "Enable PROC Test"
+ default n
+ depends on LOSCFG_TEST_FS && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_FS_NFS
+ bool "Enable NFS Test"
+ default n
+ depends on LOSCFG_TEST_FS && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_MTD
+ bool "Enable MTD Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_MTD_JFFS
+ bool "Enable JFFS MTD Testsuit"
+ default n
+ depends on LOSCFG_TEST_MTD && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_MTD_FAT
+ bool "Enable FAT MTD Testsuit"
+ default n
+ depends on LOSCFG_TEST_MTD && !LOSCFG_FS_FAT_VIRTUAL_PARTITION && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_MTD_FAT_VIRPART
+ bool "Enable FAT virtual partition MTD test"
+ default n
+ depends on LOSCFG_TEST_MTD && LOSCFG_FS_FAT_VIRTUAL_PARTITION && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_DRIVERBASE
+ bool "Enable DriverBase Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_LIBC
+ bool "Enable LIBC Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_LIBM
+ bool "Enable LIBM Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_SHELL
+ bool "Enable Shell Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_USB
+ bool "Enable Usb Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL && LOSCFG_DRIVERS_USB
+ help
+
+config LOSCFG_TEST_HOST_MASS_DEVICE
+ bool "Enable Host Mass Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_DRIVERS_USB_MASS_STORAGE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_DEVICE_MASS_GADGET
+ bool "Enable Device Mass Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_DRIVERS_USB_MASS_STORAGE_GADGET && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_UVC_GADGET
+ bool "Enable UVC Gadget Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_DRIVERS_USB_UVC_GADGET && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_UAC_GADGET
+ bool "Enable UAC Gadget Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_DRIVERS_USB_UAC_GADGET && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_CAMERA_GADGET
+ bool "Enable Camera Gadget Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_DRIVERS_USB_CAMERA_GADGET && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_HUB_GADGET
+ bool "Enable HUB Gadget Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_DRIVERS_USB_MASS_STORAGE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_SERIAL_GADGET
+ bool "Enable Serial Gadget Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_DRIVERS_USB_SERIAL_GADGET && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_ETHERNET_GADGET
+ bool "Enable Ethernet Gadget Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_DRIVERS_USB_ETHERNET_GADGET && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_MULTI_GADGET
+ bool "Enable Ethernet & Serial Gadget Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_DRIVERS_USB_ETH_SER_GADGET && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_DFU_GADGET
+ bool "Enable Drivers DFU Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_MUTILDEVICE_GADGET
+ bool "Enable Drivers Multidevices Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_HOST_ETH
+ bool "Enable Host Eth Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_AUTO_USB
+ bool "Enable Usb auto Testsuit"
+ default n
+ depends on LOSCFG_TEST_USB && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_MMC
+ bool "Enable MMC Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL && LOSCFG_DRIVERS_MMC
+
+config LOSCFG_TEST_SD
+ bool "Enable SD Testsuit"
+ default n
+ depends on LOSCFG_TEST_MMC && LOSCFG_DRIVERS_MMC && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_SDIO
+ bool "Enable SDIO Testsuit"
+ default n
+ depends on LOSCFG_TEST_MMC && LOSCFG_DRIVERS_MMC && LOSCFG_TESTSUIT_SHELL
+
+comment "Only one platform can be selected"
+ depends on LOSCFG_TEST_SDIO && LOSCFG_TEST_MMC && LOSCFG_DRIVERS_MMC && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_SDIO_1131S
+ depends on LOSCFG_TEST_SDIO && LOSCFG_TEST_MMC && LOSCFG_DRIVERS_MMC && LOSCFG_TESTSUIT_SHELL
+ bool "1131s"
+config LOSCFG_TEST_SDIO_RTL8189
+ depends on LOSCFG_TEST_SDIO && LOSCFG_TEST_MMC && LOSCFG_DRIVERS_MMC && LOSCFG_TESTSUIT_SHELL
+ bool "RTL8189"
+
+config LOSCFG_TEST_PERFORMANCE
+ bool "Enable Performance Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_PERFORMANCE_CORE
+ bool "Enable Performance CORE Testsuit"
+ default n
+ depends on LOSCFG_TEST_PERFORMANCE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_PERFORMANCE_MEM
+ bool "Enable Performance MEM Testsuit"
+ default n
+ depends on LOSCFG_TEST_PERFORMANCE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_PERFORMANCE_FS
+ bool "Enable Performance FS Testsuit"
+ default n
+ depends on LOSCFG_TEST_PERFORMANCE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_PERFORMANCE_USB
+ bool "Enable Performance USB Testsuit"
+ default n
+ depends on LOSCFG_TEST_PERFORMANCE && LOSCFG_TESTSUIT_SHELL
+config LOSCFG_TEST_PERFORMANCE_NET
+ bool "Enable Performance NET Testsuit"
+ default n
+ depends on LOSCFG_TEST_PERFORMANCE && LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_PLATFORM
+ bool "Enable Platform Testsuit"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+
+config LOSCFG_TEST_NET
+ bool "Enable NET Test"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+ help
+ Attention: if this option turns on, other test suits will be ignored.
+
+config LOSCFG_TEST_LWIP
+ bool "Enable LWIP Testsuit"
+ default n
+ depends on LOSCFG_TEST_NET && LOSCFG_TESTSUIT_SHELL
+config AR6K3_WIFI_TEST
+ bool "Enable AR6K3_WIFI Test"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL && LOSCFG_DRIVERS_WIFI_QRD
+ help
+ Attention: if this option turns on, other test suits will be ignored.
+config BCM_WIFI_TEST
+ bool "Enable BCM_WIFI Test"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL && LOSCFG_DRIVERS_WIFI_BCM
+ help
+ Attention: if this option turns on, other test suits will be ignored.
+
+config LOSCFG_3RDPARTY_TEST
+ bool "Enable 3rdParty Test"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL && LOSCFG_3RDPARTY
+ help
+ Attention: 3rdParty tools and libs test
+config LOSCFG_TEST_MANUAL_SHELL
+ bool "Enable Manual Test"
+ default n
+ depends on LOSCFG_TESTSUIT_SHELL
+
diff --git a/testsuites/kernel/Makefile b/testsuites/kernel/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..c3e417a59df24f69684480fc0a038bb9af28dfde
--- /dev/null
+++ b/testsuites/kernel/Makefile
@@ -0,0 +1,48 @@
+# 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 $(LITEOSTESTTOPDIR)/config.mk
+
+MODULE_NAME := ktest
+
+LOCAL_INCLUDE := -I $(LITEOSTESTTOPDIR)/kernel/include
+
+LOCAL_SRCS := $(wildcard src/osTest.c) \
+ $(wildcard src/runstop_osTest.c) \
+ $(wildcard src/scatter_osTest.c) \
+ $(wildcard src/iCunit.c) \
+ $(wildcard src/ChipTest.c) \
+ $(wildcard src/testusb_shellcmd.c) \
+ $(wildcard src/testrun_shellcmd.c)
+
+LOCAL_FLAGS := $(LOCAL_INCLUDE) -Wno-error -I $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH)/include \
+ -I $(LITEOSTOPDIR)/fs/fat/os_adapt
+
+include $(MODULE)
diff --git a/testsuites/kernel/include/iCunit.h b/testsuites/kernel/include/iCunit.h
new file mode 100644
index 0000000000000000000000000000000000000000..a0de0031f5f0c2d1d0464035d6e7cbc3235b4ca1
--- /dev/null
+++ b/testsuites/kernel/include/iCunit.h
@@ -0,0 +1,574 @@
+/*
+ * 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 _UNI_ICUNIT_H
+#define _UNI_ICUNIT_H
+
+#include
+#include
+#include "los_typedef.h"
+#include "los_spinlock.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)
+
+#define TEST_LESSER_MEM NO
+
+
+typedef iUINT32 (*CASE_FUNCTION)(void);
+
+typedef struct {
+ const 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_VM,
+ TEST_SEM,
+ TEST_MUX,
+ TEST_RWLOCK,
+ TEST_EVENT,
+ TEST_QUE,
+ TEST_SWTMR,
+ TEST_HWI,
+ TEST_MP,
+ TEST_ATO,
+ TEST_CPUP,
+ TEST_SCATTER,
+ TEST_RUNSTOP,
+ TEST_TIMER,
+ TEST_MMU,
+ TEST_ROBIN,
+ TEST_LIBC,
+ TEST_WAIT,
+ TEST_VFAT,
+ TEST_JFFS,
+ TEST_RAMFS,
+ TEST_NFS,
+ TEST_PROC,
+ TEST_FS,
+ TEST_UART,
+ 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_UNAME,
+ TEST_ERR,
+ TEST_CMD,
+ TEST_TICKLESS,
+ TEST_TRACE,
+ TEST_UNALIGNACCESS,
+ TEST_EXC,
+ TEST_REQULATOR,
+ TEST_DEVFREQ,
+ TEST_CPUFREQ,
+ TEST_MISC,
+#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,
+ TEST_XML2,
+ TEST_ZBAR,
+ TEST_HARFBUZZ,
+#endif
+ TEST_DRIVERBASE,
+ TEST_UDP,
+ TEST_TCP,
+ TEST_MODULE_ALL,
+} LiteOS_test_module;
+
+typedef enum {
+ TEST_LOS = 0,
+ 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_NET_LWIP,
+ TEST_LAYER_ALL,
+} LiteOS_test_layer;
+
+typedef enum {
+ TEST_LEVEL0 = 0,
+ TEST_LEVEL1,
+ TEST_LEVEL2,
+ TEST_LEVEL3,
+ TEST_LEVEL4,
+ TEST_LEVEL_ALL,
+} LiteOS_test_level;
+
+typedef enum {
+ TEST_FUNCTION = 0,
+ TEST_PRESSURE,
+ TEST_PERFORMANCE,
+ TEST_TYPE_ALL,
+} LiteOS_test_type;
+
+typedef enum {
+ TEST_SEQUENCE = 0,
+ TEST_RANDOM
+} LiteOS_test_sequence;
+
+extern iUINT16 g_iCunitErrLineNo;
+extern iiUINT32 g_iCunitErrCode;
+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
+
+#if 1
+
+#define ICUNIT_TRACK_EQUAL(param, g_value, retcode) \
+ do { \
+ if ((param) != (g_value)) { \
+ ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
+ } \
+ } while (0)
+
+
+#define ICUNIT_TRACK_NOT_EQUAL(param, g_value, retcode) \
+ do { \
+ if ((param) == (g_value)) { \
+ ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_NOT_EQUAL_NULL(param, g_value, retcode) \
+ do { \
+ if ((param) == (g_value)) { \
+ ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
+ return NULL; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_EQUAL_NULL(param, g_value, retcode) \
+ do { \
+ if ((param) != (g_value)) { \
+ ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
+ return NULL; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_EQUAL_VOID(param, g_value, retcode) \
+ do { \
+ if ((param) != (g_value)) { \
+ ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
+ return; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_NOT_EQUAL_VOID(param, g_value, retcode) \
+ do { \
+ if ((param) == (g_value)) { \
+ ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
+ return; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_EQUAL(param, g_value, retcode) \
+ do { \
+ if ((param) != (g_value)) { \
+ ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
+ return 1; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_NOT_EQUAL(param, g_value, retcode) \
+ do { \
+ if ((param) == (g_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_WITHIN_EQUAL_NULL(param, value1, value2, retcode) \
+ do { \
+ if ((param) < (value1) || (param) > (value2)) { \
+ 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_EQUAL_TIME(param, g_value, retcode, label) \
+ do { \
+ if ((param) < (g_value - 1) || (param) > (g_value + 1)) { \
+ ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
+ goto label; \
+ } \
+ } 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(str1, 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, g_value, retcode, label) \
+ do { \
+ if ((param) != (g_value)) { \
+ ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
+ goto label; \
+ } \
+ } while (0)
+
+#define ICUNIT_GOTO_EQUAL_IN(param, value1, value2, retcode, label) \
+ do { \
+ if (((param) != (value1)) && ((param) != (value2))) { \
+ ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
+ goto label; \
+ } \
+ } while (0)
+
+#define ICUNIT_GOTO_NOT_EQUAL(param, g_value, retcode, label) \
+ do { \
+ if ((param) == (g_value)) { \
+ ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
+ goto label; \
+ } \
+ } while (0)
+
+#define ICUNIT_GOTO_WITHIN_EQUAL(param, value1, value2, retcode, label) \
+ do { \
+ if ((param) < (value1) || (param) > (value2)) { \
+ 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)
+
+#else
+
+#define ICUNIT_TRACK_EQUAL(param, g_value, retcode) \
+ do { \
+ if ((param) != (g_value)) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ } \
+ } while (0)
+
+#define ICUNIT_TRACK_NOT_EQUAL(param, g_value, retcode) \
+ do { \
+ if ((param) == (g_value)) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_EQUAL_VOID(param, g_value, retcode) \
+ do { \
+ if ((param) != (g_value)) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ return; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_NOT_EQUAL_VOID(param, g_value, retcode) \
+ do { \
+ if ((param) == (g_value)) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ return; \
+ } \
+ } while (0)
+#define ICUNIT_ASSERT_EQUAL(param, g_value, retcode) \
+ do { \
+ if ((param) != (g_value)) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ return 1; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_NOT_EQUAL(param, g_value, retcode) \
+ do { \
+ if ((param) == (g_value)) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ return 1; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_STRING_EQUAL(str1, str2, retcode) \
+ do { \
+ if (strcmp(str1, str2) != 0) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ return 1; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_STRING_NOT_EQUAL(str1, str2, retcode) \
+ do { \
+ if (strcmp(str1, str2) == 0) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ return 1; \
+ } \
+ } while (0)
+
+#define ICUNIT_GOTO_EQUAL(param, g_value, retcode, label) \
+ do { \
+ if ((param) != (g_value)) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ goto label; \
+ } \
+ } while (0)
+
+#define ICUNIT_GOTO_NOT_EQUAL(param, g_value, retcode, label) \
+ do { \
+ if ((param) == (g_value)) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ goto label; \
+ } \
+ } while (0)
+
+#define ICUNIT_GOTO_STRING_EQUAL(str1, str2, retcode, label) \
+ do { \
+ if (strcmp(str1, str2) != 0) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ goto label; \
+ } \
+ } while (0)
+
+#define ICUNIT_GOTO_STRING_NOT_EQUAL(str1, str2, retcode, label) \
+ do { \
+ if (strcmp(str1, str2) == 0) { \
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? __LINE__ : g_iCunitErrLineNo; \
+ g_iCunitErrCode = (g_iCunitErrCode == 0) ? (iiUINT32)retcode : g_iCunitErrCode; \
+ goto label; \
+ } \
+ } while (0)
+#endif
+
+#if (LOSCFG_KERNEL_SMP == YES)
+extern SPIN_LOCK_S g_testSuitSpin;
+#define TESTSUIT_LOCK(state) LOS_SpinLockSave(&g_testSuitSpin, &(state))
+#define TESTSUIT_UNLOCK(state) LOS_SpinUnlockRestore(&g_testSuitSpin, state)
+#endif
+
+extern iUINT32 iCunitAddSuit_F(iCHAR *suitName, iCHAR *pfileName);
+#define iCunitAddSuit(suitName) iCunitAddSuit_F(suitName, __FILE__)
+extern iUINT32 ICunitAddCase(const iCHAR *caseName, CASE_FUNCTION caseFunc, iUINT16 testcaseLayer,
+ iUINT16 testcaseModule, iUINT16 testcaseLevel, iUINT16 testcaseType);
+
+extern iUINT32 ICunitRunTestOne(const char *tcId);
+extern INT32 ICunitRunTestArray(const char *tcSequence, const char *tcNum, const char *tcLayer, const char *tcModule,
+ const char *tcLevel, const char *tcType);
+extern iUINT32 ICunitRunTestArraySequence(iUINT32 testcaseNum, iUINT32 testcaseLayer, iUINT32 testcaseModule,
+ iUINT32 testcaseLevel, iUINT32 testcaseType);
+extern iUINT32 ICunitRunTestArrayRandom(iUINT32 testcaseNum, iUINT32 testcaseLayer, iUINT32 testcaseModule,
+ iUINT32 testcaseLevel, iUINT32 testcaseType);
+extern iUINT32 ICunitRunTestcaseSatisfied(ICUNIT_CASE_S *testCase, iUINT32 testcaseLayer, iUINT32 testcaseModule,
+ iUINT32 testcaseLevel, iUINT32 testcaseType);
+
+extern iUINT32 ICunitInit(void);
+extern iUINT32 ICunitRunSingle(ICUNIT_CASE_S *psubCase);
+extern iUINT32 ICunitRunF(ICUNIT_CASE_S *psubCase);
+
+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 */
\ No newline at end of file
diff --git a/testsuites/kernel/include/iCunit.inc b/testsuites/kernel/include/iCunit.inc
new file mode 100644
index 0000000000000000000000000000000000000000..9ad1f18bc0b544c8d06db0cbdad69257a0be2003
--- /dev/null
+++ b/testsuites/kernel/include/iCunit.inc
@@ -0,0 +1,64 @@
+/*
+ * 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"
+#include "los_builddef.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+ICUNIT_CASE_S g_iCunitRandArray[1];
+ICUNIT_CASE_S g_iCunitCaseArray[ICUNIT_CASE_SIZE];
+
+iUINT32 g_iCunitInitSuccess = 0x0000FFFF;
+iUINT32 g_iCunitCaseCnt = 0xFFFF;
+iUINT32 g_iCunitCaseFailedCnt = 0;
+iUINT32 g_iCunitErrLogAddCase = 0;
+
+iUINT16 g_iCunitErrLineNo;
+iiUINT32 g_iCunitErrCode;
+
+iUINT32 g_iCunitCaseRun = 0;
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+#endif /* _UNI_ICUNIT_INC */
diff --git a/testsuites/kernel/include/iCunit_config.h b/testsuites/kernel/include/iCunit_config.h
new file mode 100644
index 0000000000000000000000000000000000000000..dc128734bedc97eaad055bf56bc64ed042a462a2
--- /dev/null
+++ b/testsuites/kernel/include/iCunit_config.h
@@ -0,0 +1,60 @@
+/*
+ * 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 "los_builddef.h"
+#ifndef _ICUNIT_CONFIG_H
+#define _ICUNIT_CONFIG_H
+
+#include "los_builddef.h"
+#include "los_config.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#if defined(LITEOS_TEST_AUTO) && !defined(LOSCFG_TEST_MUTIL)
+#define ICUNIT_CASE_SIZE LOSCFG_BASE_CORE_TSK_LIMIT
+#else
+#define ICUNIT_CASE_SIZE 20000
+#endif
+
+#define ICUNIT_SUIT_SIZE 1
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif
diff --git a/testsuites/kernel/include/los_test_pri.h b/testsuites/kernel/include/los_test_pri.h
new file mode 100644
index 0000000000000000000000000000000000000000..f6015bf2670333e7fa5bbeace325783e0b93c5d5
--- /dev/null
+++ b/testsuites/kernel/include/los_test_pri.h
@@ -0,0 +1,49 @@
+/*
+ * 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_TEST_PRI_H
+#define _LOS_TEST_PRI_H
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+extern UINT32 OsTestInit(VOID);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_TEST_PRI_H */
\ No newline at end of file
diff --git a/testsuites/kernel/include/osTest.h b/testsuites/kernel/include/osTest.h
new file mode 100644
index 0000000000000000000000000000000000000000..bdb549a5d58cac81cc13db43a891a0adad4d29bd
--- /dev/null
+++ b/testsuites/kernel/include/osTest.h
@@ -0,0 +1,374 @@
+/*
+ * 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
+
+#ifndef SWTMR_TEST
+#define SWTMR_TEST
+#endif
+
+#include "test_menuconfig.h"
+#include "stdarg.h"
+#include "los_config.h"
+#include "iCunit.h"
+#include "stdio.h"
+#include "stdlib.h"
+#include "limits.h"
+#include "string.h"
+#include "los_base.h"
+#include "los_config.h"
+#include "los_typedef.h"
+#include "los_hwi.h"
+#include "los_vm_map.h"
+#include "los_task.h"
+#include "los_sched_pri.h"
+#include "los_task_pri.h"
+#include "los_sys_pri.h"
+#include "los_sem_pri.h"
+#include "los_event.h"
+#include "los_memory.h"
+#include "los_queue.h"
+#include "los_swtmr.h"
+#include "los_mux.h"
+#include "los_queue_pri.h"
+#include "los_atomic.h"
+#if !defined(TEST1980) && !defined(TESTISP)
+#include "console.h"
+#endif
+
+#ifndef LOSCFG_AARCH64
+#ifdef LOSCFG_LIB_LIBC
+#include "time.h"
+#endif
+#include "target_config.h"
+#endif
+#include "los_process_pri.h"
+#include "pthread.h"
+
+#ifdef LOSCFG_PLATFORM_HI3516DV300
+#define TEST3516DV300
+#elif LOSCFG_PLATFORM_HI3518EV300
+#define TEST3518EV300
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define TEST_TASK_PARAM_INIT(testTask, task_name, entry, prio) \
+ do { \
+ memset(&testTask, 0, sizeof(TSK_INIT_PARAM_S)); \
+ testTask.pfnTaskEntry = (TSK_ENTRY_FUNC)entry; \
+ testTask.uwStackSize = LOS_TASK_MIN_STACK_SIZE; \
+ testTask.pcName = task_name; \
+ testTask.usTaskPrio = prio; \
+ testTask.uwResved = LOS_TASK_STATUS_DETACHED; \
+ } while (0)
+
+#if (LOSCFG_KERNEL_SMP == YES)
+#define TEST_TASK_PARAM_INIT_AFFI(testTask, task_name, entry, prio, affi) \
+ TEST_TASK_PARAM_INIT(testTask, task_name, entry, prio) \
+ testTask.usCpuAffiMask = affi;
+#else
+#define TEST_TASK_PARAM_INIT_AFFI(stTestTask, task_name, entry, prio, affi) \
+ TEST_TASK_PARAM_INIT(stTestTask, task_name, entry, prio)
+#endif
+#define JFFS_BASE_MTD_ADDR 0x100000
+#define JFFS_BASE_MTD_LEN 0x600000
+
+
+#define TASK_PRIO_TEST 25
+#define TASK_PRIO_TEST_TASK 4
+#define TASK_PRIO_TEST_SWTMR 4
+#ifdef LOSCFG_AARCH64
+#define TASK_STACK_SIZE_TEST (LOS_TASK_MIN_STACK_SIZE * 3)
+#else
+#define TASK_STACK_SIZE_TEST LOS_TASK_MIN_STACK_SIZE
+#endif
+#define LOS_MS_PER_TICK (OS_SYS_MS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND)
+
+#define HWI_NUM_INTVALID OS_HWI_MAX_NUM
+#define writel(g_value, address) WRITE_UINT32(g_value, address)
+#ifdef TESTPBXA9
+extern int vsnprintf(char *str, size_t n, const char *fmt, va_list ap);
+#endif
+
+#if defined(LOSCFG_TEST_POSIX)
+extern UINT32 PosixPthreadInit(pthread_attr_t *attr, int pri);
+extern UINT32 PosixPthreadDestroy(pthread_attr_t *attr, pthread_t thread);
+#endif
+
+extern UINT32 TaskCountGetTest(VOID);
+extern UINT32 SemCountGetTest(VOID);
+extern UINT32 QueueCountGetTest(VOID);
+extern UINT32 SwtmrCountGetTest(VOID);
+extern void hal_interrupt_set_affinity(uint32_t irq, uint32_t cpuMask);
+
+#define TASK_EXISTED_NUM (TaskCountGetTest())
+#define QUEUE_EXISTED_NUM (QueueCountGetTest())
+#define SWTMR_EXISTED_NUM (SwtmrCountGetTest())
+#define SEM_EXISTED_NUM (SemCountGetTest())
+
+extern void TestTestHwiDelete(unsigned int irq, void *devId);
+extern void TestHwiTrigger(unsigned int irq);
+extern void TestExtraTaskDelay(UINT32 tick);
+extern UINT64 TestTickCountGet(void);
+extern UINT64 TestTickCountByCurrCpuid(void);
+extern void TestBusyTaskDelay(UINT32 tick);
+extern void *malloc(size_t size);
+extern void TestDumpCpuid(void);
+extern u_long TRandom(void);
+
+#define TEST_HwiDelete(ID) TestTestHwiDelete(ID, NULL)
+#define TEST_HwiClear(ID) HalIrqMask(ID)
+#define TEST_HwiTriggerDelay LOS_TaskDelay(200 * LOSCFG_BASE_CORE_TICK_PER_SECOND / 1000)
+#define TEST_HwiCreate(ID, prio, mode, Func, arg) LOS_HwiCreate(ID, prio, mode, Func, arg)
+
+
+#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_INT19 19
+#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_INT34 34
+#define HWI_NUM_INT35 35
+#define HWI_NUM_INT42 42
+#define HWI_NUM_INT45 45
+#define HWI_NUM_INT46 46
+#define HWI_NUM_INT50 50
+#define HWI_NUM_INT55 55
+#define HWI_NUM_INT56 56
+#define HWI_NUM_INT57 57
+#define HWI_NUM_INT58 58
+#define HWI_NUM_INT59 59
+#define HWI_NUM_INT60 60
+#define HWI_NUM_INT61 61
+#define HWI_NUM_INT63 63
+#define HWI_NUM_INT62 62
+#define HWI_NUM_INT68 68
+#define HWI_NUM_INT69 69
+
+#define HWI_NUM_INT95 95
+#define HWI_NUM_INT114 114
+#define HWI_NUM_INT169 169
+
+#if defined TESTPBXA9
+#define HWI_NUM_TEST HWI_NUM_INT56
+#define HWI_NUM_TEST1 HWI_NUM_INT57
+#define HWI_NUM_TEST0 HWI_NUM_INT58
+#define HWI_NUM_TEST2 HWI_NUM_INT59
+#define HWI_NUM_TEST3 HWI_NUM_INT60
+#elif defined TEST3518EV300
+#define HWI_NUM_TEST0 HWI_NUM_INT58
+#define HWI_NUM_TEST HWI_NUM_INT59
+#define HWI_NUM_TEST1 HWI_NUM_INT60
+#define HWI_NUM_TEST2 HWI_NUM_INT61
+#define HWI_NUM_TEST3 HWI_NUM_INT68
+#elif defined TEST3516DV300
+#define HWI_NUM_TEST HWI_NUM_INT56
+#define HWI_NUM_TEST1 HWI_NUM_INT57
+#define HWI_NUM_TEST0 HWI_NUM_INT58
+#define HWI_NUM_TEST2 HWI_NUM_INT59
+#define HWI_NUM_TEST3 HWI_NUM_INT60
+#endif
+
+#define TEST_TASKDELAY_1TICK 1
+#define TEST_TASKDELAY_2TICK 2
+#define TEST_TASKDELAY_4TICK 4
+#define TEST_TASKDELAY_10TICK 10
+#define TEST_TASKDELAY_20TICK 20
+#define TEST_TASKDELAY_50TICK 50
+
+#ifdef TEST3731
+#define TestTimer2ValueGet(temp) READ_UINT32(temp, TIMER1_REG_BASE + TIMER_VALUE)
+#elif defined TEST3559
+#define TestTimer2ValueGet(temp) READ_UINT32(temp, TIMER3_REG_BASE + TIMER_VALUE)
+#else
+#define TestTimer2ValueGet(temp) READ_UINT32(temp, TIMER2_REG_BASE + TIMER_VALUE)
+#endif
+
+#define REALTIME(time) (UINT32)((UINT64)(0xffffffff - time) * 1000 / OS_SYS_CLOCK) /* accuracy:ms */
+#define HW_TMI(time) (UINT32)((UINT64)(0xffffffff - time) * 1000 / (OS_SYS_CLOCK / 1000000)) /* accuracy:ns */
+
+#define uart_printf_func dprintf
+
+#ifndef VFS_STAT_PRINTF
+#define VFS_STAT_PRINTF 0
+#endif
+
+#ifndef VFS_STATFS_PRINTF
+#define VFS_STATFS_PRINTF 0
+#endif
+
+#define OPEN_FILE_MAX 20
+
+#define HUAWEI_ENV_NFS 0
+
+#ifndef TEST_RESOURCELEAK_CHECK
+#define TEST_RESOURCELEAK_CHECK YES
+#endif
+
+#ifndef TEST_MODULE_CHECK
+#define TEST_MODULE_CHECK YES
+#endif
+
+#define OS_PROCESS_STATUS_PEND OS_PROCESS_STATUS_PENDING
+#define OS_TASK_STATUS_SUSPEND OS_TASK_STATUS_SUSPENDED
+#define OS_TASK_STATUS_PEND OS_TASK_STATUS_PENDING
+
+extern UINT32 volatile g_testCount;
+extern UINT32 g_testCount1;
+extern UINT32 g_testCount2;
+extern UINT32 g_testCount3;
+extern UINT32 g_flowcheck;
+extern UINT32 g_failResult;
+extern UINT32 g_passResult;
+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_semID;
+extern UINT32 g_semID2;
+extern LosMux g_mutexkernelTest;
+extern UINT32 g_cpupTestCount;
+extern UINT16 g_swTmrID;
+extern UINT32 g_semID;
+extern UINT32 g_testQueueID01;
+extern UINT32 g_testQueueID02;
+extern UINT32 g_testQueueID03;
+extern UINT32 g_testTskHandle;
+extern UINT32 g_leavingTaskNum;
+extern UINT32 g_semID3[];
+extern EVENT_CB_S g_eventCB;
+extern EVENT_CB_S g_event;
+extern UINT32 g_testPeriod;
+extern BOOL g_isAddArray;
+extern BOOL g_isSdInit;
+extern BOOL g_isSpinorInit;
+extern UINT32 g_getTickConsume;
+extern UINT32 g_waitTestCount;
+extern INT32 g_libFileSystem;
+extern UINT32 LosMuxCreate(LosMux *mutex);
+extern INT32 g_performanceStart;
+
+extern void msleep(unsigned int msecs);
+extern unsigned int sleep(unsigned int seconds);
+extern int usleep(unsigned useconds);
+
+#define OS_TASK_STATUS_DETACHED OS_TASK_FLAG_DETACHED
+extern UINT32 LOS_MemTotalUsedGet(VOID *pool);
+extern VOID ptestTickConsume(VOID);
+extern UINT32 TEST_TskDelete(UINT32 taskID);
+extern UINT32 TEST_SemDelete(UINT32 semHandle);
+
+extern VOID ItSuiteLosQueue(VOID);
+extern VOID ItSuiteLosSwtmr(VOID);
+extern VOID ItSuiteLosTask(VOID);
+extern VOID ItSuiteLosEvent(VOID);
+
+extern VOID ItSuiteLosMux(VOID);
+extern VOID ItSuiteLosRwlock(VOID);
+extern VOID ItSuiteLosSem(VOID);
+extern VOID ItSuiteSmpHwi(VOID);
+extern VOID ItSuiteHwiNesting(VOID);
+
+extern VOID ItSuiteExtendCpup(VOID);
+
+extern VOID ItSuitePosixMutex(VOID);
+extern VOID ItSuitePosixPthread(VOID);
+
+extern VOID TestRunShell(VOID);
+
+extern UINT32 OsTestInit(VOID);
+
+extern void TEST_DT_COMMON(void);
+extern VOID dprintf(const char *fmt, ...);
+
+#define BIG_FD 512
+typedef struct testrunParam {
+ CHAR testcase_sequence[16];
+ CHAR testcase_num[16];
+ CHAR testcase_layer[32];
+ CHAR testcase_module[32];
+ CHAR testcase_level[16];
+ CHAR testcase_type[16];
+ CHAR testcase_id[128];
+} TEST_RUN_PARAM;
+
+#define LOSCFG_BASE_CORE_TSK_CONFIG LOSCFG_BASE_CORE_TSK_LIMIT
+#define LOSCFG_BASE_IPC_SEM_CONFIG LOSCFG_BASE_IPC_SEM_LIMIT
+#define LOSCFG_BASE_IPC_QUEUE_CONFIG LOSCFG_BASE_IPC_QUEUE_LIMIT
+#define LOSCFG_BASE_CORE_SWTMR_CONFIG LOSCFG_BASE_CORE_SWTMR_LIMIT
+
+#define HAL_READ_UINT8(addr, data) READ_UINT8(data, addr)
+#define HAL_WRITE_UINT8(addr, data) WRITE_UINT8(data, addr)
+#define HAL_READ_UINT32(addr, data) READ_UINT32(data, addr)
+#define HAL_WRITE_UINT32(addr, data) WRITE_UINT32(data, addr)
+
+extern void InitRebootHook(void);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif /* _OSTEST_H */
diff --git a/testsuites/kernel/sample/kernel_base/core/BUILD.gn b/testsuites/kernel/sample/kernel_base/core/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..e441507cd9e92e1841167cd0b01034ac2689d331
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/BUILD.gn
@@ -0,0 +1,35 @@
+static_library("test_core") {
+
+ sources = [
+ "task/It_los_task.c",
+ "swtmr/It_los_swtmr.c",
+ "hwi/It_smp_hwi.c",
+ "hwi_nesting/It_hwi_nesting.c",
+ ]
+
+ if (LOSCFG_TEST_SMOKE) {
+ sources += [
+ "task/smoke/It_los_task_045.c",
+ "task/smoke/It_los_task_046.c",
+ "task/smoke/It_los_task_049.c",
+ "task/smoke/It_los_task_081.c",
+ "task/smoke/It_los_task_089.c",
+ "task/smoke/It_los_task_097.c",
+ "task/smoke/It_los_task_099.c",
+ "task/smoke/It_los_task_101.c",
+ "task/smoke/It_los_task_105.c",
+ "task/smoke/It_los_task_timeslice_001.c",
+ "swtmr/smoke/It_los_swtmr_053.c",
+ "swtmr/smoke/It_los_swtmr_058.c",
+ ]
+ }
+ include_dirs = [
+ "../../../include/",
+ "task",
+ "swtmr",
+ "hwi",
+ "hwi_nesting",
+ ]
+
+ cflags = [ "-Wno-error" ]
+}
diff --git a/testsuites/kernel/sample/kernel_base/core/Makefile b/testsuites/kernel/sample/kernel_base/core/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..aa2a22eb936f16bdc8c8ad6829608fa97ea52229
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/Makefile
@@ -0,0 +1,46 @@
+
+include $(LITEOSTESTTOPDIR)/config.mk
+
+MODULE_NAME := coretest
+
+LOCAL_INCLUDE := \
+ -I $(LITEOSTESTTOPDIR)/kernel/include \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/kernel_base/core/task \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/kernel_base/core/swtmr \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/kernel_base/core/hwi \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/kernel_base/core/hwi_nesting
+
+SRC_MODULES := task swtmr hwi hwi_nesting
+
+ifeq ($(LOSCFG_KERNEL_SMP), y)
+SMP_MODULES := task/smp swtmr/smp hwi/smp task/float
+endif
+
+ifeq ($(LOSCFG_TEST_LLT), y)
+LLT_MODULES := task/llt swtmr/llt
+endif
+
+ifeq ($(LOSCFG_TEST_PRESSURE), y)
+PRESSURE_MODULES := task/pressure swtmr/pressure
+endif
+
+ifeq ($(LOSCFG_TEST_SMOKE), y)
+SMOKE_MODULES := task/smoke swtmr/smoke
+endif
+
+ifeq ($(LOSCFG_TEST_FULL), y)
+FULL_MODULES := task/full swtmr/full hwi_nesting/full
+endif
+
+ifeq ($(LOSCFG_TEST_MANUAL_SHELL), y)
+MANUAL_MODULES :=task/manual
+endif
+
+LOCAL_MODULES := $(SRC_MODULES) $(LLT_MODULES) $(PRESSURE_MODULES) $(SMOKE_MODULES) $(FULL_MODULES) $(SMP_MODULES) $(MANUAL_MODULES)
+
+LOCAL_SRCS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.c))
+LOCAL_CHS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.h))
+
+LOCAL_FLAGS := $(LOCAL_INCLUDE) -Wno-error
+
+include $(MODULE)
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/It_smp_hwi.c b/testsuites/kernel/sample/kernel_base/core/hwi/It_smp_hwi.c
new file mode 100644
index 0000000000000000000000000000000000000000..36bea719a9fb2b31c6249a28092b04f8fa7f099f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/It_smp_hwi.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+VOID ItSuiteSmpHwi(VOID)
+{
+#if (LOSCFG_KERNEL_SMP == YES)
+ ItSmpLosHwi001();
+ ItSmpLosHwi002();
+ ItSmpLosHwi003();
+ ItSmpLosHwi004();
+ ItSmpLosHwi005();
+ ItSmpLosHwi006();
+ ItSmpLosHwi007();
+ ItSmpLosHwi008();
+ ItSmpLosHwi009();
+ ItSmpLosHwi010();
+ ItSmpLosHwi011();
+ ItSmpLosHwi012();
+ ItSmpLosHwi013();
+
+#ifndef LOSCFG_NO_SHARED_IRQ
+ ItSmpLosHwiShare001();
+ ItSmpLosHwiShare002();
+ ItSmpLosHwiShare003();
+ ItSmpLosHwiShare004();
+ ItSmpLosHwiShare005();
+ ItSmpLosHwiShare006();
+ ItSmpLosHwiShare007();
+ ItSmpLosHwiShare008();
+ ItSmpLosHwiShare009();
+ ItSmpLosHwiShare010();
+#endif
+ ItSmpLosHwiIpi001();
+ ItSmpLosHwiIpi002();
+ ItSmpLosHwiIpi003();
+ ItSmpLosHwiIpi004();
+ ItSmpLosHwiIpi005();
+
+ ItSmpLosHwiIpi006();
+ ItSmpLosHwiIpi007();
+ ItSmpLosHwiIpi008();
+
+ ItSmpLosHwiNest001();
+ ItSmpLosHwiNest002();
+ ItSmpLosHwiNest003();
+ ItSmpLosHwiNest004();
+ ItSmpLosHwiNest005();
+ ItSmpLosHwiNest006();
+ ItSmpLosHwiNest007();
+ ItSmpLosHwiNest008();
+#endif
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, 1);
+ HalIrqSetAffinity(HWI_NUM_TEST1, 1);
+ HalIrqSetAffinity(HWI_NUM_TEST2, 1);
+ HalIrqSetAffinity(HWI_NUM_TEST3, 1);
+#endif
+}
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/It_smp_hwi.h b/testsuites/kernel/sample/kernel_base/core/hwi/It_smp_hwi.h
new file mode 100644
index 0000000000000000000000000000000000000000..403a64f4d679413b3955b7878f03550ce4ab3ba3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/It_smp_hwi.h
@@ -0,0 +1,98 @@
+/*
+ * 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_SMP_HWI_H
+#define LOS_SMP_HWI_H
+
+#include "los_hwi.h"
+#include "osTest.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define LOOP 100
+
+#if defined(LOSCFG_TEST_SMP)
+VOID ItSmpLosHwi001(VOID);
+VOID ItSmpLosHwi002(VOID);
+VOID ItSmpLosHwi003(VOID);
+VOID ItSmpLosHwi004(VOID);
+VOID ItSmpLosHwi005(VOID);
+VOID ItSmpLosHwi006(VOID);
+VOID ItSmpLosHwi007(VOID);
+VOID ItSmpLosHwi008(VOID);
+VOID ItSmpLosHwi009(VOID);
+VOID ItSmpLosHwi010(VOID);
+VOID ItSmpLosHwi011(VOID);
+VOID ItSmpLosHwi012(VOID);
+VOID ItSmpLosHwi013(VOID);
+
+#ifndef LOSCFG_NO_SHARED_IRQ
+VOID ItSmpLosHwiShare001(VOID);
+VOID ItSmpLosHwiShare002(VOID);
+VOID ItSmpLosHwiShare003(VOID);
+VOID ItSmpLosHwiShare004(VOID);
+VOID ItSmpLosHwiShare005(VOID);
+VOID ItSmpLosHwiShare006(VOID);
+VOID ItSmpLosHwiShare007(VOID);
+VOID ItSmpLosHwiShare008(VOID);
+VOID ItSmpLosHwiShare009(VOID);
+VOID ItSmpLosHwiShare010(VOID);
+#endif
+
+VOID ItSmpLosHwiIpi001(VOID);
+VOID ItSmpLosHwiIpi002(VOID);
+VOID ItSmpLosHwiIpi003(VOID);
+VOID ItSmpLosHwiIpi004(VOID);
+VOID ItSmpLosHwiIpi005(VOID);
+VOID ItSmpLosHwiIpi006(VOID);
+VOID ItSmpLosHwiIpi007(VOID);
+VOID ItSmpLosHwiIpi008(VOID);
+
+VOID ItSmpLosHwiNest001(VOID);
+VOID ItSmpLosHwiNest002(VOID);
+VOID ItSmpLosHwiNest003(VOID);
+VOID ItSmpLosHwiNest004(VOID);
+VOID ItSmpLosHwiNest005(VOID);
+VOID ItSmpLosHwiNest006(VOID);
+VOID ItSmpLosHwiNest007(VOID);
+VOID ItSmpLosHwiNest008(VOID);
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#endif /* LOS_SMP_HWI_H */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_001.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..aa82373600f8b086fe82d9bc9633958b73617f7e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_001.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_testTimes;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(void)
+{
+#ifdef TEST1980
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi001(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi001", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_002.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..06fde6006cb3ce7971daa4d04990f422c9df9516
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_002.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(void)
+{
+#ifdef TEST1980
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(0));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid, currCpuid;
+
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_002_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi002(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi002", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_003.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..f0b422da21a902d76841bbcfcd952338cfb74516
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_003.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_testTimes;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ TestDumpCpuid();
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+#ifndef LOSCFG_NO_SHARED_IRQ
+ ICUNIT_ASSERT_EQUAL_VOID(ret, OS_ERRNO_HWI_SHARED_ERROR, ret);
+#else
+ ICUNIT_ASSERT_EQUAL_VOID(ret, OS_ERRNO_HWI_ALREADY_CREATED, ret);
+#endif
+
+ return;
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+#ifdef TEST1980
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi003(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi003", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_004.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..ed8093620382f986fc2f84575a3009a205fb92f6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_004.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_testTimes;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ TestDumpCpuid();
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+#ifndef LOSCFG_NO_SHARED_IRQ
+ ICUNIT_ASSERT_EQUAL_VOID(ret, OS_ERRNO_HWI_SHARED_ERROR, ret);
+#else
+ ICUNIT_ASSERT_EQUAL_VOID(ret, OS_ERRNO_HWI_ALREADY_CREATED, ret);
+#endif
+
+ return;
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid, currCpuid;
+
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TestDumpCpuid();
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_002_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+#ifdef TEST1980
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi004(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi004", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_005.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..2a408e2756833d09cc34da9c29a9d05565caedb7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_005.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ TestDumpCpuid();
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+#ifdef TEST1980
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi005(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi005", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_006.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..221678df111230bd10b07d81a378e189c856e72f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_006.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 "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#if (LOSCFG_KERNEL_SMP == YES)
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ TestDumpCpuid();
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid, currCpuid;
+
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TestDumpCpuid();
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_002_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+
+#ifdef TEST1980
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi006(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi006", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_007.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..a63b39b04492604bb97d2c2882feba616b66585f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_007.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+
+ return;
+}
+
+static VOID TaskF02(void)
+{
+ UINT32 ret;
+#ifdef TEST1980
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestDumpCpuid();
+ return;
+}
+
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(testTask, "it_hwi_007_task01", TaskF01, TASK_PRIO_TEST + 1);
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ TEST_TASK_PARAM_INIT(testTask, "it_hwi_007_task02", TaskF02, TASK_PRIO_TEST + 1);
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi007(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi007", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_008.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..b26f6adfebc5801137bc48e64cb321e304e8cbbb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_008.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 "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+
+static UINT32 g_ret = 0;
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ g_ret |= ret;
+ TestDumpCpuid();
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, i, j;
+
+ for (j = 0; j < LOOP; j++) {
+ g_testCount = 0;
+ g_ret = 0;
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_007_task01", TaskF01, TASK_PRIO_TEST + 1,
+ CPUID_TO_AFFI_MASK(i));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+ LOS_TaskDelay(1);
+
+#ifdef TEST1980
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ ICUNIT_GOTO_NOT_EQUAL(g_ret, 0, g_ret, EXIT);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ }
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi008(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi008", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_009.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..22bb709ff6a9031988b2a996049b3c6bdab89a62
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_009.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+
+static UINT32 g_ret = 0;
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ g_ret |= ret;
+ TestDumpCpuid();
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, i, j;
+
+ for (j = 0; j < LOOP; j++) {
+ g_testCount = 0;
+ g_ret = 0;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_007_task01", TaskF01, TASK_PRIO_TEST + 1,
+ CPUID_TO_AFFI_MASK(i));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(2); // 2, set delay time
+
+#ifdef TEST1980
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ }
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi009(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi009", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_010.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..b28b2f42c94ec1e161319921f11c8c6a0327c2c2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_010.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_szId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+static VOID HwiF01(void)
+{
+ UINT32 ret;
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_szId[0], 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ TestDumpCpuid();
+ return;
+}
+static VOID HwiF02(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_szId[1], 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret, i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST1, 1, 0, (HWI_PROC_FUNC)HwiF02, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST1, CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM)); // other cpu
+
+ for (i = 0; i < LOOP; i++) {
+#ifndef TEST1980
+ TestHwiTrigger(HWI_NUM_TEST1);
+ TestHwiTrigger(HWI_NUM_TEST);
+#else
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM), HWI_NUM_TEST1);
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK(ArchCurrCpuid()), HWI_NUM_TEST);
+#endif
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ ret = LOS_SwtmrDelete(g_szId[0]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ret = LOS_SwtmrDelete(g_szId[1]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_HwiDelete(HWI_NUM_TEST1, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_szId[0]);
+ LOS_SwtmrDelete(g_szId[1]);
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST1, NULL);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi010(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi010", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_011.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..b9ee190b7ad800b62971409368b201e22436d3e0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_011.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_szId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+static VOID HwiF01(void)
+{
+ UINT32 ret;
+ TEST_HwiClear(HWI_NUM_TEST);
+ ret = LOS_SwtmrStart(g_szId[0]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestDumpCpuid();
+ return;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST1, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST2, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST3, NULL);
+ LOS_SwtmrDelete(g_szId[0]);
+ LOS_SwtmrDelete(g_szId[1]);
+ return;
+}
+static VOID HwiF02(void)
+{
+ UINT32 ret;
+ TEST_HwiClear(HWI_NUM_TEST1);
+ ret = LOS_SwtmrStart(g_szId[1]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestDumpCpuid();
+ return;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST1, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST2, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST3, NULL);
+ LOS_SwtmrDelete(g_szId[0]);
+ LOS_SwtmrDelete(g_szId[1]);
+ return;
+}
+static VOID HwiF03(void)
+{
+ UINT32 ret;
+ TEST_HwiClear(HWI_NUM_TEST2);
+ ret = LOS_SwtmrStop(g_szId[1]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestDumpCpuid();
+ return;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST1, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST2, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST3, NULL);
+ LOS_SwtmrDelete(g_szId[0]);
+ LOS_SwtmrDelete(g_szId[1]);
+ return;
+}
+static VOID HwiF04(void)
+{
+ UINT32 ret;
+ TEST_HwiClear(HWI_NUM_TEST3);
+ ret = LOS_SwtmrStop(g_szId[0]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestDumpCpuid();
+ return;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST1, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST2, NULL);
+ LOS_HwiDelete(HWI_NUM_TEST3, NULL);
+ LOS_SwtmrDelete(g_szId[0]);
+ LOS_SwtmrDelete(g_szId[1]);
+ return;
+}
+static UINT32 Testcase(void)
+{
+ UINT32 ret, i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_szId[0], 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_szId[1], 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST1, 1, 0, (HWI_PROC_FUNC)HwiF02, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST1, CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM)); // other cpu
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST2, 1, 0, (HWI_PROC_FUNC)HwiF03, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST2, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST3, 1, 0, (HWI_PROC_FUNC)HwiF04, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST3, CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM)); // other cpu
+
+ for (i = 0; i < LOOP; i++) {
+#ifndef TEST1980
+ TestHwiTrigger(HWI_NUM_TEST1); // start swtmrs
+ TestHwiTrigger(HWI_NUM_TEST);
+#else
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM), HWI_NUM_TEST1);
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK(ArchCurrCpuid()), HWI_NUM_TEST);
+#endif
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2 * (i + 1), g_testCount, EXIT); // 2 * (i + 1),Compared to the expected value.
+#ifndef TEST1980
+ TestHwiTrigger(HWI_NUM_TEST3); // stop swtmrs
+ TestHwiTrigger(HWI_NUM_TEST2);
+#else
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM), HWI_NUM_TEST3);
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK(ArchCurrCpuid()), HWI_NUM_TEST2);
+#endif
+ LOS_TaskDelay(g_testPeriod + 1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2 * (i + 1), g_testCount, EXIT); // 2 * (i + 1),Compared to the expected value.
+ }
+EXIT:
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ret = LOS_HwiDelete(HWI_NUM_TEST1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ret = LOS_HwiDelete(HWI_NUM_TEST2, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ret = LOS_HwiDelete(HWI_NUM_TEST3, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(g_szId[0]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ret = LOS_SwtmrDelete(g_szId[1]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi011(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi011", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_012.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..4d6ba350c2200d3642a3fd076e03bf86e0d156ec
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_012.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_szId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+static VOID HwiF01(void)
+{
+ UINT32 ret;
+ ret = LOS_SwtmrDelete(g_szId[0]);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ TestDumpCpuid();
+ return;
+}
+static VOID HwiF02(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrDelete(g_szId[1]);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret, i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST1, 1, 0, (HWI_PROC_FUNC)HwiF02, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST1, CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM)); // other cpu
+
+ for (i = 0; i < LOOP; i++) {
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_szId[0], 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_szId[1], 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_SwtmrStart(g_szId[0]);
+ LOS_SwtmrStart(g_szId[1]);
+
+#ifndef TEST1980
+ TestHwiTrigger(HWI_NUM_TEST1);
+ TestHwiTrigger(HWI_NUM_TEST);
+#else
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM), HWI_NUM_TEST1);
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK(ArchCurrCpuid()), HWI_NUM_TEST);
+#endif
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ }
+
+EXIT:
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ret = LOS_HwiDelete(HWI_NUM_TEST1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(g_szId[0]);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+ ret = LOS_SwtmrDelete(g_szId[1]);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi012(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi012", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_013.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..7c3a571e34ef7f0a237ebd7d533e2c2b13fcdd52
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_013.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+static VOID HwiF01(void)
+{
+ UINT32 ret, i;
+ for (i = 0; i < TRandom() % 100; i++) { // Get a random number between 0 and 100
+ }
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret, i, j;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM)); // other cpu
+
+ for (i = 0; i < LOOP; i++) {
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestHwiTrigger(HWI_NUM_TEST); // delete swtmr in hwi on other cpu
+
+ for (j = 0; j < TRandom() % 500; j++) { // Get a random number between 0 and 500
+ LOS_SwtmrStart(g_swTmrID); // start swtmr in task on current cpu
+ }
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ }
+
+EXIT:
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwi013(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwi013", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_001.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..820e3858906a4dcfec3eef0968b18f4261ec7cb7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_001.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ ICUNIT_GOTO_EQUAL(ArchCurrCpuid(), g_targetCpuid, ArchCurrCpuid(), EXIT);
+ return;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return;
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+
+ g_targetCpuid = 0;
+
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ g_targetCpuid = ArchCurrCpuid(); // currernt cpu
+
+ PRINT_DEBUG("g_targetCpuid = %d\n", g_targetCpuid);
+
+ LOS_TaskDelay(1);
+
+ HalIrqSendIpi(g_targetCpuid + 1, HWI_NUM_INT11); // 01:0kernel,10:1kernel,11:0kernel& 1kernel
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiIpi001(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiIpi001", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_002.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..a19ad70c7209643c3e93ddf2885b1c2f41bb863c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_002.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 "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ ICUNIT_ASSERT_EQUAL_VOID(ArchCurrCpuid(), g_targetCpuid, ArchCurrCpuid());
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+
+ g_targetCpuid = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ g_targetCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM; // other cpu
+
+ PRINT_DEBUG("g_targetCpuid = %d\n", g_targetCpuid);
+
+ LOS_TaskDelay(1);
+
+ HalIrqSendIpi(g_targetCpuid + 1, HWI_NUM_INT11);
+
+ LOS_TaskDelay(1);
+
+ TEST_HwiDelete(HWI_NUM_INT11);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiIpi002(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiIpi002", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_003.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..180b5065709182e1b068f3f58048043c2a6c1efa
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_003.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ ICUNIT_ASSERT_EQUAL_VOID(ArchCurrCpuid(), g_targetCpuid, ArchCurrCpuid());
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ PRINT_DEBUG("g_targetCpuid = %d\n", g_targetCpuid);
+
+ HalIrqSendIpi(g_targetCpuid + 1, HWI_NUM_INT11);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid, currCpuid;
+ UINT32 i;
+
+ g_testCount = 0;
+
+ g_targetCpuid = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ g_targetCpuid = currCpuid; // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1, CPUID_TO_AFFI_MASK(currCpuid));
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiIpi003(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiIpi003", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_004.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..a37d3108e11419b912b15a57915629adcdf4adda
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_004.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ ICUNIT_ASSERT_EQUAL_VOID(ArchCurrCpuid(), g_targetCpuid, ArchCurrCpuid());
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ PRINT_DEBUG("g_targetCpuid = %d\n", g_targetCpuid);
+
+ HalIrqSendIpi(g_targetCpuid + 1, HWI_NUM_INT11);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid, currCpuid;
+ UINT32 i;
+
+ g_testCount = 0;
+
+ g_targetCpuid = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); // other cpu
+
+ g_targetCpuid = ArchCurrCpuid();
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1, CPUID_TO_AFFI_MASK(currCpuid));
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiIpi004(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiIpi004", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_005.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..663e37e425d812432e59810b291920ccb4249c16
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_005.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return;
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+
+ g_targetCpuid = 0;
+
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ g_targetCpuid = (1 << LOSCFG_KERNEL_CORE_NUM) - 1; // all cpu
+
+ PRINT_DEBUG("g_targetCpuid = %d\n", g_targetCpuid);
+
+ LOS_TaskDelay(1);
+
+ HalIrqSendIpi(g_targetCpuid, HWI_NUM_INT11);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiIpi005(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiIpi005", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_006.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..d7f2a75ba687dc2ae08a183854a0273642700b1f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_006.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static UINT32 g_szId[LOSCFG_KERNEL_CORE_NUM] = {0};
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+static VOID HwiF01(void)
+{
+ UINT32 ret, index;
+ index = ArchCurrCpuid();
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_szId[index], 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+
+ return;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return;
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i, j;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+ g_targetCpuid = 0;
+
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ g_targetCpuid = (1 << LOSCFG_KERNEL_CORE_NUM) - 1; // all cpu
+
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(1);
+
+ for (j = 0; j < LOOP; j++) {
+ HalIrqSendIpi(g_targetCpuid, HWI_NUM_INT11);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM * (j + 1), g_testCount, EXIT);
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_SwtmrDelete(g_szId[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+ }
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_SwtmrDelete(g_szId[i]);
+ }
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiIpi006(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiIpi006", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_007.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..3597112f2c97ae5435998ae0517194ff526e4044
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_007.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+/* for debugging */
+STATIC UINT32 g_ipiTriggerTimes = 0;
+STATIC UINT32 g_ipiRecieveTimes[LOSCFG_KERNEL_CORE_NUM] = { 0 };
+
+static UINT32 g_szId[LOSCFG_KERNEL_CORE_NUM] = {0};
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+static VOID HwiF01(void)
+{
+ UINT32 ret, index;
+ index = ArchCurrCpuid();
+ g_ipiRecieveTimes[index]++;
+ ret = LOS_SwtmrDelete(g_szId[index]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+
+ return;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return;
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i, j;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+ g_targetCpuid = 0;
+
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ g_targetCpuid = (1 << LOSCFG_KERNEL_CORE_NUM) - 1; // all cpu
+
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+ LOS_TaskDelay(1);
+
+ for (j = 0; j < LOOP; j++) {
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_szId[i], 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ g_ipiTriggerTimes++;
+ HalIrqSendIpi(g_targetCpuid, HWI_NUM_INT11);
+
+ LOS_TaskDelay(1);
+ PRINTK("sent %u time\n", g_ipiTriggerTimes);
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ PRINTK(" cpu%d recieved %u times\n", i, g_ipiRecieveTimes[i]);
+ }
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM * (j + 1), g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_SwtmrDelete(g_szId[i]);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+ }
+ }
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ PRINT_DEBUG("---%d---\n", g_szId[i]);
+ LOS_SwtmrDelete(g_szId[i]);
+ }
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiIpi007(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiIpi007", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_008.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..eb62101404fa7818daccef6132ec175f91104772
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_ipi_008.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicDec(&g_testCount);
+}
+static VOID HwiF01(void)
+{
+ UINT32 ret, id;
+
+ id = ArchCurrCpuid() % 3; // 3, Get the current CPU
+ switch (id) {
+ case 0:
+ LOS_SwtmrStart(g_swTmrID);
+ break;
+ case 1:
+ LOS_SwtmrDelete(g_swTmrID);
+ break;
+ case 2: // 2, when id is 2
+ LOS_SwtmrStop(g_swTmrID);
+ break;
+ default:
+ break;
+ }
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+ g_targetCpuid = 0;
+
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+ g_targetCpuid = (1 << LOSCFG_KERNEL_CORE_NUM) - 1; // all cpu
+
+ LOS_TaskDelay(1);
+ for (i = 0; i < LOOP; i++) {
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSendIpi(g_targetCpuid, HWI_NUM_INT11);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM * (i + 1), g_testCount, EXIT);
+ LOS_SwtmrDelete(g_swTmrID);
+ }
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiIpi008(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiIpi008", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_001.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..4d863e6818bccfaf7a3525667f4bcc6ae9825a9a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_001.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF02(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static VOID HwiF01(void)
+{
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT12);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+ g_targetCpuid = 0;
+
+ HalIrqUnmask(HWI_NUM_INT12);
+ ret = LOS_HwiCreate(HWI_NUM_INT12, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); // ipi
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF02, 0); // spi
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ g_targetCpuid = ArchCurrCpuid();
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK(g_targetCpuid), HWI_NUM_INT12); // currernt cpu;
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2,The expected value
+
+ TEST_HwiDelete(HWI_NUM_INT12);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT12);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiNest001(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiNest001", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_002.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..6e334c56f9bf2b0d2000b8d7f913531d42dd29ed
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_002.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+extern EVENT_CB_S g_event;
+static VOID HwiF02(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static VOID HwiF01(void)
+{
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT12);
+ LOS_EventWrite(&g_event, 0x1 << (ArchCurrCpuid()));
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+ g_targetCpuid = 0;
+ LOS_EventInit(&g_event);
+
+ HalIrqUnmask(HWI_NUM_INT12);
+ ret = LOS_HwiCreate(HWI_NUM_INT12, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); // ipi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF02, 0); // spi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+ ret = LOS_EventRead(&g_event, (0x1 << LOSCFG_KERNEL_CORE_NUM) - 1, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, (0x1 << LOSCFG_KERNEL_CORE_NUM) - 1, ret, EXIT);
+
+ g_targetCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM; // other cpu
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK(g_targetCpuid), HWI_NUM_INT12);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2,The expected value
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT12);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_EventDestroy(&g_event);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiNest002(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiNest002", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_003.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..8be106ddbf5cd41764f7128fd4e2652a848fba46
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_003.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF02(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static VOID HwiF01(void)
+{
+ TestHwiTrigger(HWI_NUM_TEST1);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+ g_targetCpuid = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); // spi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST1, 1, 0, (HWI_PROC_FUNC)HwiF02, 0); // spi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST1, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2,The expected value
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+ TEST_HwiDelete(HWI_NUM_TEST1);
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ TEST_HwiDelete(HWI_NUM_TEST1);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiNest003(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiNest003", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_004.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..ef9720b0ff818c68baab84b7f856d1ce359254a7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_004.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF02(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static VOID HwiF01(void)
+{
+#ifndef TEST1980
+ TestHwiTrigger(HWI_NUM_TEST1);
+#else
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM), HWI_NUM_TEST1);
+#endif
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+ g_targetCpuid = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); // spi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST1, 1, 0, (HWI_PROC_FUNC)HwiF02, 0); // spi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST1, CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM)); // other cpu
+
+#ifndef TEST1980
+ TestHwiTrigger(HWI_NUM_TEST);
+#else
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK(ArchCurrCpuid()), HWI_NUM_TEST);
+#endif
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2,The expected value
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+ TEST_HwiDelete(HWI_NUM_TEST1);
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ TEST_HwiDelete(HWI_NUM_TEST1);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiNest004(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiNest004", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_005.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..ce7aa34d475b9e3091b8f8972e45811742687816
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_005.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF02(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static VOID HwiF01(void)
+{
+ HalIrqSendIpi(g_targetCpuid + 1, HWI_NUM_INT12);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+ HalIrqUnmask(HWI_NUM_INT12);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+ g_targetCpuid = 0;
+
+ HalIrqUnmask(HWI_NUM_INT11);
+ HalIrqUnmask(HWI_NUM_INT12);
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); // ipi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_INT12, 1, 0, (HWI_PROC_FUNC)HwiF02, 0); // ipi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ g_targetCpuid = ArchCurrCpuid(); // current cpu
+ HalIrqSendIpi(g_targetCpuid + 1, HWI_NUM_INT11);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2,The expected value
+
+ TEST_HwiDelete(HWI_NUM_INT11);
+ TEST_HwiDelete(HWI_NUM_INT12);
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ TEST_HwiDelete(HWI_NUM_INT12);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiNest005(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiNest005", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_006.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..f06786b3675f12008d10c444aa17c145b4a1b5c6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_006.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF02(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static VOID HwiF01(void)
+{
+ HalIrqSendIpi(((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM) + 1, HWI_NUM_INT12);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+ HalIrqUnmask(HWI_NUM_INT12);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+ g_targetCpuid = 0;
+
+ HalIrqUnmask(HWI_NUM_INT11);
+ HalIrqUnmask(HWI_NUM_INT12);
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); // ipi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_INT12, 1, 0, (HWI_PROC_FUNC)HwiF02, 0); // ipi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ g_targetCpuid = ArchCurrCpuid(); // current cpu
+ HalIrqSendIpi(g_targetCpuid + 1, HWI_NUM_INT11);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2,The expected value
+
+ TEST_HwiDelete(HWI_NUM_INT11);
+ TEST_HwiDelete(HWI_NUM_INT12);
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ TEST_HwiDelete(HWI_NUM_INT12);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiNest006(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiNest006", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_007.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..609c22754d9c4cd1df5dfd1f49b141c27337ecc2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_007.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF02(void)
+{
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK(g_targetCpuid), HWI_NUM_INT11); // currernt cpu;
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static VOID HwiF01(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+ g_targetCpuid = 0;
+
+ HalIrqUnmask(HWI_NUM_INT11);
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); // ipi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST1, 1, 0, (HWI_PROC_FUNC)HwiF02, 0); // spi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST1, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ g_targetCpuid = ArchCurrCpuid();
+ TestHwiTrigger(HWI_NUM_TEST1);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2,The expected value
+
+ TEST_HwiDelete(HWI_NUM_INT11);
+ TEST_HwiDelete(HWI_NUM_TEST1);
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ TEST_HwiDelete(HWI_NUM_TEST1);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiNest007(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiNest007", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_008.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..9d6a4ef6f7814bb7d8164cddc0b2acc20673f776
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_nest_008.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static VOID HwiF02(void)
+{
+ HalIrqSendIpi(CPUID_TO_AFFI_MASK((g_targetCpuid + 1) % LOSCFG_KERNEL_CORE_NUM), HWI_NUM_INT11); // other cpu;
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // 10, Timeout interval of a periodic software timer.
+ g_targetCpuid = 0;
+
+ HalIrqUnmask(HWI_NUM_INT11);
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); // ipi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST1, 1, 0, (HWI_PROC_FUNC)HwiF02, 0); // spi
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST1, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ g_targetCpuid = ArchCurrCpuid();
+ TestHwiTrigger(HWI_NUM_TEST1);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2,The expected value
+
+ TEST_HwiDelete(HWI_NUM_INT11);
+ TEST_HwiDelete(HWI_NUM_TEST1);
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_INT11);
+ TEST_HwiDelete(HWI_NUM_TEST1);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiNest008(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiNest008", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_001.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..9df37ec187aeb26bd7663b74e6cff4934af84f1d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_001.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#ifndef LOSCFG_NO_SHARED_IRQ
+
+static HwiIrqParam g_dev1, g_dev2;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID HwiF02(void)
+{
+ LOS_AtomicAdd(&g_testCount, 0xff);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_dev2.pDevId = (void *)2; // 2, Set device ID
+ g_dev2.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF02, &g_dev2); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+
+ g_testCount = 0;
+
+ g_dev1.pDevId = (void *)1;
+ g_dev1.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &g_dev1); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0x100, g_testCount, EXIT);
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiShare001(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiShare001", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_002.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..9abdf86a0759234fbb3b07c91191acd9bfb069f8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_002.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#ifndef LOSCFG_NO_SHARED_IRQ
+
+static HwiIrqParam g_dev1, g_dev2;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID HwiF02(void)
+{
+ LOS_AtomicAdd(&g_testCount, 0xff);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_dev2.pDevId = (void *)2; // 2, Set device ID
+ g_dev2.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF02, &g_dev2); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid, currCpuid;
+
+ g_testCount = 0;
+
+ g_dev1.pDevId = (void *)1;
+ g_dev1.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &g_dev1); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TestDumpCpuid();
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_002_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0x100, g_testCount, EXIT);
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiShare002(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiShare002", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_003.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..08e6e9b9cbaac2f8fdcbde70451ab4a6fd123504
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_003.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#ifndef LOSCFG_NO_SHARED_IRQ
+
+static HwiIrqParam g_dev1, g_dev2;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID HwiF02(void)
+{
+ LOS_AtomicAdd(&g_testCount, 0xff);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ TestDumpCpuid();
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+
+ g_testCount = 0;
+
+ g_dev1.pDevId = (void *)1;
+ g_dev1.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &g_dev1); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ g_dev2.pDevId = (void *)2; // 2, Set device ID
+ g_dev2.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF02, &g_dev2); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0x100, g_testCount, EXIT);
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiShare003(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiShare003", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_004.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..933c46ab75736e0028be910f965beb50842f8779
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_004.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#ifndef LOSCFG_NO_SHARED_IRQ
+
+static HwiIrqParam g_dev1, g_dev2;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID HwiF02(void)
+{
+ LOS_AtomicAdd(&g_testCount, 0xff);
+}
+
+static VOID TaskF01(void)
+{
+ TestDumpCpuid();
+ TestHwiTrigger(HWI_NUM_TEST);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid, currCpuid;
+
+ g_testCount = 0;
+
+ g_dev1.pDevId = (void *)1;
+ g_dev1.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &g_dev1); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ g_dev2.pDevId = (void *)2; // 2, Set device ID
+ g_dev2.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF02, &g_dev2); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TestDumpCpuid();
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_002_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0x100, g_testCount, EXIT);
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiShare004(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiShare004", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_005.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..1be98fbd5b399e8e7c3ad44d639d0ce2c1d3b1ea
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_005.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#ifndef LOSCFG_NO_SHARED_IRQ
+
+static HwiIrqParam g_dev1, g_dev2;
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID HwiF02(void)
+{
+ LOS_AtomicAdd(&g_testCount, 0xff);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ TestDumpCpuid();
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ g_testCount = 0;
+ g_dev1.pDevId = (void *)1;
+ g_dev1.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &g_dev1); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ g_dev2.pDevId = (void *)2; // 2, Set device ID
+ g_dev2.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF02, &g_dev2); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0xff, g_testCount, EXIT);
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiShare005(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiShare005", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_006.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..29d3815718afae7d50698b37f7d439dc1376cdec
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_006.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#ifndef LOSCFG_NO_SHARED_IRQ
+
+static HwiIrqParam g_dev1, g_dev2;
+extern EVENT_CB_S g_event;
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID HwiF02(void)
+{
+ LOS_AtomicAdd(&g_testCount, 0xff);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_EventWrite(&g_event, 0x1);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid, currCpuid;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ g_dev1.pDevId = (void *)1;
+ g_dev1.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &g_dev1); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ g_dev2.pDevId = (void *)2; // 2, Set device ID
+ g_dev2.swIrq = HWI_NUM_TEST;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF02, &g_dev2); // 3, Set the interrupt priority
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TestDumpCpuid();
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_002_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventRead(&g_event, 0x1, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x1, ret, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0xff, g_testCount, EXIT);
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ LOS_EventDestroy(&g_event);
+ return LOS_OK;
+EXIT:
+ LOS_EventDestroy(&g_event);
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiShare006(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiShare006", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_007.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..adfa111c51cd3d19646b44e9ed92ec61b9907758
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_007.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+extern EVENT_CB_S g_event;
+#ifndef LOSCFG_NO_SHARED_IRQ
+
+static HwiIrqParam g_dev[LOSCFG_KERNEL_CORE_NUM];
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF02(VOID)
+{
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_EventWrite(&g_event, 0x1 << LOSCFG_KERNEL_CORE_NUM);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(UINTPTR devIndex)
+{
+ UINT32 ret;
+ // 3, Set the interrupt priority
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &(g_dev[devIndex]));
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_EventWrite(&g_event, 0x1 << devIndex);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid, currCpuid;
+ UINT32 i;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ g_dev[i].pDevId = (void *)(i + 1);
+ g_dev[i].swIrq = HWI_NUM_TEST;
+ }
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT(testTask, "it_hwi_share_task", TaskF01,
+ TASK_PRIO_TEST + 1); // not set cpuaffi
+ testTask.auwArgs[0] = i;
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ ret = LOS_EventRead(&g_event, (0x1 << LOSCFG_KERNEL_CORE_NUM) - 1, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, (0x1 << LOSCFG_KERNEL_CORE_NUM) - 1, ret, EXIT);
+
+ TEST_TASK_PARAM_INIT(testTask, "it_hwi_share_task", TaskF02,
+ TASK_PRIO_TEST + 1); // not set cpuaffi
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventRead(&g_event, (0x1 << (LOSCFG_KERNEL_CORE_NUM + 1)) - 1, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, (0x1 << (LOSCFG_KERNEL_CORE_NUM + 1)) - 1, ret, EXIT);
+
+ LOS_TaskDelay(2); // 2, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_HwiDelete(HWI_NUM_TEST, &(g_dev[i]));
+ }
+ LOS_EventDestroy(&g_event);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiShare007(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiShare007", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_008.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..1a75078ce29fbb3da62d7db9a3cae48643a20159
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_008.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 "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#ifndef LOSCFG_NO_SHARED_IRQ
+
+static UINT32 g_ret = 0;
+static HwiIrqParam g_dev;
+
+static VOID HwiF01(void)
+{
+ TEST_HwiClear(HWI_NUM_TEST);
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01()
+{
+ UINT32 ret;
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &g_dev); // 3, Set the interrupt priority
+ g_ret |= ret;
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i, j;
+
+ g_dev.pDevId = (void *)(1);
+ g_dev.swIrq = HWI_NUM_TEST;
+
+ for (j = 0; j < LOOP; j++) {
+ g_testCount = 0;
+ g_ret = 0;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_share_task", TaskF01, TASK_PRIO_TEST + 1,
+ CPUID_TO_AFFI_MASK(i));
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(1);
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_NOT_EQUAL(g_ret, 0, g_ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev);
+ }
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev);
+ return LOS_OK;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiShare008(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiShare008", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_009.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..45a72747a8b5b1bc124d4f87c9ea7c24a901e9b8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_009.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#ifndef LOSCFG_NO_SHARED_IRQ
+
+static HwiIrqParam g_dev;
+static UINT32 g_ret = 0;
+
+static VOID HwiF01(void)
+{
+ TEST_HwiClear(HWI_NUM_TEST);
+ LOS_AtomicInc(&g_testCount);
+}
+
+
+static VOID TaskF01()
+{
+ UINT32 ret;
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev);
+ g_ret |= ret;
+ TestDumpCpuid();
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i, j;
+
+ g_dev.pDevId = (void *)(1);
+ g_dev.swIrq = HWI_NUM_TEST;
+
+ for (j = 0; j < LOOP; j++) {
+ g_testCount = 0;
+ g_ret = 0;
+ // 3, Set the interrupt priority
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &g_dev);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_share_task", TaskF01, TASK_PRIO_TEST + 1,
+ CPUID_TO_AFFI_MASK(i));
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(1);
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_NOT_EQUAL(g_ret, 0, g_ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev);
+ }
+ return LOS_OK;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, &g_dev);
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiShare009(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiShare009", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_010.c b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..9b84a33ad9e190f2393a573dc53960dbe13ea13e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi/smp/It_smp_los_hwi_share_010.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_smp_hwi.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#ifndef LOSCFG_NO_SHARED_IRQ
+
+static HwiIrqParam g_dev[3]; // 3, Three devices
+
+static VOID HwiF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01()
+{
+ UINT32 ret, index, i;
+ index = ArchCurrCpuid();
+ switch (index) {
+ case 0:
+ for (i = 0; i < LOOP; i++) {
+ // 3, Set the interrupt priority
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &(g_dev[0]));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_HwiDelete(HWI_NUM_TEST, &(g_dev[0]));
+ TestDumpCpuid();
+ }
+ break;
+ case 1:
+ for (i = 0; i < LOOP; i++) {
+ // 3, Set the interrupt priority
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &(g_dev[1]));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_HwiDelete(HWI_NUM_TEST, &(g_dev[1]));
+ TestDumpCpuid();
+ }
+ break;
+ case 2: // 2, when CPU id is
+ for (i = 0; i < LOOP; i++) {
+ // 3, Set the interrupt priority; 2, index
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &(g_dev[2]));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_HwiDelete(HWI_NUM_TEST, &(g_dev[2])); // 2, index
+ TestDumpCpuid();
+ }
+ break;
+ default:
+ TestDumpCpuid();
+ break;
+ }
+
+ return;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, &(g_dev[0]));
+ LOS_HwiDelete(HWI_NUM_TEST, &(g_dev[1]));
+ LOS_HwiDelete(HWI_NUM_TEST, &(g_dev[2])); // 2, index
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid, currCpuid;
+ UINT32 i;
+
+ g_testCount = 0;
+
+ for (i = 0; i < 3; i++) { // 3, max index
+ g_dev[i].pDevId = (void *)(i + 1);
+ g_dev[i].swIrq = HWI_NUM_TEST;
+ }
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_share_task", TaskF01, TASK_PRIO_TEST + 1, CPUID_TO_AFFI_MASK(i));
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(100); // 100, set delay time
+
+ for (i = 0; i < 3; i++) { // 3, max index
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &(g_dev[i]));
+ PRINT_DEBUG("ret = 0x%x\n", ret);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+ }
+ return LOS_OK;
+}
+
+VOID ItSmpLosHwiShare010(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosHwiShare010", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi_nesting/It_hwi_nesting.c b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/It_hwi_nesting.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d0d43ab1f40710ccfe6f9cca2dd4b4e022ca066
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/It_hwi_nesting.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_hwi_nesting.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define RECORD_SIZE 100
+
+UINT32 g_intrTrace[RECORD_SIZE];
+UINT32 g_traceIdx = 0;
+UINT32 g_intrHandleEnd = 0;
+
+VOID RecordIntrTrace(INT32 irq, INT32 direction)
+{
+ g_intrTrace[g_traceIdx++] = irq | (direction << 31); // 31, Bit shift mark.
+}
+
+VOID ResetIntrTrace(VOID)
+{
+ g_traceIdx = 0;
+ memset(g_intrTrace, 0, RECORD_SIZE);
+}
+
+UINT32 CheckIntrTrace(UINT32 *expect, UINT32 num)
+{
+ UINT32 ret = LOS_OK;
+ INT32 idx = 0;
+
+ if ((expect == NULL) || (num > RECORD_SIZE)) {
+ return LOS_NOK;
+ }
+
+ for (; idx < g_traceIdx; idx++) {
+ if (expect[idx] != g_intrTrace[idx]) {
+ ret = LOS_NOK;
+ break;
+ }
+ }
+
+ if (ret == LOS_NOK) {
+ for (idx = 0; idx < g_traceIdx; idx++) {
+ dprintf("%u ", g_intrTrace[idx]);
+ }
+ }
+ dprintf("\n");
+
+ return ret;
+}
+
+VOID ItSuiteHwiNesting(VOID)
+{
+#if defined(LOSCFG_TEST_FULL)
+#ifdef LOSCFG_ARCH_INTERRUPT_PREEMPTION
+ ItLosHwiNest001();
+ ItLosHwiNest002();
+ ItLosHwiNest003();
+ ItLosHwiNest004();
+ ItLosHwiNest005();
+ ItLosHwiNest006();
+ ItLosHwiNest007();
+#endif
+#endif
+}
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi_nesting/It_hwi_nesting.h b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/It_hwi_nesting.h
new file mode 100644
index 0000000000000000000000000000000000000000..5dc1bf18624f90e6458b17f620f0f7209072e60f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/It_hwi_nesting.h
@@ -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.
+ */
+
+#include "osTest.h"
+#include "los_hwi.h"
+#include "gic_common.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define HIGHT_PRIO_INTR 100
+#define MIDDLE_PRIO_INTR 101
+#define LOW_PRIO_INTR 102
+
+#define SPI_HIGHT_PRIO 0
+#define SPI_MIDDLE_PRIO ((GIC_MAX_INTERRUPT_PREEMPTION_LEVEL - 2) << PRIORITY_SHIFT)
+#define SPI_LOW_PRIO MIN_INTERRUPT_PRIORITY
+
+#define INTR_ENTRY 0
+#define INTR_EXIT 1
+
+extern UINT32 g_intrHandleEnd;
+VOID RecordIntrTrace(INT32 irq, INT32 direction);
+VOID ResetIntrTrace(VOID);
+UINT32 CheckIntrTrace(UINT32 *expect, UINT32 num);
+VOID ItLosHwiNest001(VOID);
+VOID ItLosHwiNest002(VOID);
+VOID ItLosHwiNest003(VOID);
+VOID ItLosHwiNest004(VOID);
+VOID ItLosHwiNest005(VOID);
+VOID ItLosHwiNest006(VOID);
+VOID ItLosHwiNest007(VOID);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_001.c b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d8d20f9c4555b7f347b69dad60633dcbeb3a4d0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_001.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_hwi_nesting.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+#ifdef LOSCFG_ARCH_INTERRUPT_PREEMPTION
+static HwiIrqParam g_nestingPara;
+
+/* low in -> middle in -> hight in -> hight out -> middle out -> low out */
+static UINT32 g_expect[] = {
+ LOW_PRIO_INTR, MIDDLE_PRIO_INTR, HIGHT_PRIO_INTR,
+ 0x80000000 | HIGHT_PRIO_INTR,
+ 0x80000000 | MIDDLE_PRIO_INTR,
+ 0x80000000 | LOW_PRIO_INTR
+};
+
+static VOID NestingPrioLow(INT32 irq, VOID *data)
+{
+ volatile UINT64 nestingDelay = 10000000; // 10000000, The loop frequency.
+
+ RecordIntrTrace(LOW_PRIO_INTR, INTR_ENTRY);
+
+ HalIrqPending(MIDDLE_PRIO_INTR); /* pending middle prio interrupt */
+ while (nestingDelay-- > 0) {
+ }
+
+ RecordIntrTrace(LOW_PRIO_INTR, INTR_EXIT);
+
+ g_intrHandleEnd = 1;
+}
+
+static VOID NestingPrioMiddle(INT32 irq, VOID *data)
+{
+ volatile UINT64 nestingDelay = 10000000; // 10000000, The loop frequency.
+
+ RecordIntrTrace(MIDDLE_PRIO_INTR, INTR_ENTRY);
+
+ HalIrqPending(HIGHT_PRIO_INTR); /* pending hight prio interrupt */
+ while (nestingDelay-- > 0) {
+ }
+
+ RecordIntrTrace(MIDDLE_PRIO_INTR, INTR_EXIT);
+}
+
+static VOID NestingPrioHigh(INT32 irq, VOID *data)
+{
+ RecordIntrTrace(HIGHT_PRIO_INTR, INTR_ENTRY);
+ RecordIntrTrace(HIGHT_PRIO_INTR, INTR_EXIT);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ LOS_HwiCreate(HIGHT_PRIO_INTR, SPI_HIGHT_PRIO, 0, (HWI_PROC_FUNC)NestingPrioHigh, &g_nestingPara);
+ LOS_HwiCreate(MIDDLE_PRIO_INTR, SPI_MIDDLE_PRIO, 0, (HWI_PROC_FUNC)NestingPrioMiddle, &g_nestingPara);
+ LOS_HwiCreate(LOW_PRIO_INTR, SPI_LOW_PRIO, 0, (HWI_PROC_FUNC)NestingPrioLow, &g_nestingPara);
+ HalIrqUnmask(HIGHT_PRIO_INTR);
+ HalIrqUnmask(MIDDLE_PRIO_INTR);
+ HalIrqUnmask(LOW_PRIO_INTR);
+
+ HalIrqPending(LOW_PRIO_INTR);
+
+ while (g_intrHandleEnd == 0) {
+ LOS_TaskDelay(10); // 10, set delay time.
+ }
+
+ ret = CheckIntrTrace(g_expect, sizeof(g_expect));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_HwiDelete(HIGHT_PRIO_INTR, &g_nestingPara);
+ LOS_HwiDelete(MIDDLE_PRIO_INTR, &g_nestingPara);
+ LOS_HwiDelete(LOW_PRIO_INTR, &g_nestingPara);
+ HalIrqMask(HIGHT_PRIO_INTR);
+ HalIrqMask(MIDDLE_PRIO_INTR);
+ HalIrqMask(LOW_PRIO_INTR);
+ g_intrHandleEnd = 0;
+ ResetIntrTrace();
+
+ return LOS_OK;
+}
+
+VOID ItLosHwiNest001(VOID)
+{
+ TEST_ADD_CASE("ItLosHwiNest001", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_002.c b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..63f30c998c72a6ea52ce03a7b6608d1ac64e857d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_002.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_hwi_nesting.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+#ifdef LOSCFG_ARCH_INTERRUPT_PREEMPTION
+static HwiIrqParam g_nestingPara;
+
+/* middle in -> middle out -> low in -> hight in -> hight out -> low out */
+static UINT32 g_expect[] = {
+ MIDDLE_PRIO_INTR,
+ 0x80000000 | MIDDLE_PRIO_INTR,
+ LOW_PRIO_INTR,
+ HIGHT_PRIO_INTR,
+ 0x80000000 | HIGHT_PRIO_INTR,
+ 0x80000000 | LOW_PRIO_INTR
+};
+
+static VOID NestingPrioLow(INT32 irq, VOID *data)
+{
+ volatile UINT64 nestingDelay = 10000000; // 10000000, The loop frequency.
+
+ RecordIntrTrace(LOW_PRIO_INTR, INTR_ENTRY);
+
+ HalIrqPending(HIGHT_PRIO_INTR); /* pending hight prio interrupt */
+ while (nestingDelay-- > 0);
+
+ RecordIntrTrace(LOW_PRIO_INTR, INTR_EXIT);
+
+ g_intrHandleEnd = 1;
+}
+
+static VOID NestingPrioMiddle(INT32 irq, VOID *data)
+{
+ volatile UINT64 nestingDelay = 10000000; // 10000000, The loop frequency.
+
+ RecordIntrTrace(MIDDLE_PRIO_INTR, INTR_ENTRY);
+
+ HalIrqPending(LOW_PRIO_INTR); /* pending low prio interrupt */
+ while (nestingDelay-- > 0);
+
+ RecordIntrTrace(MIDDLE_PRIO_INTR, INTR_EXIT);
+}
+
+static VOID NestingPrioHigh(INT32 irq, VOID *data)
+{
+ RecordIntrTrace(HIGHT_PRIO_INTR, INTR_ENTRY);
+ RecordIntrTrace(HIGHT_PRIO_INTR, INTR_EXIT);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ LOS_HwiCreate(HIGHT_PRIO_INTR, SPI_HIGHT_PRIO, 0, (HWI_PROC_FUNC)NestingPrioHigh, &g_nestingPara);
+ LOS_HwiCreate(MIDDLE_PRIO_INTR, SPI_MIDDLE_PRIO, 0, (HWI_PROC_FUNC)NestingPrioMiddle, &g_nestingPara);
+ LOS_HwiCreate(LOW_PRIO_INTR, SPI_LOW_PRIO, 0, (HWI_PROC_FUNC)NestingPrioLow, &g_nestingPara);
+ HalIrqUnmask(HIGHT_PRIO_INTR);
+ HalIrqUnmask(MIDDLE_PRIO_INTR);
+ HalIrqUnmask(LOW_PRIO_INTR);
+
+ HalIrqPending(MIDDLE_PRIO_INTR); /* pending middle prio interrupt */
+
+ while (g_intrHandleEnd == 0) {
+ LOS_TaskDelay(10); // 10, set delay time.
+ }
+
+ ret = CheckIntrTrace(g_expect, sizeof(g_expect));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_HwiDelete(HIGHT_PRIO_INTR, &g_nestingPara);
+ LOS_HwiDelete(MIDDLE_PRIO_INTR, &g_nestingPara);
+ LOS_HwiDelete(LOW_PRIO_INTR, &g_nestingPara);
+ HalIrqMask(HIGHT_PRIO_INTR);
+ HalIrqMask(MIDDLE_PRIO_INTR);
+ HalIrqMask(LOW_PRIO_INTR);
+ g_intrHandleEnd = 0;
+ ResetIntrTrace();
+
+ return LOS_OK;
+}
+
+
+VOID ItLosHwiNest002(VOID)
+{
+ TEST_ADD_CASE("ItLosHwiNest002", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_003.c b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..c81b5114161a85302c1fa64453f58cba315f4be4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_003.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_hwi_nesting.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+#ifdef LOSCFG_ARCH_INTERRUPT_PREEMPTION
+static HwiIrqParam g_nestingPara;
+
+/* hight in -> hight out -> middle in -> middle out -> low in -> low out */
+static UINT32 g_expect[] = {
+ HIGHT_PRIO_INTR,
+ 0x80000000 | HIGHT_PRIO_INTR,
+ MIDDLE_PRIO_INTR,
+ 0x80000000 | MIDDLE_PRIO_INTR,
+ LOW_PRIO_INTR,
+ 0x80000000 | LOW_PRIO_INTR
+};
+
+static VOID NestingPrioLow(INT32 irq, VOID *data)
+{
+ RecordIntrTrace(LOW_PRIO_INTR, INTR_ENTRY);
+ RecordIntrTrace(LOW_PRIO_INTR, INTR_EXIT);
+
+ g_intrHandleEnd = 1;
+}
+
+static VOID NestingPrioMiddle(INT32 irq, VOID *data)
+{
+ volatile UINT64 nestingDelay = 10000000; // 10000000, The loop frequency.
+
+ RecordIntrTrace(MIDDLE_PRIO_INTR, INTR_ENTRY);
+
+ HalIrqPending(LOW_PRIO_INTR); /* pending low prio interrupt */
+ while (nestingDelay-- > 0) {
+ }
+
+ RecordIntrTrace(MIDDLE_PRIO_INTR, INTR_EXIT);
+}
+
+static VOID NestingPrioHigh(INT32 irq, VOID *data)
+{
+ volatile UINT64 nestingDelay = 10000000; // 10000000, The loop frequency.
+
+ RecordIntrTrace(HIGHT_PRIO_INTR, INTR_ENTRY);
+
+ HalIrqPending(MIDDLE_PRIO_INTR); /* pending middle prio interrupt */
+ while (nestingDelay-- > 0) {
+ }
+
+ RecordIntrTrace(HIGHT_PRIO_INTR, INTR_EXIT);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ LOS_HwiCreate(HIGHT_PRIO_INTR, SPI_HIGHT_PRIO, 0, (HWI_PROC_FUNC)NestingPrioHigh, &g_nestingPara);
+ LOS_HwiCreate(MIDDLE_PRIO_INTR, SPI_MIDDLE_PRIO, 0, (HWI_PROC_FUNC)NestingPrioMiddle, &g_nestingPara);
+ LOS_HwiCreate(LOW_PRIO_INTR, SPI_LOW_PRIO, 0, (HWI_PROC_FUNC)NestingPrioLow, &g_nestingPara);
+ HalIrqUnmask(HIGHT_PRIO_INTR);
+ HalIrqUnmask(MIDDLE_PRIO_INTR);
+ HalIrqUnmask(LOW_PRIO_INTR);
+
+ HalIrqPending(HIGHT_PRIO_INTR); /* pending hight prio interrupt */
+
+ while (g_intrHandleEnd == 0) {
+ LOS_TaskDelay(10); // 10, set delay time.
+ }
+
+ ret = CheckIntrTrace(g_expect, sizeof(g_expect));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_HwiDelete(HIGHT_PRIO_INTR, &g_nestingPara);
+ LOS_HwiDelete(MIDDLE_PRIO_INTR, &g_nestingPara);
+ LOS_HwiDelete(LOW_PRIO_INTR, &g_nestingPara);
+ HalIrqMask(HIGHT_PRIO_INTR);
+ HalIrqMask(MIDDLE_PRIO_INTR);
+ HalIrqMask(LOW_PRIO_INTR);
+ g_intrHandleEnd = 0;
+ ResetIntrTrace();
+
+ return LOS_OK;
+}
+
+VOID ItLosHwiNest003(VOID)
+{
+ TEST_ADD_CASE("ItLosHwiNest003", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_004.c b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..d1179084f8ade19c1f3905c405d3cd498230ea74
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_004.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_hwi_nesting.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+#ifdef LOSCFG_ARCH_INTERRUPT_PREEMPTION
+static HwiIrqParam g_nestingPara;
+
+/* middle in -> middle out -> low in -> low out -> hight in -> hight out */
+static UINT32 g_expect[] = {
+ MIDDLE_PRIO_INTR,
+ 0x80000000 | MIDDLE_PRIO_INTR,
+ LOW_PRIO_INTR,
+ 0x80000000 | LOW_PRIO_INTR,
+ HIGHT_PRIO_INTR,
+ 0x80000000 | HIGHT_PRIO_INTR
+};
+
+static VOID NestingPrioLow(INT32 irq, VOID *data)
+{
+ volatile UINT64 nestingDelay = 10000000; // 10000000, The loop frequency.
+
+ RecordIntrTrace(LOW_PRIO_INTR, INTR_ENTRY);
+
+ HalIrqPending(HIGHT_PRIO_INTR); /* pending hight prio interrupt */
+ while (nestingDelay-- > 0);
+
+ RecordIntrTrace(LOW_PRIO_INTR, INTR_EXIT);
+
+ g_intrHandleEnd = 1;
+}
+
+static VOID NestingPrioMiddle(INT32 irq, VOID *data)
+{
+ volatile UINT64 nestingDelay = 10000000; // 10000000, The loop frequency.
+
+ RecordIntrTrace(MIDDLE_PRIO_INTR, INTR_ENTRY);
+
+ HalIrqPending(LOW_PRIO_INTR); /* pending low prio interrupt */
+ while (nestingDelay-- > 0);
+
+ RecordIntrTrace(MIDDLE_PRIO_INTR, INTR_EXIT);
+}
+
+static VOID NestingPrioHigh(INT32 irq, VOID *data)
+{
+ RecordIntrTrace(HIGHT_PRIO_INTR, INTR_ENTRY);
+ RecordIntrTrace(HIGHT_PRIO_INTR, INTR_EXIT);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ LOS_HwiCreate(HIGHT_PRIO_INTR, SPI_MIDDLE_PRIO, 0, (HWI_PROC_FUNC)NestingPrioHigh, &g_nestingPara);
+ LOS_HwiCreate(MIDDLE_PRIO_INTR, SPI_MIDDLE_PRIO, 0, (HWI_PROC_FUNC)NestingPrioMiddle, &g_nestingPara);
+ LOS_HwiCreate(LOW_PRIO_INTR, SPI_MIDDLE_PRIO, 0, (HWI_PROC_FUNC)NestingPrioLow, &g_nestingPara);
+ HalIrqUnmask(HIGHT_PRIO_INTR);
+ HalIrqUnmask(MIDDLE_PRIO_INTR);
+ HalIrqUnmask(LOW_PRIO_INTR);
+
+ HalIrqPending(MIDDLE_PRIO_INTR); /* pending middle prio interrupt */
+
+ while (g_intrHandleEnd == 0) {
+ LOS_TaskDelay(10); // 10, set delay time.
+ }
+
+ ret = CheckIntrTrace(g_expect, sizeof(g_expect));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_HwiDelete(HIGHT_PRIO_INTR, &g_nestingPara);
+ LOS_HwiDelete(MIDDLE_PRIO_INTR, &g_nestingPara);
+ LOS_HwiDelete(LOW_PRIO_INTR, &g_nestingPara);
+ HalIrqMask(HIGHT_PRIO_INTR);
+ HalIrqMask(MIDDLE_PRIO_INTR);
+ HalIrqMask(LOW_PRIO_INTR);
+ g_intrHandleEnd = 0;
+ ResetIntrTrace();
+
+ return LOS_OK;
+}
+
+
+VOID ItLosHwiNest004(VOID)
+{
+ TEST_ADD_CASE("ItLosHwiNest004", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_005.c b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..83744b40dbab894c5b41a5fae1856cf49c6802a0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_005.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_hwi_nesting.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+#ifdef LOSCFG_ARCH_INTERRUPT_PREEMPTION
+static HwiIrqParam g_nestingPara;
+
+/* low in -> middle in -> hight in -> hight out -> middle out -> low out */
+/* loop trigger */
+static UINT32 g_expect[] = {
+ LOW_PRIO_INTR, MIDDLE_PRIO_INTR, HIGHT_PRIO_INTR,
+ 0x80000000 | HIGHT_PRIO_INTR,
+ 0x80000000 | MIDDLE_PRIO_INTR,
+ 0x80000000 | LOW_PRIO_INTR,
+ LOW_PRIO_INTR, MIDDLE_PRIO_INTR, HIGHT_PRIO_INTR,
+ 0x80000000 | HIGHT_PRIO_INTR,
+ 0x80000000 | MIDDLE_PRIO_INTR,
+ 0x80000000 | LOW_PRIO_INTR,
+ LOW_PRIO_INTR, MIDDLE_PRIO_INTR, HIGHT_PRIO_INTR,
+ 0x80000000 | HIGHT_PRIO_INTR,
+ 0x80000000 | MIDDLE_PRIO_INTR,
+ 0x80000000 | LOW_PRIO_INTR,
+ LOW_PRIO_INTR,
+ 0x80000000 | LOW_PRIO_INTR,
+};
+
+static VOID NestingPrioLow(INT32 irq, VOID *data)
+{
+ volatile UINT64 nestingDelay = 10000000; // 10000000, The loop frequency.
+
+ RecordIntrTrace(LOW_PRIO_INTR, INTR_ENTRY);
+
+ if (g_intrHandleEnd < 3) { // 3, Interrupt callback function count.
+ HalIrqPending(MIDDLE_PRIO_INTR); /* pending middle prio interrupt */
+ }
+ while (nestingDelay-- > 0) {
+ }
+
+ RecordIntrTrace(LOW_PRIO_INTR, INTR_EXIT);
+
+ g_intrHandleEnd++;
+}
+
+static VOID NestingPrioMiddle(INT32 irq, VOID *data)
+{
+ volatile UINT64 nestingDelay = 10000000; // 10000000, The loop frequency.
+
+ RecordIntrTrace(MIDDLE_PRIO_INTR, INTR_ENTRY);
+
+ HalIrqPending(HIGHT_PRIO_INTR); /* pending hight prio interrupt */
+ while (nestingDelay-- > 0) {
+ }
+
+ RecordIntrTrace(MIDDLE_PRIO_INTR, INTR_EXIT);
+}
+
+static VOID NestingPrioHigh(INT32 irq, VOID *data)
+{
+ RecordIntrTrace(HIGHT_PRIO_INTR, INTR_ENTRY);
+
+ HalIrqPending(LOW_PRIO_INTR);
+
+ RecordIntrTrace(HIGHT_PRIO_INTR, INTR_EXIT);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ LOS_HwiCreate(HIGHT_PRIO_INTR, SPI_HIGHT_PRIO, 0, (HWI_PROC_FUNC)NestingPrioHigh, &g_nestingPara);
+ LOS_HwiCreate(MIDDLE_PRIO_INTR, SPI_MIDDLE_PRIO, 0, (HWI_PROC_FUNC)NestingPrioMiddle, &g_nestingPara);
+ LOS_HwiCreate(LOW_PRIO_INTR, SPI_LOW_PRIO, 0, (HWI_PROC_FUNC)NestingPrioLow, &g_nestingPara);
+ HalIrqUnmask(HIGHT_PRIO_INTR);
+ HalIrqUnmask(MIDDLE_PRIO_INTR);
+ HalIrqUnmask(LOW_PRIO_INTR);
+
+ HalIrqPending(LOW_PRIO_INTR);
+
+ while (g_intrHandleEnd == 0) {
+ LOS_TaskDelay(10); // 10, set delay time.
+ }
+
+ ret = CheckIntrTrace(g_expect, sizeof(g_expect));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_HwiDelete(HIGHT_PRIO_INTR, &g_nestingPara);
+ LOS_HwiDelete(MIDDLE_PRIO_INTR, &g_nestingPara);
+ LOS_HwiDelete(LOW_PRIO_INTR, &g_nestingPara);
+ HalIrqMask(HIGHT_PRIO_INTR);
+ HalIrqMask(MIDDLE_PRIO_INTR);
+ HalIrqMask(LOW_PRIO_INTR);
+ g_intrHandleEnd = 0;
+ ResetIntrTrace();
+
+ return LOS_OK;
+}
+
+VOID ItLosHwiNest005(VOID)
+{
+ TEST_ADD_CASE("ItLosHwiNest005", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_006.c b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..58be6103da6a01f6e63fc7c103386440bbcf9b62
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_006.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_hwi_nesting.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+#ifdef LOSCFG_ARCH_INTERRUPT_PREEMPTION
+static HwiIrqParam g_nestingPara;
+
+static VOID NestingPrioHigh(INT32 irq, VOID *data)
+{
+ g_intrHandleEnd = 1;
+ UINT32 temp[0x100][2] = {0};
+ memset(temp, 1, sizeof(UINT32) * 0x100 * 2); // 2, buffer size.
+}
+
+static VOID TaskF01(VOID)
+{
+ HalIrqUnmask(HIGHT_PRIO_INTR);
+ HalIrqPending(HIGHT_PRIO_INTR);
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, taskID;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ // 4, Task priority calculation.
+ TEST_TASK_PARAM_INIT(task1, "ItLosHwiNest010", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST - 4);
+ task1.uwStackSize = 0x2000;
+ LOS_HwiCreate(HIGHT_PRIO_INTR, SPI_HIGHT_PRIO, 0, (HWI_PROC_FUNC)NestingPrioHigh, &g_nestingPara);
+ HalIrqUnmask(HIGHT_PRIO_INTR);
+
+ ret = LOS_TaskCreate(&taskID, &task1);
+
+ while (g_intrHandleEnd == 0) {
+ LOS_TaskDelay(10); // 10, set delay time.
+ }
+
+ ICUNIT_GOTO_EQUAL(g_intrHandleEnd, 1, g_intrHandleEnd, EXIT);
+
+EXIT:
+ LOS_HwiDelete(HIGHT_PRIO_INTR, &g_nestingPara);
+ HalIrqMask(HIGHT_PRIO_INTR);
+ g_intrHandleEnd = 0;
+
+ return LOS_OK;
+}
+
+
+VOID ItLosHwiNest006(VOID)
+{
+ TEST_ADD_CASE("ItLosHwiNest006", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_007.c b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..43bf4cf921666a435a5f43b95a476ef664d8e7ee
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/hwi_nesting/full/It_los_hwi_nesting_007.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_hwi_nesting.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+#ifdef LOSCFG_ARCH_INTERRUPT_PREEMPTION
+
+#define MAX_RECORD_SIZE 1000
+static HwiIrqParam g_nestingPara;
+static INT32 g_saveIndex = 0;
+static UINT64 g_intPendTime;
+static UINT64 g_recordTime[MAX_RECORD_SIZE] = {0};
+static VOID NestingPrioHigh(INT32 irq, VOID *data)
+{
+ UINT64 curTime;
+ curTime = LOS_CurrNanosec();
+ g_recordTime[g_saveIndex] = curTime - g_intPendTime;
+ if (g_saveIndex == MAX_RECORD_SIZE) {
+ g_saveIndex = 0;
+ }
+ dprintf("curTime = %lld, pendTime = %lld \n", curTime, g_intPendTime);
+ dprintf("%lld\n", curTime - g_intPendTime);
+ dprintf("[swtmr] hwi response time : ##%lld \n", g_recordTime[g_saveIndex]);
+ g_saveIndex++;
+}
+
+static VOID DumpResult()
+{
+ UINT32 i, count;
+ UINT64 avg, sum;
+ sum = 0;
+ count = 0;
+ for (i = 0; i < MAX_RECORD_SIZE; i++) {
+ if (g_recordTime[i] != 0) {
+ dprintf("%lld ");
+ sum += g_recordTime[i];
+ count++;
+ }
+ }
+
+ avg = sum / count;
+ dprintf("***hwi perf test dump***: \n");
+ dprintf("avg = %lld \n");
+}
+
+static VOID SwtmrF01(VOID)
+{
+ g_intPendTime = LOS_CurrNanosec();
+ HalIrqPending(HIGHT_PRIO_INTR);
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, swtmrId;
+
+ LOS_HwiCreate(HIGHT_PRIO_INTR, SPI_HIGHT_PRIO, 0, (HWI_PROC_FUNC)NestingPrioHigh, &g_nestingPara);
+ HalIrqUnmask(HIGHT_PRIO_INTR);
+
+ // 10, Timing duration of the software timer to be created.
+ ret = LOS_SwtmrCreate(10, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swtmrId,
+ 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_SwtmrStart(swtmrId);
+
+ /* EXIT time control */
+ LOS_TaskDelay(100); // 100, set delay time.
+
+ LOS_SwtmrStop(swtmrId);
+ DumpResult();
+
+EXIT:
+ LOS_SwtmrDelete(swtmrId);
+ LOS_HwiDelete(HIGHT_PRIO_INTR, &g_nestingPara);
+ HalIrqMask(HIGHT_PRIO_INTR);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosHwiNest007(VOID)
+{
+ TEST_ADD_CASE("ItLosHwiNest007", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/It_los_swtmr.c b/testsuites/kernel/sample/kernel_base/core/swtmr/It_los_swtmr.c
new file mode 100644
index 0000000000000000000000000000000000000000..7ad82c517460fe2bf16d645612def64aa353dc18
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/It_los_swtmr.c
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+EVENT_CB_S g_eventCB1, g_eventCB2, g_eventCB3;
+
+VOID ItSuiteLosSwtmr(VOID)
+{
+ int ret = LOS_SetProcessScheduler(LOS_GetCurrProcessID(), LOS_SCHED_RR, TASK_PRIO_TEST_SWTMR);
+ if (ret != LOS_OK) {
+ dprintf("%s set test process schedule failed! %d\n", ret);
+ }
+ ret = LOS_SetTaskScheduler(LOS_CurTaskIDGet(), LOS_SCHED_RR, TASK_PRIO_TEST_SWTMR);
+ if (ret != LOS_OK) {
+ dprintf("%s set test task schedule failed! %d\n", ret);
+ }
+#if defined(LOSCFG_TEST_SMOKE)
+ ItLosSwtmr053();
+ ItLosSwtmr058();
+#endif
+#if (LOSCFG_KERNEL_SMP == YES)
+ ItSmpLosSwtmr001(); /* Concurrent Multi-core */
+ ItSmpLosSwtmr002(); /* Stop Across Cores */
+ ItSmpLosSwtmr003();
+ ItSmpLosSwtmr004();
+ ItSmpLosSwtmr005();
+ ItSmpLosSwtmr006();
+ ItSmpLosSwtmr007();
+ ItSmpLosSwtmr008();
+ ItSmpLosSwtmr009();
+ ItSmpLosSwtmr010();
+ ItSmpLosSwtmr011();
+ ItSmpLosSwtmr012();
+ ItSmpLosSwtmr013();
+ ItSmpLosSwtmr014();
+ ItSmpLosSwtmr015();
+ ItSmpLosSwtmr016();
+ ItSmpLosSwtmr017();
+ ItSmpLosSwtmr018();
+ ItSmpLosSwtmr019();
+ ItSmpLosSwtmr020();
+ ItSmpLosSwtmr021();
+ ItSmpLosSwtmr022();
+ ItSmpLosSwtmr023();
+ ItSmpLosSwtmr024();
+ ItSmpLosSwtmr025();
+ ItSmpLosSwtmr026();
+ ItSmpLosSwtmr027();
+ ItSmpLosSwtmr028();
+ ItSmpLosSwtmr029();
+ ItSmpLosSwtmr030();
+ ItSmpLosSwtmr031();
+ ItSmpLosSwtmr032();
+ ItSmpLosSwtmr033();
+ ItSmpLosSwtmr034();
+ ItSmpLosSwtmr035();
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+ ItLosSwtmr001();
+ ItLosSwtmr002();
+ ItLosSwtmr003();
+ ItLosSwtmr005();
+ ItLosSwtmr006();
+ ItLosSwtmr007();
+ ItLosSwtmr008();
+ ItLosSwtmr009();
+ ItLosSwtmr010();
+ ItLosSwtmr011();
+ ItLosSwtmr012();
+ ItLosSwtmr013();
+ ItLosSwtmr014();
+ ItLosSwtmr015();
+ ItLosSwtmr016();
+ ItLosSwtmr017();
+ ItLosSwtmr018();
+ ItLosSwtmr019();
+ ItLosSwtmr020();
+ ItLosSwtmr021();
+ ItLosSwtmr022();
+ ItLosSwtmr030();
+ ItLosSwtmr033();
+ ItLosSwtmr036();
+ ItLosSwtmr037();
+ ItLosSwtmr039();
+ ItLosSwtmr040();
+ ItLosSwtmr041();
+ ItLosSwtmr042();
+ ItLosSwtmr043();
+ ItLosSwtmr044();
+ ItLosSwtmr045();
+ ItLosSwtmr046();
+ ItLosSwtmr047();
+ ItLosSwtmr048();
+ ItLosSwtmr049();
+ ItLosSwtmr050();
+ ItLosSwtmr051();
+ ItLosSwtmr052();
+ ItLosSwtmr054();
+ ItLosSwtmr055();
+ ItLosSwtmr056();
+ ItLosSwtmr057();
+ ItLosSwtmr059();
+ ItLosSwtmr060();
+ ItLosSwtmr061();
+ ItLosSwtmr062();
+ ItLosSwtmr063();
+ ItLosSwtmr064();
+ ItLosSwtmr065();
+ ItLosSwtmr066();
+ ItLosSwtmr067();
+ ItLosSwtmr068();
+ ItLosSwtmr069();
+ ItLosSwtmr070();
+ ItLosSwtmr071();
+ ItLosSwtmr075();
+ ItLosSwtmr076();
+ ItLosSwtmr077();
+ ItLosSwtmr078();
+#endif
+
+#if defined(LOSCFG_TEST_PRESSURE)
+ ItLosSwtmr004();
+ ItLosSwtmr024();
+ ItLosSwtmr025();
+ ItLosSwtmr026();
+ ItLosSwtmr027();
+ ItLosSwtmr028();
+ ItLosSwtmr029();
+ ItLosSwtmr031();
+ ItLosSwtmr032();
+ ItLosSwtmr034();
+ ItLosSwtmr035();
+ ItLosSwtmr038();
+#endif
+
+#if defined(LOSCFG_TEST_LLT)
+ ItLosSwtmr073();
+#if !defined(TESTPBXA9) && !defined(TESTVIRTA53) && !defined(TEST3516DV300) && !defined(TESTHI1980IMU)
+ ItLosSwtmr072(); // SwtmrTimeGet
+ ItLosSwtmr074(); // across cores
+ ItLosSwtmr079(); // sched_clock_swtmr
+#endif
+ ItLosSwtmr080();
+ ItLosSwtmr023();
+#endif
+ ret = LOS_SetProcessScheduler(LOS_GetCurrProcessID(), LOS_SCHED_RR, 20); // 20, set a reasonable priority.
+ if (ret != LOS_OK) {
+ dprintf("%s set test process schedule failed! %d\n", ret);
+ }
+ ret = LOS_SetTaskScheduler(LOS_CurTaskIDGet(), LOS_SCHED_RR, TASK_PRIO_TEST);
+ if (ret != LOS_OK) {
+ dprintf("%s set test task schedule failed! %d\n", ret);
+ }
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/It_los_swtmr.h b/testsuites/kernel/sample/kernel_base/core/swtmr/It_los_swtmr.h
new file mode 100644
index 0000000000000000000000000000000000000000..580342f1eaebe3ea2a0cb02be7ccb483ec6eec6a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/It_los_swtmr.h
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IT_LOS_SWTMR_H
+#define IT_LOS_SWTMR_H
+
+#include "los_swtmr.h"
+#include "osTest.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define LOOP 100
+
+#define SELF_DELETED 0
+#define SYS_EXIST_SWTMR 1
+#define SWTMR_LOOP_NUM 10
+#define TEST_HWI_RUNTIME 0x100000
+
+extern EVENT_CB_S g_eventCB1;
+extern EVENT_CB_S g_eventCB2;
+extern EVENT_CB_S g_eventCB3;
+
+extern LITE_OS_SEC_BSS SWTMR_CTRL_S *m_pstSwtmrFreeList;
+
+static UINT32 g_swTmrMaxNum;
+
+static UINT16 g_swTmrID1;
+static UINT16 g_swTmrID2;
+static UINT16 g_swTmrID3;
+
+static UINT32 g_swtmrCountA;
+static UINT32 g_swtmrCountB;
+static UINT32 g_swtmrCountC;
+static UINT64 g_cpuTickCountA;
+static UINT64 g_cpuTickCountB;
+
+extern UINT32 OsSwTmrGetNextTimeout(VOID);
+extern UINT32 OsSwtmrTimeGet(SWTMR_CTRL_S *swtmr);
+
+extern VOID LOS_GetCpuTick(UINT32 *puwCntHi, UINT32 *puwCntLo);
+extern VOID ItSuiteLosSwtmr(VOID);
+
+#if defined(LOSCFG_KERNEL_SMP)
+VOID ItSmpLosSwtmr001(VOID);
+VOID ItSmpLosSwtmr002(VOID);
+VOID ItSmpLosSwtmr003(VOID);
+VOID ItSmpLosSwtmr004(VOID);
+VOID ItSmpLosSwtmr005(VOID);
+VOID ItSmpLosSwtmr006(VOID);
+VOID ItSmpLosSwtmr007(VOID);
+VOID ItSmpLosSwtmr008(VOID);
+VOID ItSmpLosSwtmr009(VOID);
+VOID ItSmpLosSwtmr010(VOID);
+VOID ItSmpLosSwtmr011(VOID);
+VOID ItSmpLosSwtmr012(VOID);
+VOID ItSmpLosSwtmr013(VOID);
+VOID ItSmpLosSwtmr014(VOID);
+VOID ItSmpLosSwtmr015(VOID);
+VOID ItSmpLosSwtmr016(VOID);
+VOID ItSmpLosSwtmr017(VOID);
+VOID ItSmpLosSwtmr018(VOID);
+VOID ItSmpLosSwtmr019(VOID);
+VOID ItSmpLosSwtmr020(VOID);
+VOID ItSmpLosSwtmr021(VOID);
+VOID ItSmpLosSwtmr022(VOID);
+VOID ItSmpLosSwtmr023(VOID);
+VOID ItSmpLosSwtmr024(VOID);
+VOID ItSmpLosSwtmr025(VOID);
+VOID ItSmpLosSwtmr026(VOID);
+VOID ItSmpLosSwtmr027(VOID);
+VOID ItSmpLosSwtmr028(VOID);
+VOID ItSmpLosSwtmr029(VOID);
+VOID ItSmpLosSwtmr030(VOID);
+VOID ItSmpLosSwtmr031(VOID);
+VOID ItSmpLosSwtmr032(VOID);
+VOID ItSmpLosSwtmr033(VOID);
+VOID ItSmpLosSwtmr034(VOID);
+VOID ItSmpLosSwtmr035(VOID);
+#endif
+
+#if defined(LOSCFG_TEST_SMOKE)
+VOID ItLosSwtmr053(VOID);
+VOID ItLosSwtmr058(VOID);
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+VOID ItLosSwtmr001(VOID);
+VOID ItLosSwtmr002(VOID);
+VOID ItLosSwtmr003(VOID);
+VOID ItLosSwtmr005(VOID);
+VOID ItLosSwtmr006(VOID);
+VOID ItLosSwtmr007(VOID);
+VOID ItLosSwtmr008(VOID);
+VOID ItLosSwtmr009(VOID);
+VOID ItLosSwtmr010(VOID);
+VOID ItLosSwtmr011(VOID);
+VOID ItLosSwtmr012(VOID);
+VOID ItLosSwtmr013(VOID);
+VOID ItLosSwtmr014(VOID);
+VOID ItLosSwtmr015(VOID);
+VOID ItLosSwtmr016(VOID);
+VOID ItLosSwtmr017(VOID);
+VOID ItLosSwtmr018(VOID);
+VOID ItLosSwtmr019(VOID);
+VOID ItLosSwtmr020(VOID);
+VOID ItLosSwtmr021(VOID);
+VOID ItLosSwtmr022(VOID);
+VOID ItLosSwtmr030(VOID);
+VOID ItLosSwtmr033(VOID);
+VOID ItLosSwtmr036(VOID);
+VOID ItLosSwtmr037(VOID);
+VOID ItLosSwtmr038(VOID);
+VOID ItLosSwtmr039(VOID);
+VOID ItLosSwtmr040(VOID);
+VOID ItLosSwtmr041(VOID);
+VOID ItLosSwtmr042(VOID);
+VOID ItLosSwtmr043(VOID);
+VOID ItLosSwtmr044(VOID);
+VOID ItLosSwtmr045(VOID);
+VOID ItLosSwtmr046(VOID);
+VOID ItLosSwtmr047(VOID);
+VOID ItLosSwtmr048(VOID);
+VOID ItLosSwtmr049(VOID);
+VOID ItLosSwtmr050(VOID);
+VOID ItLosSwtmr051(VOID);
+VOID ItLosSwtmr052(VOID);
+VOID ItLosSwtmr054(VOID);
+VOID ItLosSwtmr055(VOID);
+VOID ItLosSwtmr056(VOID);
+VOID ItLosSwtmr057(VOID);
+VOID ItLosSwtmr059(VOID);
+VOID ItLosSwtmr060(VOID);
+VOID ItLosSwtmr061(VOID);
+VOID ItLosSwtmr062(VOID);
+VOID ItLosSwtmr063(VOID);
+VOID ItLosSwtmr064(VOID);
+VOID ItLosSwtmr065(VOID);
+VOID ItLosSwtmr066(VOID);
+VOID ItLosSwtmr067(VOID);
+VOID ItLosSwtmr068(VOID);
+VOID ItLosSwtmr069(VOID);
+VOID ItLosSwtmr070(VOID);
+VOID ItLosSwtmr071(VOID);
+VOID ItLosSwtmr075(VOID);
+VOID ItLosSwtmr076(VOID);
+VOID ItLosSwtmr077(VOID);
+VOID ItLosSwtmr078(VOID);
+#endif
+
+#if defined(LOSCFG_TEST_PRESSURE)
+VOID ItLosSwtmr004(VOID);
+VOID ItLosSwtmr024(VOID);
+VOID ItLosSwtmr025(VOID);
+VOID ItLosSwtmr026(VOID);
+VOID ItLosSwtmr027(VOID);
+VOID ItLosSwtmr028(VOID);
+VOID ItLosSwtmr029(VOID);
+VOID ItLosSwtmr031(VOID);
+VOID ItLosSwtmr032(VOID);
+VOID ItLosSwtmr034(VOID);
+VOID ItLosSwtmr035(VOID);
+VOID ItLosSwtmr081(VOID);
+VOID ItLosSwtmr082(VOID);
+VOID ItLosSwtmr083(VOID);
+#endif
+
+#if defined(LOSCFG_TEST_LLT)
+VOID ItLosSwtmr072(VOID);
+VOID ItLosSwtmr073(VOID);
+VOID ItLosSwtmr074(VOID);
+VOID ItLosSwtmr079(VOID);
+VOID ItLosSwtmr080(VOID);
+VOID ItLosSwtmr023(VOID);
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#endif /* IT_LOS_SWTMR_H */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_001.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..2b75278184b195866925a6767083ebc7de64ed73
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_001.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+#endif
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr001(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr001", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_002.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..4908967caf1494d92eefb06b4acda7f7ba6ccc66
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_002.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xabcdbcda) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID, 0xabcdbcda);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, The expected value
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr002(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr002", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_003.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..5249655d4cf294580232b9543f78ea7eaac8b235
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_003.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, NULL, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_RET_PTR_NULL, ret, EXIT);
+
+ ret = LOS_SwtmrCreate(0, 0, NULL, &swTmrID, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_INTERVAL_NOT_SUITED, ret, EXIT);
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, NULL, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_PTR_NULL, ret, EXIT);
+
+ ret = LOS_SwtmrCreate(0, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_INTERVAL_NOT_SUITED, ret, EXIT);
+
+ // 4, Timeout interval of a periodic software timer. 3, test mode
+ ret = LOS_SwtmrCreate(4, 3, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_MODE_INVALID, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr003(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr003", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_005.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..6095e71a576d4e9fc351501f81fe02df8d5975de
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_005.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+
+ ret = LOS_SwtmrCreate(0x8000, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr005(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr005", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_006.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..9395a09f73ff39b28adae3d786d27c9208fa38cd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_006.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+
+ ret = LOS_SwtmrCreate(0x7fff, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr006(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr006", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_007.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..3d4bc23dd0237d14a75266712db76b38d322357e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_007.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_CREATED, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr007(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr007", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_008.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..fc1ffaaef9eca4b3bb9a35fe6b71ed32903893d9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_008.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_CREATED, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr008(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr008", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_009.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..b92c102b38aa28f1d15f3a81b5ced54ad1b8dcf5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_009.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID = OS_SWTMR_MAX_TIMERID;
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_ID_INVALID, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr009(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr009", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_010.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..6f7e94c0f2c856e06feb5b6b16856ebbeadcae7f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_010.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr010(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr010", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_011.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..af87ea95719f0ef7ba76b3c969ea1f0f2e72922f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_011.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr011(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr011", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_012.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..3fb5753bc476ee034e922fb4ef4422f285a85476
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_012.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ UINT32 ret;
+
+ if (arg != 0xffff) {
+ return;
+ }
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+#endif
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ g_testTaskID01 = swTmrID;
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+#endif
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr012(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr012", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_013.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..1af9a1f7db4f831b47d114fff8dd2bc61764f50a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_013.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ UINT32 ret;
+
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value
+
+EXIT:
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr013(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr013", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_014.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_014.c
new file mode 100644
index 0000000000000000000000000000000000000000..4b788bd82ea05c5d018f729cabdcc5cd8fff4620
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_014.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID = OS_SWTMR_MAX_TIMERID;
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_ID_INVALID, ret, EXIT);
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr014(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr014", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_015.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..30dd751e72d13a6de0a818a7bc5a60350d854b5e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_015.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+#endif
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr015(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr015", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_016.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_016.c
new file mode 100644
index 0000000000000000000000000000000000000000..2edcb6e090300b854d3a5150c353fb787d899deb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_016.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xabcdbcda) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID, 0xabcdbcda);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value
+
+EXIT:
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr016(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr016", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_017.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_017.c
new file mode 100644
index 0000000000000000000000000000000000000000..81b639bfff2c1b3acccd3e756674ef44c3d2d2be
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_017.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+
+ ret = LOS_SwtmrCreate(0x8000, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_CREATED, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr017(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr017", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_018.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..694f3584d45d2f279984a0a1972acd83d0dfac84
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_018.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+
+ ret = LOS_SwtmrCreate(0x8000, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_CREATED, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr018(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr018", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_019.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..05e158272e820f237b99551f4be8448da2a4e89b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_019.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_CREATED, ret, EXIT);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr019(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr019", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_020.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..9bafbfd190f16da167920384c058b30e62a172b7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_020.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ UINT32 ret;
+
+ if (arg != 0xffff) {
+ return;
+ }
+#if SELF_DELETED
+ ret = LOS_SwtmrStart(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+#endif
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ g_testTaskID01 = swTmrID;
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if SELF_DELETED
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value
+#else
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+#endif
+
+EXIT:
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+#endif
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr020(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr020", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_021.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..d337d2ea9a81e813f6720a9008c229ee9644308b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_021.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ UINT32 ret;
+
+ if (arg != 0xffff) {
+ return;
+ }
+#if SELF_DELETED
+ ret = LOS_SwtmrStart(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+#endif
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ g_testTaskID01 = swTmrID;
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value
+
+EXIT:
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr021(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr021", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_022.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..3118d432202f5e478802c90d9978bff002d9c7e2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_022.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (g_testCount != 2) { // 2, Execute if g_testCount is 2
+ return;
+ }
+ g_testCount++;
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ UINT32 hwiNum;
+#ifdef TEST3516A
+ hwiNum = HWI_NUM_INT32;
+#elif defined TEST3518E || defined TEST3516CV300
+ hwiNum = HWI_NUM_INT31;
+#elif defined TEST3559
+ hwiNum = HWI_NUM_INT32;
+#elif defined TEST3559A
+ hwiNum = HWI_NUM_INT69;
+#elif defined TEST3559A_M7
+ hwiNum = HWI_NUM_INT11;
+#elif defined TESTPBXA9 || defined TESTVIRTA53
+ hwiNum = HWI_NUM_INT60;
+#elif defined TEST3516DV300
+ hwiNum = HWI_NUM_INT60;
+#endif
+
+ TEST_HwiClear(HWI_NUM_TEST3);
+ g_testCount++;
+
+ // 2, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(2, LOS_SWTMR_MODE_ONCE, SwtmrF01, &g_swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST3, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestHwiTrigger(HWI_NUM_TEST3);
+
+ TestExtraTaskDelay(2); // 2, set delay time
+
+ ret = LOS_SwtmrStart(g_swTmrID1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, The expected value
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST3);
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+#endif
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr022(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr022", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_030.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_030.c
new file mode 100644
index 0000000000000000000000000000000000000000..7239f95b7d14bf433dcdaf42c5623c83b32ce4a9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_030.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+static VOID SwtmrF01(UINT32 arg)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID SwtmrF02(UINT32 arg)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1;
+ UINT16 swTmrID2;
+ int value;
+ g_testCount = 0;
+
+ // 10, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(10, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF02, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ // 10, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(10, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID2, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HAL_READ_UINT32(&g_testCount, value);
+ while (value < 4) { // 4, if value < 4, to do
+ HAL_READ_UINT32(&g_testCount, value);
+ }
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr030(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr030", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_033.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_033.c
new file mode 100644
index 0000000000000000000000000000000000000000..7aa9b526b46aa6ba3594b9991a6706a9da4baadd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_033.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 index;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ for (index = 0; index < TEST_HWI_RUNTIME; index++) {
+ }
+
+ g_testCount = 10; // 10,Set the number to determine whether the process is as expected.
+}
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 20, g_testCount); // 20, The expected value
+ g_testCount++;
+}
+
+static VOID SwtmrF02(UINT32 arg)
+{
+ UINT32 index;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 10, g_testCount); // 10, The expected value
+
+ for (index = 0; index < 0x1000; index++) {
+ }
+
+ g_testCount = 20; // 20, Set the number to determine whether the process is as expected.
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1;
+ UINT16 swTmrID2;
+ int value;
+ UINT64 tickstart;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF02, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ // 2, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(2, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID2, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ ret = LOS_SwtmrStart(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_SwtmrStart(swTmrID2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ HAL_READ_UINT32(&g_testCount, value);
+
+ tickstart = LOS_TickCountGet();
+
+ while (value != 21) { // 21, The expected value is not 21, execute
+ HAL_READ_UINT32(&g_testCount, value);
+ if (LOS_TickCountGet() - tickstart > 0xff) {
+ ICUNIT_GOTO_EQUAL(g_testCount, 21, g_testCount, EXIT); // 21, The expected value
+ }
+ }
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID1);
+ LOS_SwtmrDelete(swTmrID2);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr033(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr033", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_036.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_036.c
new file mode 100644
index 0000000000000000000000000000000000000000..61b8667d17dc76eead03358da85dd8f1d703a6c0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_036.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart((swTmrID + 1));
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+#endif
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr036(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr036", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_037.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_037.c
new file mode 100644
index 0000000000000000000000000000000000000000..48f76529a237702e25fb0957904ce722a0b4f6f9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_037.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(LOS_Tick2MS(1), LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart((swTmrID1 + 1));
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelay(12); // 12, set delay time
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ if (g_testCount < 10) { // 10, if g_testCount < 10 set a erro code, then exit
+ ICUNIT_GOTO_EQUAL(g_testCount, 10, g_testCount, EXIT); // 10, if g_testCount < 10 set a erro code, then exit
+ }
+
+EXIT:
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr037(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr037", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_039.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_039.c
new file mode 100644
index 0000000000000000000000000000000000000000..954f9d1a841fe56c3d6af693117cf4a8e0d2cc9c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_039.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+ ret = LOS_SwtmrStart(g_swTmrID1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ g_testCount1++;
+ return;
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_SWTMR_HWI_ACTIVE, ret);
+}
+
+static VOID SwtmrF02(UINT32 arg)
+{
+ g_testCount1++;
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ HWI_PRIOR_T hwiPrio = 3;
+ HWI_MODE_T hwiMode;
+ HWI_ARG_T arg = 0;
+
+ g_testCount1 = 0;
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF02, &g_swTmrID1, arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+ hwiMode = 0;
+ ret = TEST_HwiCreate(HWI_NUM_TEST, hwiPrio, hwiMode, (HWI_PROC_FUNC)SwtmrF01, (HwiIrqParam *)arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_TaskDelay(5); // 5, set delay time
+ ICUNIT_GOTO_EQUAL(g_testCount1, 2, g_testCount1, EXIT5); // 2, The expected value
+ TEST_HwiDelete(HWI_NUM_TEST);
+EXIT5:
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+#endif
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+
+EXIT3:
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr039(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr039", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_040.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_040.c
new file mode 100644
index 0000000000000000000000000000000000000000..d42b666c2c9eff4b69eab1c57b713a7b63fda9c8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_040.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(UINT32 arg)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+ ret = LOS_SwtmrStart(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount1++;
+
+ return;
+
+EXIT:
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_SWTMR_HWI_ACTIVE, ret);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+}
+
+static VOID SwtmrF02(UINT32 arg)
+{
+ g_testCount++;
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ HWI_PRIOR_T hwiPrio = 1;
+ HWI_MODE_T hwiMode;
+ HWI_ARG_T arg = 0;
+
+ g_testCount1 = 0;
+ g_testCount = 0;
+ // 5, create swtmr.
+ ret = LOS_SwtmrCreate(LOS_Tick2MS(5), LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF02, &g_swTmrID1, arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ hwiMode = 0;
+ ret = TEST_HwiCreate(HWI_NUM_TEST, hwiPrio, hwiMode, (HWI_PROC_FUNC)HwiF01, (HwiIrqParam *)arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ret = LOS_TaskDelay(7); // 7, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ ICUNIT_GOTO_EQUAL(g_testCount1, 1, g_testCount1, EXIT3);
+ ICUNIT_GOTO_NOT_EQUAL(g_testCount, 0, g_testCount, EXIT3);
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+EXIT3:
+ LOS_SwtmrDelete(g_swTmrID1);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr040(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr040", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_041.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_041.c
new file mode 100644
index 0000000000000000000000000000000000000000..34a6aa234ed83f319e843ef9aa04420fbe64af27
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_041.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ g_testCount1++;
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID1);
+ LOS_SwtmrDelete(g_swTmrID2);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return;
+}
+
+static VOID SwtmrF02(UINT32 arg)
+{
+ g_testCount1++;
+
+ return;
+}
+
+static VOID SwtmrF03(UINT32 arg)
+{
+ g_testCount1++;
+
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ HWI_PRIOR_T hwiPrio = 3;
+ HWI_MODE_T hwiMode = 0;
+ HWI_ARG_T arg = 0;
+ g_testCount1 = 0;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ // 10, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(10, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF03, &g_swTmrID1, arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ // 20, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(20, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF02, &g_swTmrID2, arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ ret = TEST_HwiCreate(HWI_NUM_TEST, hwiPrio, hwiMode, (HWI_PROC_FUNC)SwtmrF01, (HwiIrqParam *)arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT5);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ ret = LOS_SwtmrStart(g_swTmrID2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT5);
+
+ ret = LOS_SwtmrStart(g_swTmrID1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT5);
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount1, 1, g_testCount1, EXIT5);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+
+EXIT5:
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+EXIT3:
+ LOS_SwtmrDelete(g_swTmrID2);
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID1);
+}
+
+VOID ItLosSwtmr041(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr041", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_042.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_042.c
new file mode 100644
index 0000000000000000000000000000000000000000..0f01941daf496a01702338704814d26a1fe135ee
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_042.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ UINT32 *tick = NULL;
+
+ g_testCount = 0;
+
+ // 10, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(10, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStop((OS_SWTMR_MAX_TIMERID + 1));
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID1);
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr042(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr042", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_043.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_043.c
new file mode 100644
index 0000000000000000000000000000000000000000..070da1c39f0dff77d8496c43b435756101f25f1a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_043.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ g_testCount1++;
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ UINT32 tick;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+ g_testCount1++;
+
+ ret = LOS_SwtmrStart(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStop(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
+
+ ret = LOS_SwtmrTimeGet(g_swTmrID1, &tick);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret);
+ g_testCount1++;
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ g_testCount1 = 0;
+
+ // 2, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(2, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &g_swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ret = LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr043(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr043", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_044.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_044.c
new file mode 100644
index 0000000000000000000000000000000000000000..34f1055a08350319afea541bd38dcd35d36634ec
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_044.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+
+ // 2, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(2, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStop(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStop(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_CREATED, ret);
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr044(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr044", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_045.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_045.c
new file mode 100644
index 0000000000000000000000000000000000000000..645f83e243ab35d8a7e7e903ef6898d83a17c31e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_045.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID2, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr045(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr045", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_046.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_046.c
new file mode 100644
index 0000000000000000000000000000000000000000..345478bf2fab9cd3edca3fd77b312f44f5b57775
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_046.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1;
+ g_testCount = 0;
+
+ // 2, set swtmr
+ ret = LOS_SwtmrCreate(2, LOS_SWTMR_MODE_ONCE | LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(21); // 21, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 10, g_testCount, EXIT); // 10, The expected value
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID1);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr046(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr046", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_047.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_047.c
new file mode 100644
index 0000000000000000000000000000000000000000..98e3cb764c97b86bbae2ef2e695d1c1a27bd1bf4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_047.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1 = 0xffff;
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, 10, SwtmrF01, &swTmrID1, 0xffff); // 10, Timeout interval of a periodic software timer.
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr047(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr047", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_048.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_048.c
new file mode 100644
index 0000000000000000000000000000000000000000..0a1f38c22a543ab9bdc31ad7ee45f37fdb110258
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_048.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1 = (LOSCFG_BASE_CORE_SWTMR_CONFIG - 1);
+ UINT16 swTmrID2 = (LOSCFG_BASE_CORE_SWTMR_CONFIG - 1);
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID2, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr048(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr048", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_049.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_049.c
new file mode 100644
index 0000000000000000000000000000000000000000..06b8b5244f6e03ceba64fcb76376229291ce208d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_049.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1 + 1);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ g_testCount = 0;
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID2, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID2 + 1);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr049(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr049", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_050.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_050.c
new file mode 100644
index 0000000000000000000000000000000000000000..d5f976940207b9c885455e611437fe6956f093e2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_050.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID = OS_SWTMR_MAX_TIMERID;
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr050(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr050", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_051.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_051.c
new file mode 100644
index 0000000000000000000000000000000000000000..4721d1cb3646b9f24a864b8ecf3b7a6fcddcaa4e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_051.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(OS_SWTMR_MAX_TIMERID);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID2, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(OS_SWTMR_MAX_TIMERID);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr051(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr051", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_052.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_052.c
new file mode 100644
index 0000000000000000000000000000000000000000..70650e0fe41c5644c698a51e3a4f4e9199c0fc67
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_052.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(OS_SWTMR_MAX_TIMERID);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID2, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(OS_SWTMR_MAX_TIMERID);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr052(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr052", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_054.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_054.c
new file mode 100644
index 0000000000000000000000000000000000000000..e38953ccb00f7f6a3c5cbb252a04c3c8604e20a0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_054.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ UINT32 tick;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrTimeGet(swTmrID1 + 1, &tick);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr054(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr054", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_055.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_055.c
new file mode 100644
index 0000000000000000000000000000000000000000..bf2bf1ac3a3dbdd79ea262d2b0faab3860f45404
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_055.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ UINT32 tick;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrTimeGet(swTmrID1, &tick);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr055(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr055", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_056.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_056.c
new file mode 100644
index 0000000000000000000000000000000000000000..a5a46bb20155a0a9bdf4db1453d4344a87ad9225
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_056.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ UINT32 tick;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrTimeGet(swTmrID1, &tick);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr056(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr056", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_057.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_057.c
new file mode 100644
index 0000000000000000000000000000000000000000..d9f92ce8e2eeed727edd30d1c92f260ac2617696
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_057.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1;
+ UINT32 *tick = NULL;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStop(OS_SWTMR_MAX_TIMERID);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr057(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr057", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_059.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_059.c
new file mode 100644
index 0000000000000000000000000000000000000000..a003cd42081e9b3f58e2907218fa678a812f5a36
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_059.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ UINT32 tick;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrTimeGet(OS_SWTMR_MAX_TIMERID, &tick);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr059(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr059", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_060.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_060.c
new file mode 100644
index 0000000000000000000000000000000000000000..540c2dc96db670bb43ecfbbfc2c2edf3fd7ebb4b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_060.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ UINT32 tick;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrTimeGet(OS_SWTMR_MAX_TIMERID, &tick);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr060(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr060", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_061.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_061.c
new file mode 100644
index 0000000000000000000000000000000000000000..a0f9a47cde4ca5ebf56e18ad6e466546039ccaa7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_061.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ UINT32 tick;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrTimeGet((OS_SWTMR_MAX_TIMERID + 1), &tick);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr061(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr061", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_062.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_062.c
new file mode 100644
index 0000000000000000000000000000000000000000..db2350aaf7a004c5fc96e6b90929ce40bdfce7f8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_062.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ UINT32 *tick = NULL;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(swTmrID1, NULL);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID1);
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr062(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr062", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_063.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_063.c
new file mode 100644
index 0000000000000000000000000000000000000000..e16104584d98feb2d94593cb478345adc4f55cd9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_063.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ UINT32 *tick = NULL;
+
+ g_testCount = 0;
+
+ // 2, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(2, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStop((swTmrID1 + 1));
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStop(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr063(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr063", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_064.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_064.c
new file mode 100644
index 0000000000000000000000000000000000000000..afcb99f4f74645a9778e421ba85fce5a6de9bdcf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_064.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+ ret = LOS_SwtmrStop(g_swTmrID1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+ return;
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_SwtmrDelete(g_swTmrID1);
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ HWI_PRIOR_T hwiPrio = 3;
+ HWI_MODE_T hwiMode;
+ HWI_ARG_T arg = 0;
+
+ g_testCount = 0;
+ // 10, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(10, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID1, arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ hwiMode = 0;
+ ret = TEST_HwiCreate(HWI_NUM_TEST, hwiPrio, hwiMode, (HWI_PROC_FUNC)HwiF01, (HwiIrqParam *)arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ ret = LOS_SwtmrStart(g_swTmrID1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ret = LOS_SwtmrStart(g_swTmrID1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ LOS_TaskDelay(15); // 15, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT5); // 2, The expected value
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+#endif
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+EXIT5:
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+#endif
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+EXIT3:
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr064(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr064", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_065.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_065.c
new file mode 100644
index 0000000000000000000000000000000000000000..190056f6cd7f230f005310cb97dbfa4b6d5f4652
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_065.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+ ret = LOS_SwtmrStop(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID1);
+ TEST_HwiDelete(HWI_NUM_TEST);
+}
+static VOID SwtmrF01(UINT32 arg)
+{
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ HWI_PRIOR_T hwiPrio = 1;
+ HWI_MODE_T hwiMode;
+ HWI_ARG_T arg = 0;
+
+ g_testCount = 0;
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID1, arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ hwiMode = 0;
+ ret = TEST_HwiCreate(HWI_NUM_TEST, hwiPrio, hwiMode, (HWI_PROC_FUNC)HwiF01, (HwiIrqParam *)arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+ ret = LOS_SwtmrStart(g_swTmrID1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ ret = LOS_TaskDelay(3); // 3, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT5);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT5);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+EXIT5:
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+
+EXIT3:
+ ret = LOS_SwtmrDelete(g_swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr065(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr065", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_066.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_066.c
new file mode 100644
index 0000000000000000000000000000000000000000..4eb6be894c81c1f9cc66f33d93e6e4aba4d19b93
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_066.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ UINT32 tick;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(swTmrID, &tick);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ if (tick > 4) { // 4, if tick > 4, set a erro code, then exit
+ ICUNIT_GOTO_EQUAL(1, 0, tick, EXIT);
+ }
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(swTmrID, &tick);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_ID_INVALID, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+#endif
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr066(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr066", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_067.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_067.c
new file mode 100644
index 0000000000000000000000000000000000000000..5a687653e2b8506955dfc1f100a82894295656c6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_067.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_tick67;
+static UINT16 g_swTmrID67;
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ UINT32 ret;
+ if (arg != 0xffff) {
+ return;
+ }
+
+ ret = LOS_SwtmrTimeGet(g_swTmrID67, &g_tick67);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_ID_INVALID, ret, EXIT);
+
+ g_testCount++;
+ return;
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID67);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, &g_swTmrID67, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(g_swTmrID67);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(g_swTmrID67, &g_tick67);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(g_swTmrID67);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+#endif
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_SwtmrDelete(g_swTmrID67);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr067(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr067", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_068.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_068.c
new file mode 100644
index 0000000000000000000000000000000000000000..1308c5d1855044057236b1a522d7ab397fcc8e09
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_068.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xabcdbcda) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ UINT32 tick;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID, 0xabcdbcda);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(swTmrID, &tick);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(swTmrID, &tick);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(swTmrID, &tick);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_CREATED, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, The expected value
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr068(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr068", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_069.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_069.c
new file mode 100644
index 0000000000000000000000000000000000000000..21ee45a039335de9285301cc1bdf9e76928ec666
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_069.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_tick69;
+static UINT16 g_swTmrID69;
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ UINT32 ret;
+ if (arg != 0xabcdbcda) {
+ return;
+ }
+
+ ret = LOS_SwtmrTimeGet(g_swTmrID69, &g_tick69);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+ return;
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID69);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &g_swTmrID69, 0xabcdbcda);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(g_swTmrID69);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(g_swTmrID69, &g_tick69);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value
+
+ ret = LOS_SwtmrDelete(g_swTmrID69);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(g_swTmrID69, &g_tick69);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_CREATED, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, The expected value
+
+ return LOS_OK;
+EXIT:
+ ret = LOS_SwtmrDelete(g_swTmrID69);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr069(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr069", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_070.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_070.c
new file mode 100644
index 0000000000000000000000000000000000000000..4c7132581426457c2d0de4bbee7d9e4e670ce051
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_070.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+UINT32 g_getTickConsume1 = 0;
+static UINT32 g_time1, g_time2;
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+ g_time1 = g_time2 = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+#endif
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr070(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr070", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_071.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_071.c
new file mode 100644
index 0000000000000000000000000000000000000000..2b33ca55a5f5098a5306637fc988dd414e26f5e7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_071.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+static UINT32 g_tick;
+static UINT16 g_swTmrID71;
+static VOID SwtmrF01(UINT32 arg)
+{
+ UINT32 ret;
+ UINT32 tickTask1;
+
+ if (arg != 0xffff) {
+ return;
+ }
+
+ tickTask1 = (UINT32)LOS_TickCountGet();
+ g_testCount++;
+ return;
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID71);
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ g_testCount = 0;
+ // 10, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(10, LOS_SWTMR_MODE_ONCE, SwtmrF01, &g_swTmrID71, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(g_swTmrID71, &g_tick); // Gets the number of ticks left in the timer before it starts
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret, EXIT);
+
+ ret = 0;
+ ret = LOS_SwtmrStop(g_swTmrID71); // If the timer is not started, stop
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret, EXIT);
+
+ ret = LOS_SwtmrStart(g_swTmrID71); // Start timer
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = 0;
+ ret = LOS_TaskDelay(5); // 5, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(g_swTmrID71, &g_tick); // Gets the number of ticks remaining for the timer being timed
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStop(g_swTmrID71); // Stops the started timer
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrTimeGet(g_swTmrID71, &g_tick); // Gets the number of ticks left in the stopped timer
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret, EXIT);
+
+ ret = LOS_SwtmrStart(g_swTmrID71); // Start the timer again
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(12); // 12, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID71);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_ID_INVALID, ret, EXIT);
+
+ // After a single timer executes the callback function, the timer will be deleted, and the timer status will change
+ // to OS_SWTMR_STATUS_UNUSED
+ ret = LOS_SwtmrTimeGet(g_swTmrID71, &g_tick);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_ID_INVALID, ret, EXIT);
+
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(g_swTmrID71);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+#endif
+
+ return LOS_OK;
+EXIT:
+ ret = LOS_SwtmrDelete(g_swTmrID71);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr071(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr071", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_075.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_075.c
new file mode 100644
index 0000000000000000000000000000000000000000..5ca8136408053ce29ab3d059ac4390d2d15b2cb3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_075.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID = 0;
+
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_NO_SELFDELETE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr075(VOID)
+{
+ TEST_ADD_CASE("ItLosSwtmr075", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_076.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_076.c
new file mode 100644
index 0000000000000000000000000000000000000000..066c5519455c8296b6cdcd0404b528eff900e63c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_076.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID = 0;
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE | LOS_SWTMR_MODE_NO_SELFDELETE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID,
+ 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr076(VOID)
+{
+ TEST_ADD_CASE("ItLosSwtmr076", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_077.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_077.c
new file mode 100644
index 0000000000000000000000000000000000000000..f08f8af7f4f52d2baa4b15baaf8ca23ea7bfeb59
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_077.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ g_testCount = 0;
+
+ swTmrID = 0xff;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_PERIOD | LOS_SWTMR_MODE_NO_SELFDELETE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID,
+ 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_MODE_INVALID, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ if ((ret != LOS_ERRNO_SWTMR_ID_INVALID) && (ret != LOS_ERRNO_SWTMR_NOT_CREATED))
+ ICUNIT_GOTO_EQUAL(1, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ if ((ret != LOS_ERRNO_SWTMR_ID_INVALID) && (ret != LOS_ERRNO_SWTMR_NOT_CREATED))
+ ICUNIT_GOTO_EQUAL(1, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr077(VOID)
+{
+ TEST_ADD_CASE("ItLosSwtmr077", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_078.c b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_078.c
new file mode 100644
index 0000000000000000000000000000000000000000..f2fd5e4edfa8971af3caa749043bcd3a4965df03
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/full/It_los_swtmr_078.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID = 0xfff;
+
+ g_testCount = 0;
+
+ // 4, Timeout interval of a periodic software timer.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_OPP, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_MODE_INVALID, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ if ((ret != LOS_ERRNO_SWTMR_ID_INVALID) && (ret != LOS_ERRNO_SWTMR_NOT_CREATED))
+ ICUNIT_GOTO_EQUAL(1, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ if ((ret != LOS_ERRNO_SWTMR_ID_INVALID) && (ret != LOS_ERRNO_SWTMR_NOT_CREATED))
+ ICUNIT_GOTO_EQUAL(1, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+VOID ItLosSwtmr078(VOID)
+{
+ TEST_ADD_CASE("ItLosSwtmr078", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smoke/It_los_swtmr_053.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smoke/It_los_swtmr_053.c
new file mode 100644
index 0000000000000000000000000000000000000000..a370cf36df24357462d6140ba1379ae333319401
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smoke/It_los_swtmr_053.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1, swTmrID2;
+ UINT32 tick;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrTimeGet(swTmrID1 + 1, &tick);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr053(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr053", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smoke/It_los_swtmr_058.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smoke/It_los_swtmr_058.c
new file mode 100644
index 0000000000000000000000000000000000000000..6eb0d0912f59f23cab79a3e64c651115b33bd0cf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smoke/It_los_swtmr_058.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(UINT32 arg)
+{
+ if (arg != 0xffff) {
+ return;
+ }
+
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID1;
+ UINT32 *tick = NULL;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, SwtmrF01, &swTmrID1, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStop((swTmrID1 + 1));
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrDelete(swTmrID1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSwtmr058(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSwtmr058", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_001.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..4e02d0b0d5548ca5657ca446731843c8062b4d7d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_001.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTimes;
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ UINT16 testSwtmrHandle;
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &testSwtmrHandle, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(testSwtmrHandle);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskDelay(g_testPeriod * g_testTimes + 5); // g_testPeriod * g_testTimes + 5, set delay time
+
+ ret = LOS_SwtmrStop(testSwtmrHandle);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(testSwtmrHandle);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_SwtmrDelete(testSwtmrHandle);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 coreIdx = 0;
+
+ /* each core run swtmr for 10 times, period is 10 */
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+ g_testTimes = 10; // each core run swtmr for 10 times
+
+ while (coreIdx < LOSCFG_KERNEL_CORE_NUM) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_001_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(coreIdx));
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ coreIdx++;
+ }
+
+ LOS_TaskDelay(g_testPeriod * g_testTimes + 10); // g_testPeriod * g_testTimes + 10, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, g_testTimes * LOSCFG_KERNEL_CORE_NUM, g_testCount);
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr001(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr001", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_002.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..c62c2c927741854b74a58e979ba833a7184e54d8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_002.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTimes;
+
+static UINT16 g_swtmrHandle[LOSCFG_KERNEL_CORE_NUM];
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(UINTPTR swtmrId)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrStart(swtmrId);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestDumpCpuid();
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(swtmrId);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ /* each core run swtmr for 10 times, period is 10 */
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+ g_testTimes = 1;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swtmrHandle[i], 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT(testTask, "it_swtmr_002_task", TaskF01,
+ TASK_PRIO_TEST_SWTMR + 1); // not set cpuaffi
+ testTask.auwArgs[0] = g_swtmrHandle[i];
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(g_testPeriod * g_testTimes + 5); // g_testPeriod * g_testTimes + 5, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, g_testTimes * LOSCFG_KERNEL_CORE_NUM, g_testCount);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_SwtmrStop(g_swtmrHandle[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swtmrHandle[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+ return LOS_OK;
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_SwtmrDelete(g_swtmrHandle[i]);
+ }
+}
+
+VOID ItSmpLosSwtmr002(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr002", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_003.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..51f45b5981d5ab9ed7f094a1ac5a74e56dbceb1f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_003.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret, currCpuid;
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ /* do stop and delete */
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr003(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr003", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_004.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..4f3966405f3044c3e5513fc88d1b1f1947eb65c5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_004.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value
+
+ /* do stop and delete */
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr004(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr004", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_005.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..dd99d9bfcb3e2e418cda74b227906e977d4be2e7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_005.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret, currCpuid;
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_005_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value
+
+ /* do stop and delete */
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr005(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr005", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_006.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..c2159a886c95439c1f04f0be944bd48858bdc7c1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_006.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value
+
+ /* do stop and delete */
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr006(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr006", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_007.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..5aeae55faa6606f06fe1cc58425bf1d6a52a8a3e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_007.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret, currCpuid;
+
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr007(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr007", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_008.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..7e7ebcaeb942e85516ee70f35f0fc28c31c320b4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_008.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr008(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr008", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_009.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..db54d29bdc55f7d59ccad3d8ad4463e269d6a18b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_009.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret, currCpuid;
+
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_009_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr009(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr009", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_010.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..bbc549d51fd9a6be28064f3c349e74c4488b2cea
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_010.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr010(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr010", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_011.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..f8a60f3eab047a6aadce0c56af26d17ec2ab9759
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_011.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret, currCpuid;
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr011(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr011", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_012.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..7f6fb59d1efd09c146b1ef451acffc3d9bf4352f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_012.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr012(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr012", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_013.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..688783dd25daa153aa1bcd6caf8719226d9da2c7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_013.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret, currCpuid;
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_013_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr013(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr013", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_014.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_014.c
new file mode 100644
index 0000000000000000000000000000000000000000..3f76c2860f8952db290e8af0aa00c1ec39d0d94c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_014.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_014_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr014(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr014", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_015.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..c08564cf26dbe3d2ef8217142771833a39ed6bf5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_015.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr015(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr015", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_016.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_016.c
new file mode 100644
index 0000000000000000000000000000000000000000..1763c9edcbcf286a7998e7eff64c5a372095f83e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_016.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr016(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr016", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_017.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_017.c
new file mode 100644
index 0000000000000000000000000000000000000000..1a7d88bdeec054dcbe1dffbc88c03a02360b09d8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_017.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret, currCpuid;
+
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_009_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr017(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr017", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_018.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..1a25097c6e5d4349925dfd91a99a45266fb0d260
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_018.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 "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr018(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr018", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_019.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..cba9858171b6e9fdc7d99c4cd1278a59292d9915
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_019.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret, currCpuid;
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr019(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr019", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_020.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..146b808da453e02a7ed0edb5f65f00f70545790f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_020.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr020(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr020", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_021.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..d23455db19b06dfc216981e98b2ad45c46c1bfb3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_021.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret, currCpuid;
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_009_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr021(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr021", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_022.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..56b752ece220689f7ac8d73009264b6fb5eb7fbc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_022.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr022(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr022", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_023.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..60cdd36a55f11c52c6442266f175569eea6f4c5f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_023.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // cross task
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ret = LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr023(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr023", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_024.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_024.c
new file mode 100644
index 0000000000000000000000000000000000000000..ccfcbe061392e6e57c6c38b9adc4f567dc9e8ac1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_024.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestDumpCpuid();
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ LOS_SwtmrStop(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestDumpCpuid();
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT(testTask, "it_swtmr_024_task1", TaskF01,
+ TASK_PRIO_TEST_SWTMR + 1); // not set cpuaffi
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT(testTask, "it_swtmr_024_task2", TaskF02,
+ TASK_PRIO_TEST_SWTMR + 1); // not set cpuaffi
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr024(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr024", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_025.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_025.c
new file mode 100644
index 0000000000000000000000000000000000000000..69d3f1eed3109ef495b1d837837aecc0ea8e58f0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_025.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_szId[LOSCFG_KERNEL_CORE_NUM] = {0};
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(UINT32 index)
+{
+ UINT32 ret;
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_szId[index], 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_025_task1", TaskF01, TASK_PRIO_TEST_SWTMR + 1, CPUID_TO_AFFI_MASK(i));
+ testTask.auwArgs[0] = i;
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(1);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_SwtmrStart(g_szId[i]);
+ }
+
+ LOS_TaskDelay(g_testPeriod);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_SwtmrDelete(g_szId[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_SwtmrDelete(g_szId[i]);
+ }
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr025(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr025", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_026.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..fc596eb77c0aeca17f82cfbf81446ead5660886e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_026.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sztmrId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 g_sztskId[LOSCFG_KERNEL_CORE_NUM] = {0};
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(UINT32 index)
+{
+ UINT32 ret, i, j;
+
+ for (i = 0; i < LOOP; i++) {
+ for (j = 0; j < TRandom() % 100; j++) { // 100, Gets a random number between 0 and 100
+ }
+ ret = LOS_SwtmrStart(g_sztmrId[index]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ TestDumpCpuid();
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_sztmrId[index]);
+ return;
+}
+
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+ UINT32 i, ticks;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_sztmrId[i], 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_026_task1", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ testTask.auwArgs[0] = i;
+ ret = LOS_TaskCreate(&g_sztskId[i], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ TestBusyTaskDelay(g_testPeriod + 1);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = OS_TCB_FROM_TID(g_sztskId[i])->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ ret = LOS_SwtmrTimeGet(g_sztmrId[i], &ticks);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ if (ticks > g_testPeriod)
+ ICUNIT_GOTO_EQUAL(1, 0, ticks, EXIT);
+ }
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(g_sztskId[i]);
+ ret = LOS_SwtmrDelete(g_sztmrId[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr026(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr026", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_027.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..8a79c73c247ef54827512f3ecc15624768d47bdf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_027.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sztmrId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 g_sztskId[LOSCFG_KERNEL_CORE_NUM] = {0};
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(UINT32 index)
+{
+ UINT32 ret, i;
+
+ for (i = 0; i < TRandom() % 500; i++) { // 500, Gets a random number between 0 and 500
+ }
+
+ ret = LOS_SwtmrStop(g_sztmrId[index]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount1);
+ TestDumpCpuid();
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_sztmrId[index]);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+ UINT32 i, j;
+
+ g_testCount = 0;
+ g_testCount1 = 0;
+ g_testPeriod = 10; // period is 10
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_sztmrId[i], 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_sztmrId[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ for (j = 0; j < LOOP; j++) {
+ g_testCount = 0;
+ g_testCount1 = 0;
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_027_task1", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ testTask.auwArgs[0] = i;
+ ret = LOS_TaskCreate(&g_sztskId[i], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(g_testPeriod * 2); // 2,delay enough time
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount1, LOSCFG_KERNEL_CORE_NUM, g_testCount1, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = OS_TCB_FROM_TID(g_sztskId[i])->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = LOS_SwtmrStart(g_sztmrId[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+ }
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_SwtmrDelete(g_sztmrId[i]);
+ LOS_TaskDelete(g_sztskId[i]);
+ }
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr027(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr027", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_028.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_028.c
new file mode 100644
index 0000000000000000000000000000000000000000..4d7f05f73d6829fdb2cb63a63f1b9c43234d7dfc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_028.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 g_sztmrId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 g_sztskId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(UINT32 index)
+{
+ UINT32 ret, i;
+
+ for (i = 0; i < TRandom() % 500; i++) { // 500, Gets a random number between 0 and 500
+ }
+
+ ret = LOS_SwtmrDelete(g_sztmrId[index]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount1);
+ TestDumpCpuid();
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_sztmrId[index]);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+ UINT32 i, j;
+
+ g_testPeriod = 10; // period is 10
+
+ for (j = 0; j < LOOP; j++) {
+ g_testCount = 0;
+ g_testCount1 = 0;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_sztmrId[i], 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(g_sztmrId[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_028_task1", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ testTask.auwArgs[0] = i;
+ ret = LOS_TaskCreate(&g_sztskId[i], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(g_testPeriod * 2); // 2, delay enough time
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount1, LOSCFG_KERNEL_CORE_NUM, g_testCount1, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = OS_TCB_FROM_TID(g_sztskId[i])->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ LOS_SwtmrDelete(g_sztmrId[i]); // clear the swtmr
+ LOS_TaskDelete(g_sztskId[i]);
+ }
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_SwtmrDelete(g_sztmrId[i]);
+ LOS_TaskDelete(g_sztskId[i]);
+ }
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr028(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr028", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_029.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..6b548a64d44cc4c55484aac65ca211edf58407e2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_029.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 g_sztmrId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 g_sztskId[LOSCFG_KERNEL_CORE_NUM] = {0};
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(VOID)
+{
+ UINT32 ret, i, j;
+
+ for (i = 0; i < LOOP; i++) {
+ for (j = 0; j < TRandom() % 100; j++) { // 100, Gets a random number between 0 and 100
+ }
+
+ ret = LOS_SwtmrStart(g_sztmrId[0]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+ LOS_AtomicInc(&g_testCount1);
+ TestDumpCpuid();
+ ret = LOS_EventWrite(&g_eventCB, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_SwtmrDelete(g_sztmrId[i]);
+ }
+ return;
+}
+
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+ UINT32 i, j;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+ g_testCount1 = 0;
+
+ ret = LOS_EventInit(&g_eventCB);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_sztmrId[i], 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_029_task1", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&g_sztskId[i], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ ret = LOS_EventRead(&g_eventCB, LOSCFG_KERNEL_CPU_MASK, LOS_WAITMODE_AND,
+ LOS_MS2Tick(10000)); // 10000, Converts the number of milliseconds to the number of ticks,and set timeout
+ LOS_TaskDelay(g_testPeriod + 1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount1, LOSCFG_KERNEL_CORE_NUM, g_testCount1, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = OS_TCB_FROM_TID(g_sztskId[i])->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ }
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(g_sztskId[i]);
+ ret = LOS_SwtmrDelete(g_sztmrId[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_EventDestroy(&g_eventCB);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr029(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr029", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_030.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_030.c
new file mode 100644
index 0000000000000000000000000000000000000000..333408eb6b8b5125372e992e5c439c2bdb155bc9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_030.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sztskId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 g_ret = 0xff;
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret, i;
+
+ for (i = 0; i < TRandom() % 100; i++) { // 100, Gets a random number between 0 and 100
+ }
+
+ ret = LOS_SwtmrStop(g_swTmrID);
+
+ LOS_AtomicAdd(&g_ret, ret);
+
+ TestDumpCpuid();
+ return;
+}
+
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+ UINT32 i, j;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ for (j = 0; j < LOOP; j++) {
+ g_testCount = 0;
+ g_ret = 0xff;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_030_task1", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&g_sztskId[i], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(g_testPeriod * 2); // g_testPeriod*2, delay enough time
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_ret, 0xff + LOS_OK + LOS_ERRNO_SWTMR_NOT_STARTED * (LOSCFG_KERNEL_CORE_NUM - 1), g_ret,
+ EXIT);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+EXIT:
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(g_sztskId[i]);
+ }
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr030(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr030", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_031.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_031.c
new file mode 100644
index 0000000000000000000000000000000000000000..953b6f965f9c9b1666519cabe36b8874d2e03298
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_031.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sztskId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 g_ret = 0xff;
+
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret, i;
+
+ for (i = 0; i < TRandom() % 100; i++) { // 100, Gets a random number between 0 and 100
+ }
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ LOS_AtomicAdd(&g_ret, ret);
+
+ TestDumpCpuid();
+ return;
+
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+ UINT32 i, j;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ for (j = 0; j < LOOP; j++) {
+ g_testCount = 0;
+ g_ret = 0xff;
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_031_task1", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+
+ ret = LOS_TaskCreate(&g_sztskId[i], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(g_testPeriod * 2); // g_testPeriod*2, set delay time
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ ICUNIT_GOTO_EQUAL(g_ret, 0xff + LOS_OK + LOS_ERRNO_SWTMR_NOT_CREATED * (LOSCFG_KERNEL_CORE_NUM - 1), g_ret,
+ EXIT);
+ }
+
+EXIT:
+
+ LOS_SwtmrDelete(g_swTmrID);
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(g_sztskId[i]);
+ }
+ LOS_TaskDelay(20); // 20, delay
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr031(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr031", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_032.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_032.c
new file mode 100644
index 0000000000000000000000000000000000000000..8f85fb062e3375fa09bb178f0ceb6c277e08c8e8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_032.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sztmrId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 g_sztskId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(UINT32 index)
+{
+ UINT32 ret, i, j;
+
+ for (i = 0; i < LOOP; i++) {
+ for (j = 0; j < TRandom() % 100; j++) { // 100, Gets a random number between 0 and 100
+ }
+
+ ret = LOS_SwtmrCreate(LOS_Tick2MS(g_testPeriod), LOS_SWTMR_MODE_PERIOD,
+ (SWTMR_PROC_FUNC)SwtmrF01, &g_sztmrId[index], 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_sztmrId[index]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskDelay(g_testPeriod + 3); // +3, have enough time to wait alarm.
+
+ for (j = 0; j < TRandom() % 100; j++) { // 100, Gets a random number between 0 and 100
+ }
+
+ ret = LOS_SwtmrStop(g_sztmrId[index]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrDelete(g_sztmrId[index]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+ TestDumpCpuid();
+ return;
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_SwtmrDelete(g_sztmrId[i]);
+ }
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testPeriod = 10; // period is 10
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_032_task1", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ testTask.auwArgs[0] = i;
+ ret = LOS_TaskCreate(&g_sztskId[i], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(g_testPeriod * LOOP * 10 + 1000); // g_testPeriod*LOOP * 10 +1000, delay enough time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM * LOOP, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_SwtmrDelete(g_sztmrId[i]);
+ LOS_TaskDelete(g_sztskId[i]);
+ }
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr032(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr032", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_033.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_033.c
new file mode 100644
index 0000000000000000000000000000000000000000..efc5dca1a12958f7c90a03cee8646fbaf3855e63
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_033.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sztskId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 g_ret;
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+static VOID TaskF01(void)
+{
+ UINT32 ret, i;
+
+ for (i = 0; i < TRandom() % 500; i++) { // 500, Gets a random number between 0 and 500
+ }
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return;
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static VOID TaskF02(void)
+{
+ UINT32 ret, i;
+
+ for (i = 0; i < TRandom() % 500; i++) { // 500, Gets a random number between 0 and 500
+ }
+
+ ret = LOS_SwtmrStop(g_swTmrID);
+ g_ret = ret;
+ return;
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+ UINT32 i;
+
+ g_testPeriod = 10; // period is 10
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_033_task1", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_033_task1", TaskF02, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ if ((g_ret != LOS_OK) && (g_ret != LOS_ERRNO_SWTMR_NOT_STARTED)) {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret, EXIT);
+ }
+
+ if (g_ret == LOS_ERRNO_SWTMR_NOT_STARTED) { // timer is started and stop failed
+ LOS_TaskDelay(g_testPeriod + 1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ }
+
+ LOS_SwtmrStop(g_swTmrID);
+ }
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr033(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr033", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_034.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_034.c
new file mode 100644
index 0000000000000000000000000000000000000000..45e9f2104a0f3193bdf322b4dae12ecaa9681ad4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_034.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sztmrId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 g_sztskId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static volatile UINT32 g_flag = 0;
+static volatile UINT32 g_mStop = 0;
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+static UINT32 Calsum(UINT32 begin, UINT32 end)
+{
+ UINT32 result = 0;
+ UINT32 i;
+ LOS_ASSERT(begin < end);
+ for (i = begin; i <= end; i++)
+ result += i;
+ return result;
+}
+static VOID TaskF01(UINT32 index)
+{
+ UINT32 ret, i, j;
+ ret = LOS_SwtmrCreate(LOS_Tick2MS(g_testPeriod), LOS_SWTMR_MODE_PERIOD,
+ (SWTMR_PROC_FUNC)SwtmrF01, &g_sztmrId[index], 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicAdd(&g_flag, index);
+ while (g_flag != g_mStop) { // wait for all swtmr create
+ }
+
+ for (i = 0; i < LOOP; i++) {
+ for (j = 0; j < TRandom() % 100; j++) { // 100, Gets a random number between 0 and 100
+ }
+
+ ret = LOS_SwtmrStart(g_sztmrId[index]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskDelay(g_testPeriod + 1);
+
+ ret = LOS_SwtmrStop(g_sztmrId[index]); // cross
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ LOS_TaskDelay(1);
+ }
+ TestDumpCpuid();
+ return;
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_SwtmrDelete(g_sztmrId[i]);
+ }
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_flag = 0;
+ g_testPeriod = 10; // period is 10
+ g_mStop = Calsum(0, LOSCFG_KERNEL_CORE_NUM - 1);
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_032_task1", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ testTask.auwArgs[0] = i;
+ ret = LOS_TaskCreate(&g_sztskId[i], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(g_testPeriod * LOOP + 20000); // g_testPeriod*LOOP+20000, delay enough time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM * LOOP, g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_SwtmrDelete(g_sztmrId[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ LOS_TaskDelete(g_sztskId[i]);
+ }
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_SwtmrDelete(g_sztmrId[i]);
+ LOS_TaskDelete(g_sztskId[i]);
+ }
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr034(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr034", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_035.c b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_035.c
new file mode 100644
index 0000000000000000000000000000000000000000..cd992ef8a4d01bebfc5e950dddfa1df8567e4379
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/swtmr/smp/It_smp_los_swtmr_035.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_swtmr.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sztskId[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 g_ret = 0xff;
+static VOID SwtmrF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret, i;
+
+ for (i = 0; i < TRandom() % 500; i++) { // 500, Gets a random number between 0 and 500
+ }
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ g_ret = ret;
+ return;
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static VOID TaskF02(void)
+{
+ UINT32 ret, i;
+
+ for (i = 0; i < TRandom() % 500; i++) { // 500, Gets a random number between 0 and 500
+ }
+
+ ret = LOS_SwtmrDelete(g_swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return;
+EXIT:
+ LOS_SwtmrDelete(g_swTmrID);
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 currCpuid;
+ UINT32 i;
+
+ g_testPeriod = 10; // period is 10
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_033_task1", TaskF01, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_033_task1", TaskF02, TASK_PRIO_TEST_SWTMR - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ if ((g_ret != LOS_OK) && (g_ret != LOS_ERRNO_SWTMR_NOT_CREATED)) {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret, EXIT);
+ }
+
+ LOS_TaskDelay(g_testPeriod + 10); // g_testPeriod+10, delay enough time
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ LOS_SwtmrDelete(g_swTmrID);
+ }
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_SwtmrDelete(g_swTmrID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSwtmr035(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSwtmr035", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/core/task/It_los_task.c b/testsuites/kernel/sample/kernel_base/core/task/It_los_task.c
new file mode 100644
index 0000000000000000000000000000000000000000..48f146bc5db518c3cb748ac62d151c1c583226b3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/It_los_task.c
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define LOSCFG_TEST_UNSOLVED YES
+volatile UINT64 g_itTimesliceTestCount1 = 0;
+volatile INT32 g_timesliceTestCount = 0;
+
+void ItSuiteLosTask(void)
+{
+ int ret = LOS_SetProcessScheduler(LOS_GetCurrProcessID(), LOS_SCHED_RR, TASK_PRIO_TEST_TASK);
+ if (ret != LOS_OK) {
+ dprintf("%s set test process schedule failed! %d\n", ret);
+ }
+ ret = LOS_SetTaskScheduler(LOS_CurTaskIDGet(), LOS_SCHED_RR, TASK_PRIO_TEST_TASK);
+ if (ret != LOS_OK) {
+ dprintf("%s set test task schedule failed! %d\n", ret);
+ }
+#if defined(LOSCFG_TEST_SMOKE)
+ ItLosTask045();
+ ItLosTask046();
+ ItLosTask049();
+ ItLosTask081();
+ ItLosTask089();
+ ItLosTask097();
+ ItLosTask101();
+ ItLosTask105();
+ ItLosTask099();
+ ItLosTaskTimeslice001();
+#if (LOSCFG_KERNEL_SMP == YES)
+ // reserved 20 for smoke test
+ ItSmpLosTask001(); /* Task Affinity */
+ ItSmpLosTask002(); /* Task Deletion Across Cores */
+ ItSmpLosTask003(); /* Task Suspend Across Cores */
+ ItSmpLosTask004(); /* Task Created Unbinded */
+#endif
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+ ItLosTask001();
+ ItLosTask002();
+ ItLosTask004();
+ ItLosTask007();
+ ItLosTask008();
+ ItLosTask009();
+ ItLosTask010();
+ ItLosTask011();
+ ItLosTask012();
+ ItLosTask013();
+ ItLosTask014();
+ ItLosTask015();
+ ItLosTask016();
+ ItLosTask017();
+ ItLosTask018();
+ ItLosTask019();
+ ItLosTask020();
+ ItLosTask021();
+ ItLosTask022();
+ ItLosTask023();
+ ItLosTask024();
+ ItLosTask025();
+ ItLosTask026();
+ ItLosTask027();
+ ItLosTask028();
+ ItLosTask029();
+ ItLosTask031();
+ ItLosTask032();
+ ItLosTask033();
+ ItLosTask034();
+ ItLosTask035();
+ ItLosTask036();
+ ItLosTask037();
+ ItLosTask038();
+ ItLosTask039();
+#ifndef TESTHI1980IMU
+ ItLosTask040();
+#endif
+ ItLosTask041();
+ ItLosTask042();
+ ItLosTask043();
+ ItLosTask047();
+ ItLosTask048();
+ ItLosTask050();
+ ItLosTask051();
+ ItLosTask052();
+ ItLosTask053();
+ ItLosTask054();
+ ItLosTask055();
+ ItLosTask056();
+ ItLosTask057();
+ ItLosTask058();
+ ItLosTask060();
+ ItLosTask061();
+ ItLosTask063();
+ ItLosTask064();
+ ItLosTask065();
+ ItLosTask066();
+ ItLosTask067();
+ ItLosTask068();
+ ItLosTask069();
+ ItLosTask071();
+ ItLosTask072();
+ ItLosTask073();
+ ItLosTask074();
+#if (LOSCFG_KERNEL_SMP != YES)
+ ItLosTask075();
+#endif
+ ItLosTask076();
+ ItLosTask077();
+ ItLosTask078();
+ ItLosTask079();
+ ItLosTask080(); // LOS_TaskYeild is not allowed in irq
+ ItLosTask082();
+ ItLosTask090();
+ ItLosTask092();
+ ItLosTask093();
+ ItLosTask094();
+ ItLosTask095();
+ ItLosTask096();
+ ItLosTask098();
+ ItLosTask100();
+ ItLosTask102();
+ ItLosTask103();
+ ItLosTask104();
+ ItLosTask106();
+ ItLosTask107();
+ ItLosTask108();
+ ItLosTask109();
+ ItLosTask110();
+ ItLosTask111();
+ ItLosTask112();
+ ItLosTask113();
+ ItLosTask114();
+ ItLosTask115();
+ ItLosTask116(); // Not used the API LOS_CurTaskPriSet to change the task priority for the software timer
+ ItLosTask119();
+ ItLosTask120();
+ ItLosTask121();
+ ItLosTask122();
+ ItLosTask123();
+ ItLosTask124();
+ ItLosTask125();
+ ItLosTask126();
+ ItLosTask127();
+ ItLosTask128();
+ ItLosTask129();
+ ItLosTask130();
+ ItLosTask131();
+ ItLosTask132();
+ ItLosTask133();
+ ItLosTask134();
+ ItLosTask135();
+ ItLosTask136();
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+ ItLosTask141(); /* fpu regs check in task switch */
+ ItLosTask142(); /* fpu regs check in irq context switch */
+#endif
+ ItLosTaskTimeslice002();
+ ItLosTaskTimeslice003();
+ ItLosTaskTimeslice004();
+#if (LOSCFG_KERNEL_SMP == YES)
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+
+ ItSmpLosFloatSwitch001();
+ ItSmpLosFloatSwitch002();
+ ItSmpLosFloatSwitch003();
+ ItSmpLosFloatSwitch004();
+ ItSmpLosFloatSwitch005();
+ ItSmpLosFloatSwitch006();
+ ItSmpLosFloatSwitch007();
+#endif
+ // fixed
+ ItSmpLosTask099();
+ ItSmpLosTask049();
+ ItSmpLosTask130();
+ ItSmpLosTask159();
+ ItSmpLosTask161();
+ ItSmpLosTask137();
+ ItSmpLosTask158();
+ ItSmpLosTask021();
+ ItSmpLosTask022();
+ ItSmpLosTask023();
+ ItSmpLosTask025();
+ ItSmpLosTask026();
+ ItSmpLosTask027();
+ ItSmpLosTask028();
+ ItSmpLosTask029();
+ ItSmpLosTask030();
+ ItSmpLosTask032();
+ ItSmpLosTask033();
+ ItSmpLosTask034();
+ ItSmpLosTask035();
+ ItSmpLosTask036();
+ ItSmpLosTask037();
+ ItSmpLosTask040();
+ ItSmpLosTask042();
+ ItSmpLosTask043();
+ ItSmpLosTask044();
+ ItSmpLosTask046();
+ ItSmpLosTask047();
+ ItSmpLosTask048();
+ ItSmpLosTask050();
+ ItSmpLosTask051();
+ ItSmpLosTask052();
+ ItSmpLosTask053();
+ ItSmpLosTask054();
+ ItSmpLosTask055();
+ ItSmpLosTask056();
+ ItSmpLosTask057();
+ ItSmpLosTask058();
+ ItSmpLosTask059();
+ ItSmpLosTask060();
+ ItSmpLosTask061();
+ ItSmpLosTask062();
+ ItSmpLosTask063();
+ ItSmpLosTask064();
+ ItSmpLosTask065();
+ ItSmpLosTask066();
+ ItSmpLosTask067();
+ ItSmpLosTask068();
+ ItSmpLosTask069();
+ ItSmpLosTask070();
+ ItSmpLosTask071();
+ ItSmpLosTask073();
+ ItSmpLosTask074();
+ ItSmpLosTask076();
+ ItSmpLosTask077();
+ ItSmpLosTask078();
+ ItSmpLosTask079();
+ ItSmpLosTask081();
+ ItSmpLosTask082();
+ ItSmpLosTask084();
+ ItSmpLosTask087();
+ ItSmpLosTask088();
+ ItSmpLosTask089();
+ ItSmpLosTask090();
+ ItSmpLosTask091();
+ ItSmpLosTask092();
+ ItSmpLosTask093();
+ ItSmpLosTask094();
+ ItSmpLosTask095();
+ ItSmpLosTask096();
+ ItSmpLosTask097();
+ ItSmpLosTask098();
+ ItSmpLosTask100();
+ ItSmpLosTask101();
+ ItSmpLosTask102();
+ ItSmpLosTask103();
+ ItSmpLosTask105();
+ ItSmpLosTask106();
+ ItSmpLosTask107();
+ ItSmpLosTask108();
+ ItSmpLosTask109();
+ ItSmpLosTask110();
+ ItSmpLosTask112();
+ ItSmpLosTask114();
+ ItSmpLosTask115();
+#if (LOSCFG_KERNEL_SMP_TASK_SYNC == NO)
+ ItSmpLosTask117();
+#endif
+ ItSmpLosTask126();
+ ItSmpLosTask127();
+ ItSmpLosTask128();
+ ItSmpLosTask129();
+ ItSmpLosTask131();
+ ItSmpLosTask132();
+ ItSmpLosTask133();
+ ItSmpLosTask134();
+ ItSmpLosTask135();
+ ItSmpLosTask136();
+ ItSmpLosTask138();
+ ItSmpLosTask139();
+ ItSmpLosTask141();
+ ItSmpLosTask142();
+ ItSmpLosTask143();
+ ItSmpLosTask144();
+ ItSmpLosTask145();
+ ItSmpLosTask146();
+ ItSmpLosTask147();
+ ItSmpLosTask148();
+ ItSmpLosTask149();
+ ItSmpLosTask150();
+ ItSmpLosTask151();
+ ItSmpLosTask152();
+ ItSmpLosTask153();
+ ItSmpLosTask154();
+ ItSmpLosTask155();
+ ItSmpLosTask156();
+ ItSmpLosTask157();
+#endif
+#endif
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, 1);
+ HalIrqSetAffinity(HWI_NUM_TEST1, 1);
+ HalIrqSetAffinity(HWI_NUM_TEST3, 1);
+#endif
+ ret = LOS_SetProcessScheduler(LOS_GetCurrProcessID(), LOS_SCHED_RR, 20); // 20, set a reasonable priority.
+ if (ret != LOS_OK) {
+ dprintf("%s set test process schedule failed! %d\n", ret);
+ }
+ ret = LOS_SetTaskScheduler(LOS_CurTaskIDGet(), LOS_SCHED_RR, TASK_PRIO_TEST);
+ if (ret != LOS_OK) {
+ dprintf("%s set test task schedule failed! %d\n", ret);
+ }
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/It_los_task.h b/testsuites/kernel/sample/kernel_base/core/task/It_los_task.h
new file mode 100644
index 0000000000000000000000000000000000000000..9b0e90586be9dca6947da3e741671490547c77bf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/It_los_task.h
@@ -0,0 +1,367 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IT_LOS_TASK_H
+#define IT_LOS_TASK_H
+
+#include "osTest.h"
+#include "los_base_pri.h"
+#include "los_task_pri.h"
+#include "los_tick_pri.h"
+#include "los_list.h"
+#include "los_process_pri.h"
+#include "los_percpu_pri.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define SELF_DELETED 0
+#define SYS_EXIST_SWTMR 1
+#define SWTMR_LOOP_NUM 10
+#define TEST_HWI_RUNTIME 0x100000
+#define TASK_LOOP_NUM 0x100000
+#if (YES == LOSCFG_BASE_CORE_SWTMR)
+#define TASK_EXISTED_NUM 4
+#else
+#define TASK_EXISTED_NUM 2
+#endif
+
+#define TASK_EXISTED_D_NUM TASK_EXISTED_NUM
+#define TASK_NAME_NUM 10
+#define IT_TASK_LOOP 20
+#define IT_TASK_SMP_LOOP 100
+
+extern EVENT_CB_S g_eventCB;
+extern EVENT_CB_S g_eventCB1;
+extern EVENT_CB_S g_eventCB2;
+extern EVENT_CB_S g_eventCB3;
+
+extern UINT32 g_testTaskID01;
+extern UINT32 g_testTaskID02;
+extern UINT32 g_testTaskID03;
+extern UINT32 g_testTskHandle;
+extern UINT32 g_swTmrMaxNum;
+
+extern UINT8 g_mUsIndex;
+extern UINT16 g_swTmrID1;
+extern UINT16 g_swTmrID2;
+extern UINT16 g_swTmrID3;
+
+extern UINT32 g_swtmrCountA;
+extern UINT32 g_swtmrCountB;
+extern UINT32 g_swtmrCountC;
+extern UINT64 g_cpuTickCountA;
+extern UINT64 g_cpuTickCountB;
+extern UINT32 g_leavingTaskNum;
+
+extern UINT32 g_mAuwTestTaskId[32];
+
+extern volatile UINT64 g_itTimesliceTestCount1;
+extern volatile INT32 g_timesliceTestCount;
+
+extern UINT32 OsPriQueueTotalSize(void);
+extern void ItSuiteLosTask(void);
+
+
+#if defined(LOSCFG_TEST_SMP)
+void ItSmpLosTask001(void);
+void ItSmpLosTask002(void);
+void ItSmpLosTask003(void);
+void ItSmpLosTask004(void);
+void ItSmpLosTask021(void);
+void ItSmpLosTask022(void);
+void ItSmpLosTask023(void);
+void ItSmpLosTask025(void);
+void ItSmpLosTask026(void);
+void ItSmpLosTask027(void);
+void ItSmpLosTask028(void);
+void ItSmpLosTask029(void);
+void ItSmpLosTask030(void);
+void ItSmpLosTask031(void);
+void ItSmpLosTask032(void);
+void ItSmpLosTask033(void);
+void ItSmpLosTask034(void);
+void ItSmpLosTask035(void);
+void ItSmpLosTask036(void);
+void ItSmpLosTask037(void);
+void ItSmpLosTask038(void);
+void ItSmpLosTask039(void);
+void ItSmpLosTask040(void);
+void ItSmpLosTask041(void);
+void ItSmpLosTask042(void);
+void ItSmpLosTask043(void);
+void ItSmpLosTask044(void);
+void ItSmpLosTask045(void);
+void ItSmpLosTask046(void);
+void ItSmpLosTask047(void);
+void ItSmpLosTask048(void);
+void ItSmpLosTask049(void);
+void ItSmpLosTask050(void);
+void ItSmpLosTask051(void);
+void ItSmpLosTask052(void);
+void ItSmpLosTask053(void);
+void ItSmpLosTask054(void);
+void ItSmpLosTask055(void);
+void ItSmpLosTask056(void);
+void ItSmpLosTask057(void);
+void ItSmpLosTask058(void);
+void ItSmpLosTask059(void);
+void ItSmpLosTask060(void);
+void ItSmpLosTask061(void);
+void ItSmpLosTask062(void);
+void ItSmpLosTask063(void);
+void ItSmpLosTask064(void);
+void ItSmpLosTask065(void);
+void ItSmpLosTask066(void);
+void ItSmpLosTask067(void);
+void ItSmpLosTask068(void);
+void ItSmpLosTask069(void);
+void ItSmpLosTask070(void);
+void ItSmpLosTask071(void);
+void ItSmpLosTask073(void);
+void ItSmpLosTask074(void);
+void ItSmpLosTask076(void);
+void ItSmpLosTask077(void);
+void ItSmpLosTask078(void);
+void ItSmpLosTask079(void);
+void ItSmpLosTask081(void);
+void ItSmpLosTask082(void);
+void ItSmpLosTask084(void);
+void ItSmpLosTask087(void);
+void ItSmpLosTask088(void);
+void ItSmpLosTask089(void);
+void ItSmpLosTask090(void);
+void ItSmpLosTask091(void);
+void ItSmpLosTask092(void);
+void ItSmpLosTask093(void);
+void ItSmpLosTask094(void);
+void ItSmpLosTask095(void);
+void ItSmpLosTask096(void);
+void ItSmpLosTask097(void);
+void ItSmpLosTask098(void);
+void ItSmpLosTask099(void);
+void ItSmpLosTask100(void);
+void ItSmpLosTask101(void);
+void ItSmpLosTask102(void);
+void ItSmpLosTask103(void);
+void ItSmpLosTask104(void);
+void ItSmpLosTask105(void);
+void ItSmpLosTask106(void);
+void ItSmpLosTask107(void);
+void ItSmpLosTask108(void);
+void ItSmpLosTask109(void);
+void ItSmpLosTask110(void);
+void ItSmpLosTask111(void);
+void ItSmpLosTask112(void);
+void ItSmpLosTask114(void);
+void ItSmpLosTask115(void);
+void ItSmpLosTask117(void);
+void ItSmpLosTask126(void);
+void ItSmpLosTask127(void);
+void ItSmpLosTask128(void);
+void ItSmpLosTask129(void);
+void ItSmpLosTask130(void);
+void ItSmpLosTask131(void);
+void ItSmpLosTask132(void);
+void ItSmpLosTask133(void);
+void ItSmpLosTask134(void);
+void ItSmpLosTask135(void);
+void ItSmpLosTask136(void);
+void ItSmpLosTask137(void);
+void ItSmpLosTask138(void);
+void ItSmpLosTask139(void);
+void ItSmpLosTask141(void);
+void ItSmpLosTask142(void);
+void ItSmpLosTask143(void);
+void ItSmpLosTask144(void);
+void ItSmpLosTask145(void);
+void ItSmpLosTask146(void);
+void ItSmpLosTask147(void);
+void ItSmpLosTask148(void);
+void ItSmpLosTask149(void);
+void ItSmpLosTask150(void);
+void ItSmpLosTask151(void);
+void ItSmpLosTask152(void);
+void ItSmpLosTask153(void);
+void ItSmpLosTask154(void);
+void ItSmpLosTask155(void);
+void ItSmpLosTask156(void);
+void ItSmpLosTask157(void);
+void ItSmpLosTask158(void);
+void ItSmpLosTask159(void);
+void ItSmpLosTask161(void);
+#endif
+
+#ifdef LOSCFG_TEST_SMOKE
+void ItLosTask081(void);
+#endif
+
+#if defined(LOSCFG_TEST_SMOKE)
+void ItLosTask045(void);
+void ItLosTask046(void);
+void ItLosTask049(void);
+void ItLosTask081(void);
+void ItLosTask089(void);
+void ItLosTask097(void);
+void ItLosTask099(void);
+void ItLosTask101(void);
+void ItLosTask105(void);
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+void ItLosTask001(void);
+void ItLosTask002(void);
+void ItLosTask004(void);
+void ItLosTask007(void);
+void ItLosTask008(void);
+void ItLosTask009(void);
+void ItLosTask010(void);
+void ItLosTask011(void);
+void ItLosTask012(void);
+void ItLosTask013(void);
+void ItLosTask014(void);
+void ItLosTask015(void);
+void ItLosTask016(void);
+void ItLosTask017(void);
+void ItLosTask018(void);
+void ItLosTask019(void);
+void ItLosTask020(void);
+void ItLosTask021(void);
+void ItLosTask022(void);
+void ItLosTask023(void);
+void ItLosTask024(void);
+void ItLosTask025(void);
+void ItLosTask026(void);
+void ItLosTask027(void);
+void ItLosTask028(void);
+void ItLosTask029(void);
+void ItLosTask031(void);
+void ItLosTask032(void);
+void ItLosTask033(void);
+void ItLosTask034(void);
+void ItLosTask035(void);
+void ItLosTask036(void);
+void ItLosTask037(void);
+void ItLosTask038(void);
+void ItLosTask039(void);
+void ItLosTask040(void);
+void ItLosTask041(void);
+void ItLosTask042(void);
+void ItLosTask043(void);
+void ItLosTask047(void);
+void ItLosTask048(void);
+void ItLosTask050(void);
+void ItLosTask051(void);
+void ItLosTask052(void);
+void ItLosTask053(void);
+void ItLosTask054(void);
+void ItLosTask055(void);
+void ItLosTask056(void);
+void ItLosTask057(void);
+void ItLosTask058(void);
+void ItLosTask060(void);
+void ItLosTask061(void);
+void ItLosTask063(void);
+void ItLosTask064(void);
+void ItLosTask065(void);
+void ItLosTask066(void);
+void ItLosTask067(void);
+void ItLosTask068(void);
+void ItLosTask069(void);
+void ItLosTask071(void);
+void ItLosTask072(void);
+void ItLosTask073(void);
+void ItLosTask074(void);
+void ItLosTask075(void);
+void ItLosTask076(void);
+void ItLosTask077(void);
+void ItLosTask078(void);
+void ItLosTask079(void);
+void ItLosTask080(void);
+void ItLosTask082(void);
+void ItLosTask090(void);
+void ItLosTask092(void);
+void ItLosTask093(void);
+void ItLosTask094(void);
+void ItLosTask095(void);
+void ItLosTask096(void);
+void ItLosTask098(void);
+void ItLosTask100(void);
+void ItLosTask102(void);
+void ItLosTask103(void);
+void ItLosTask104(void);
+void ItLosTask106(void);
+void ItLosTask107(void);
+void ItLosTask108(void);
+void ItLosTask109(void);
+void ItLosTask110(void);
+void ItLosTask111(void);
+void ItLosTask112(void);
+void ItLosTask113(void);
+void ItLosTask114(void);
+void ItLosTask115(void);
+void ItLosTask116(void);
+void ItLosTask118(void);
+void ItLosTask119(void);
+void ItLosTask120(void);
+void ItLosTask121(void);
+void ItLosTask122(void);
+void ItLosTask123(void);
+void ItLosTask124(void);
+void ItLosTask125(void);
+void ItLosTask126(void);
+void ItLosTask127(void);
+void ItLosTask128(void);
+void ItLosTask129(void);
+void ItLosTask130(void);
+void ItLosTask131(void);
+void ItLosTask132(void);
+void ItLosTask133(void);
+void ItLosTask134(void);
+void ItLosTask135(void);
+void ItLosTask136(void);
+void ItLosTask138(void);
+void ItLosTaskTimeslice001(void);
+void ItLosTaskTimeslice002(void);
+void ItLosTaskTimeslice003(void);
+void ItLosTaskTimeslice004(void);
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/float/It_los_float.h b/testsuites/kernel/sample/kernel_base/core/task/float/It_los_float.h
new file mode 100644
index 0000000000000000000000000000000000000000..a8429ef48e9675efd967f83e8d74b01087f32af0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/float/It_los_float.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IT_LOS_FLOAT_H
+#define IT_LOS_FLOAT_H
+
+#include "los_base.h"
+#include "los_task.h"
+#include "los_atomic.h"
+#include "osTest.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+extern void ItSuiteLosFloat(void);
+
+#if defined(LOSCFG_TEST_SMOKE)
+#if defined(LOSCFG_TEST_SMP)
+void ItSmpLosFloatSwitch001(void);
+void ItSmpLosFloatSwitch002(void);
+void ItSmpLosFloatSwitch003(void);
+void ItSmpLosFloatSwitch004(void);
+void ItSmpLosFloatSwitch005(void);
+void ItSmpLosFloatSwitch006(void);
+void ItSmpLosFloatSwitch007(void);
+#endif
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_001.c b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..78ff1cbbe2d69129301f1f2734cf677258da419d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_001.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_float.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+static UINT32 g_sz[LOSCFG_KERNEL_CORE_NUM] = {0};
+static void TaskF01(UINT32 arg)
+{
+ UINT32 temp1 = 0xffff;
+ UINT32 temp2;
+ FLOAT a = 123.321;
+ FLOAT b = 1234.4321;
+ FLOAT c = 999.002345;
+ FLOAT d, f, e;
+ LOS_AtomicInc(&g_testCount);
+
+ while (temp1--) {
+ temp2 = 0xffff;
+ while (temp2--) {
+ d = a * b + c + temp2;
+ f = a * c + b + temp2;
+ e = a + b * c + temp2;
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ if (d != 153230.406250 + temp2) {
+ dprintf("Error:d = %f----temp = 0x%x----\n", d, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ } else if (f != 124432.390625 + temp2) {
+ dprintf("Error:f = %f----temp = 0x%x----\n", f, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ } else if (e != (1233323.875000 + temp2)) {
+ dprintf("Error:e = %f----temp = 0x%x----\n", e, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ }
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(d, 153230.406250 + temp2, temp2, EXIT);
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(f, 124432.390625 + temp2, temp2, EXIT);
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(e, 1233323.875000 + temp2, temp2, EXIT);
+ }
+ }
+
+EXIT:
+ LOS_TaskDelete(g_sz[arg]);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 i;
+ UINT32 coreIdx = 0;
+
+ g_testCount = 0;
+
+ while (coreIdx < LOSCFG_KERNEL_CORE_NUM) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_float_switch_001", TaskF01, TASK_PRIO_TEST_TASK + 1,
+ CPUID_TO_AFFI_MASK(coreIdx));
+ testTask.auwArgs[0] = coreIdx;
+ ret = LOS_TaskCreate(&g_sz[coreIdx], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ coreIdx++;
+ }
+
+ LOS_TaskDelay(100); // 100, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(g_sz[i]);
+ }
+ return LOS_OK;
+}
+#endif
+
+void ItSmpLosFloatSwitch001(void)
+{
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+ TEST_ADD_CASE("IT_SMP_LOS_FLOAT_SWITCH_001", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+#endif
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_002.c b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..b7eec4c5ba63beae6bdd1cdbd5a09ab19307d9ab
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_002.c
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_float.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+
+static UINT32 g_sz[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 g_cpuidTask1, g_cpuidTask2;
+static void TaskF01(UINT32 arg)
+{
+ UINT32 temp1 = 0xff;
+ UINT32 temp2;
+ FLOAT a = 123.321;
+ FLOAT b = 1234.4321;
+ FLOAT c = 999.002345;
+ FLOAT d, f, e;
+ LOS_AtomicInc(&g_testCount);
+
+ while (temp1--) {
+ temp2 = 0xff;
+ while (temp2--) {
+ d = a * b + c + temp2;
+ f = a * c + b + temp2;
+ e = a + b * c + temp2;
+
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ if (d != 153230.406250 + temp2) {
+ dprintf("Error:d = %f----temp = 0x%x----\n", d, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ } else if (f != 124432.390625 + temp2) {
+ dprintf("Error:f = %f----temp = 0x%x----\n", f, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ } else if (e != (1233323.875000 + temp2)) {
+ dprintf("Error:e = %f----temp = 0x%x----\n", e, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ }
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(d, 153230.406250 + temp2, temp2, EXIT);
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(f, 124432.390625 + temp2, temp2, EXIT);
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(e, 1233323.875000 + temp2, temp2, EXIT);
+ // 2, obtains the CPU ID.
+ LOS_TaskCpuAffiSet(g_testTaskID01, temp2 % 2 ? g_cpuidTask1 : g_cpuidTask2);
+ }
+ }
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static void TaskF02(UINT32 arg)
+{
+ UINT32 temp1 = 0xff;
+ UINT32 temp2;
+ FLOAT a = 123.321;
+ FLOAT b = 1234.4321;
+ FLOAT c = 999.002345;
+ FLOAT d, f, e;
+ LOS_AtomicInc(&g_testCount);
+
+ while (temp1--) {
+ temp2 = 0xffff;
+ while (temp2--) {
+ d = a * b + c + temp2;
+ f = a * c + b + temp2;
+ e = a + b * c + temp2;
+
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ if (d != 153230.406250 + temp2) {
+ dprintf("Error:d = %f----temp = 0x%x----\n", d, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ } else if (f != 124432.390625 + temp2) { // 124432.390625, numbers involved in floating-point operations, without special functions.
+ dprintf("Error:f = %f----temp = 0x%x----\n", f, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ } else if (e != (1233323.875000 + temp2)) { // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ dprintf("Error:e = %f----temp = 0x%x----\n", e, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ }
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(d, 153230.406250 + temp2, temp2, EXIT);
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(f, 124432.390625 + temp2, temp2, EXIT);
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(e, 1233323.875000 + temp2, temp2, EXIT);
+ // 2, obtains the CPU ID.
+ LOS_TaskCpuAffiSet(g_testTaskID02, temp2 % 2 ? g_cpuidTask2 : g_cpuidTask1);
+ }
+ }
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, currCpuid;
+
+ g_testCount = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ g_cpuidTask1 = ArchCurrCpuid();
+ g_cpuidTask2 = currCpuid;
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_float_switch_002_task1", TaskF01, TASK_PRIO_TEST_TASK + 1,
+ CPUID_TO_AFFI_MASK(g_cpuidTask1)); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_028_task2", TaskF02, TASK_PRIO_TEST_TASK + 2,
+ CPUID_TO_AFFI_MASK(g_cpuidTask2)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(100); // 100, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ return LOS_OK;
+}
+#endif
+
+void ItSmpLosFloatSwitch002(void)
+{
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+ TEST_ADD_CASE("IT_SMP_LOS_FLOAT_SWITCH_002", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+#endif
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_003.c b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..f4b3a9bed499df7187ea3ec301f77cdb941149dc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_003.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_float.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+
+static UINT32 g_sz[3] = {0};
+static void TaskF01(UINT32 arg)
+{
+ UINT32 temp1 = 0xff;
+ UINT32 temp2;
+ FLOAT a = 123.321;
+ FLOAT b = 1234.4321;
+ FLOAT c = 999.002345;
+ FLOAT d, f, e;
+ LOS_AtomicInc(&g_testCount);
+
+ while (temp1--) {
+ temp2 = 0xffff;
+ while (temp2--) {
+ d = a * b + c + temp2;
+ f = a * c + b + temp2;
+ e = a + b * c + temp2;
+
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ if (d != 153230.406250 + temp2) {
+ dprintf("Error:d = %f----temp = 0x%x----\n", d, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ } else if (f != 124432.390625 + temp2) {
+ dprintf("Error:f = %f----temp = 0x%x----\n", f, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ } else if (e != (1233323.875000 + temp2)) {
+ dprintf("Error:e = %f----temp = 0x%x----\n", e, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ }
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(d, 153230.406250 + temp2, temp2, EXIT);
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(f, 124432.390625 + temp2, temp2, EXIT);
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(e, 1233323.875000 + temp2, temp2, EXIT);
+ }
+ }
+
+EXIT:
+ LOS_TaskDelete(g_sz[arg]);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 i;
+ UINT32 coreIdx;
+
+ g_testCount = 0;
+
+ // 3, Number of cycles
+ for (i = 0; i < 3; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_float_switch_003", TaskF01, TASK_PRIO_TEST_TASK + 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ testTask.auwArgs[0] = i;
+ ret = LOS_TaskCreate(&g_sz[i], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(100); // 100, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(g_sz[i]);
+ }
+ return LOS_OK;
+}
+#endif
+
+void ItSmpLosFloatSwitch003(void)
+{
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+ TEST_ADD_CASE("IT_SMP_LOS_FLOAT_SWITCH_003", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+#endif
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_004.c b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..21e213e09a9dbd179fe7db7a8a519cce3f957bc9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_004.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_float.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+
+static UINT32 g_sz[3] = {0};
+static void TaskF01(void)
+{
+ UINT32 temp1 = 0xff;
+ UINT32 temp2;
+ FLOAT a = 123.321;
+ FLOAT b = 1234.4321;
+ FLOAT c = 999.002345;
+ FLOAT d, f, e;
+ LOS_AtomicInc(&g_testCount);
+
+ while (temp1--) {
+ temp2 = 0xffff;
+ while (temp2--) {
+ d = a * b + c + temp2;
+ f = a * c + b + temp2;
+ e = a + b * c + temp2;
+
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ if (d != 153230.406250 + temp2) {
+ dprintf("Error:d = %f----temp = 0x%x----\n", d, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ } else if (f != 124432.390625 + temp2) {
+ dprintf("Error:f = %f----temp = 0x%x----\n", f, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ } else if (e != (1233323.875000 + temp2)) {
+ dprintf("Error:e = %f----temp = 0x%x----\n", e, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ }
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(d, 153230.406250 + temp2, temp2, EXIT);
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(f, 124432.390625 + temp2, temp2, EXIT);
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(e, 1233323.875000 + temp2, temp2, EXIT);
+ }
+ }
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+static void HwiF01()
+{
+ FLOAT a = 123.321;
+ FLOAT b = 1234.4321;
+ DOUBLE c = 999.002345;
+ FLOAT d, f, e;
+
+ d = a * b + c;
+ // 2.34, 5.67, 1.25, numbers involved in floating-point operations, without special functions.
+ f = a * 2.34 + b * 5.67 + c * 1.25;
+ // 4.321, numbers involved in floating-point operations, without special functions.
+ e = (a + b + c) * 4.321;
+
+ g_testCount1++;
+ TestDumpCpuid();
+ return;
+}
+static void TaskF02()
+{
+ while (1) {
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_TaskDelay(2); // 2, set delay time.
+ }
+ return;
+}
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, currCpuid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testCount1 = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); // hwi to interrupt task f01
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_float_switch_004", TaskF01, TASK_PRIO_TEST_TASK + 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_float_switch_004", TaskF02, TASK_PRIO_TEST_TASK + 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu to trigger the hwi
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(100); // 100, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ ICUNIT_GOTO_NOT_EQUAL(g_testCount1, 0, g_testCount1, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+}
+#endif
+
+void ItSmpLosFloatSwitch004(void)
+{
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+ TEST_ADD_CASE("IT_SMP_LOS_FLOAT_SWITCH_004", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+#endif
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_005.c b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..07dd79a4160e644b246631069268520096eeef23
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_005.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_float.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+
+static UINT32 g_sz[3] = {0};
+static void TaskF01(void)
+{
+ UINT32 temp1 = 0xff;
+ UINT32 temp2;
+ FLOAT a = 123.321;
+ FLOAT b = 1234.4321;
+ FLOAT c = 999.002345;
+ FLOAT d, f, e;
+ LOS_AtomicInc(&g_testCount);
+
+ while (temp1--) {
+ temp2 = 0xffff;
+ while (temp2--) {
+ d = a * b + c + temp2;
+ f = a * c + b + temp2;
+ e = a + b * c + temp2;
+
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ if (d != 153230.406250 + temp2) {
+ dprintf("Error:d = %f----temp = 0x%x----\n", d, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ } else if (f != 124432.390625 + temp2) {
+ dprintf("Error:f = %f----temp = 0x%x----\n", f, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ } else if (e != (1233323.875000 + temp2)) {
+ dprintf("Error:e = %f----temp = 0x%x----\n", e, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ }
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(d, 153230.406250 + temp2, temp2, EXIT);
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(f, 124432.390625 + temp2, temp2, EXIT);
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(e, 1233323.875000 + temp2, temp2, EXIT);
+ }
+ }
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+static void HwiF01()
+{
+ FLOAT a = 123.321;
+ FLOAT b = 1234.4321;
+ DOUBLE c = 999.002345;
+ FLOAT d, f, e;
+
+ d = a * b + c;
+ // 2.34, 5.67, 1.25, numbers involved in floating-point operations, without special functions.
+ f = a * 2.34 + b * 5.67 + c * 1.25;
+ // 4.321, numbers involved in floating-point operations, without special functions.
+ e = (a + b + c) * 4.321;
+
+ g_testCount1++;
+ TestDumpCpuid();
+ return;
+}
+static void TaskF02()
+{
+ while (1) {
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_TaskDelay(2); // 2, set delay time.
+ }
+ return;
+}
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, currCpuid;
+ UINT32 i;
+
+ g_testCount = 0;
+ g_testCount1 = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); // hwi to interrupt task f01
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM))); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_float_switch_004", TaskF01, TASK_PRIO_TEST_TASK + 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_float_switch_004", TaskF02, TASK_PRIO_TEST_TASK + 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu to trigger the hwi
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(100); // 100, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ ICUNIT_GOTO_NOT_EQUAL(g_testCount1, 0, g_testCount1, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+}
+#endif
+
+void ItSmpLosFloatSwitch005(void)
+{
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+ TEST_ADD_CASE("IT_SMP_LOS_FLOAT_SWITCH_005", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+#endif
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_006.c b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..94f0a31f6f3ac2952a658c26c4576cabee999de9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_006.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_float.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+
+static void HwiF01(UINT32 arg)
+{
+ UINT32 temp2 = 0xf;
+ FLOAT a = 123.321;
+ FLOAT b = 1234.4321;
+ FLOAT c = 999.002345;
+ FLOAT d, f, e;
+ LOS_AtomicInc(&g_testCount);
+
+ while (temp2--) {
+ d = a * b + c + temp2;
+ f = a * c + b + temp2;
+ e = a + b * c + temp2;
+
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ if (d != 153230.406250 + temp2) {
+ dprintf("Error:d = %f----temp = 0x%x----\n", d, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ } else if (f != 124432.390625 + temp2) {
+ dprintf("Error:f = %f----temp = 0x%x----\n", f, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ } else if (e != (1233323.875000 + temp2)) {
+ dprintf("Error:e = %f----temp = 0x%x----\n", e, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ }
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(d, 153230.406250 + temp2, temp2, EXIT);
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(f, 124432.390625 + temp2, temp2, EXIT);
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(e, 1233323.875000 + temp2, temp2, EXIT);
+ }
+EXIT:
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, currCpuid;
+ UINT32 i;
+
+ g_testCount = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST1, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST1, CPUID_TO_AFFI_MASK(((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM))); // other cpu
+
+ // 100, Number of cycles
+ for (i = 0; i < 100; i++) {
+ TestHwiTrigger(HWI_NUM_TEST1);
+ TestHwiTrigger(HWI_NUM_TEST);
+ LOS_TaskDelay(10); // 10, set delay time.
+ }
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 200, g_testCount, EXIT); // 200, assert that g_testCount is equal to this.
+
+EXIT:
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ret = LOS_HwiDelete(HWI_NUM_TEST1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+}
+#endif
+
+void ItSmpLosFloatSwitch006(void)
+{
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+ TEST_ADD_CASE("IT_SMP_LOS_FLOAT_SWITCH_006", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+#endif
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_007.c b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..3aee9fb0462785efdbcd4a1c319d7ccec4fa0309
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/float/It_smp_los_float_switch_007.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_float.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_targetCpuid;
+
+static void HwiF01(UINT32 arg)
+{
+ UINT32 temp2 = 0xf;
+ FLOAT a = 123.321;
+ FLOAT b = 1234.4321;
+ FLOAT c = 999.002345;
+ FLOAT d, f, e;
+ LOS_AtomicInc(&g_testCount);
+
+ while (temp2--) {
+ d = a * b + c + temp2;
+ f = a * c + b + temp2;
+ e = a + b * c + temp2;
+
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ if (d != 153230.406250 + temp2) {
+ dprintf("Error:d = %f----temp = 0x%x----\n", d, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ } else if (f != 124432.390625 + temp2) {
+ dprintf("Error:f = %f----temp = 0x%x----\n", f, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ } else if (e != (1233323.875000 + temp2)) {
+ dprintf("Error:e = %f----temp = 0x%x----\n", e, temp2);
+ LOS_AtomicInc(&g_testCount);
+ continue;
+ }
+ // 153230.406250, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(d, 153230.406250 + temp2, temp2, EXIT);
+ // 124432.390625, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(f, 124432.390625 + temp2, temp2, EXIT);
+ // 1233323.875000, numbers involved in floating-point operations, without special functions.
+ ICUNIT_GOTO_EQUAL(e, 1233323.875000 + temp2, temp2, EXIT);
+ }
+EXIT:
+ return;
+}
+
+static void TaskF01(void)
+{
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, testid;
+ UINT32 i;
+
+ g_testCount = 0;
+
+ g_targetCpuid = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_INT11, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqUnmask(HWI_NUM_INT11);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_hwi_001_task", TaskF01, TASK_PRIO_TEST_TASK - 1, CPUID_TO_AFFI_MASK(i));
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ g_targetCpuid = (1 << LOSCFG_KERNEL_CORE_NUM) - 1; // all cpu
+
+ dprintf("g_targetCpuid = %d\n", g_targetCpuid);
+
+ LOS_TaskDelay(1); // 1, set delay time.
+
+ // 100, Number of cycles
+ for (i = 0; i < 100; i++) {
+ HalIrqSendIpi(g_targetCpuid, HWI_NUM_INT11);
+ LOS_TaskDelay(10); // 10, set delay time.
+ }
+
+ // 100, assert that g_testCount is equal to this.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 100 * LOSCFG_KERNEL_CORE_NUM, g_testCount);
+
+ TEST_HwiDelete(HWI_NUM_INT11);
+ return LOS_OK;
+}
+#endif
+
+void ItSmpLosFloatSwitch007(void)
+{
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+ TEST_ADD_CASE("IT_SMP_LOS_FLOAT_SWITCH_007", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+#endif
+}
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_001.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..4f751b60764b17adf5127e2eb6131077430e3531
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_001.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+
+ return;
+}
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk001A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestExtraTaskDelay(2); // 2, set delay time.(2);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return LOS_OK;
+}
+
+void ItLosTask001(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask001", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_002.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..3027d913c54b10f41579edc8d914c3372659c85b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_002.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = NULL;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk002A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_ENTRY_NULL, ret);
+
+ task1.pcName = "";
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.pcName = NULL;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NAME_EMPTY, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask002(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask002", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_004.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..5eae0c8928bc11d86e646620547d71efaf5373fb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_004.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = LOS_TASK_MIN_STACK_SIZE - sizeof(UINTPTR) * 2; // 2, Used to calculate stack space
+ task1.pcName = "Tsk004A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_STKSZ_TOO_SMALL, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask004(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask004", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_007.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..b4274ab4aa34da3b037524aaebfe23b7f50410bc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_007.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ return;
+}
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = OS_SYS_MEM_SIZE + 1;
+ task1.pcName = "Tsk007A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_STKSZ_TOO_LARGE, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask007(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask007", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_008.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..7bb9ec52208bad39c1e020e388aacc85f7b0f278
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_008.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk007A_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask008(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask008", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_009.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..e1044f24c33a1bdba2ae236c0c0642c8e900f141
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_009.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ return;
+}
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = NULL;
+ task1.usTaskPrio = 0;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ return LOS_OK;
+}
+
+void ItLosTask009(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask009", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_010.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..a3672b6228ec5de7c9ad123cb1f9c483ab76dd0e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_010.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = 0xFFFFFFFE;
+ task1.pcName = "Tsk010A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_STKSZ_TOO_LARGE, ret);
+
+ task1.uwStackSize = 0xFFFFFFF0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_STKSZ_TOO_LARGE, ret);
+
+ task1.uwStackSize = 0xFFFFFFFF;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_STKSZ_TOO_LARGE, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask010(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask010", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_011.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..0fc65c5c4460a9f894b2f3c777b09c15fa0cc641
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_011.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk011A!@#$%^&*_+~<>";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* Wait TaskF01 to start */
+ while (g_testCount == 0) {
+ }
+#endif
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask011(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask011", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_012.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..d41c6605c6329bcb93c793f475a45052199aa74b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_012.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk012A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestExtraTaskDelay(2); // 2, set delay time.(2);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask012(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask012", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_013.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..3ef8cd6c5d1878eaba24014a9e9ad9e92d7d86e7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_013.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk013A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = 0;
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestExtraTaskDelay(2); // 2, set delay time.(2);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask013(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask013", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_014.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_014.c
new file mode 100644
index 0000000000000000000000000000000000000000..ff8cee9f598c586c07ef955a109f277a24274e60
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_014.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk014A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestExtraTaskDelay(2); // 2, set delay time.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask014(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask014", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_015.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..c0b6c7e464f8de87941a6b71fb4007693ed40985
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_015.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk015A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestExtraTaskDelay(2); // 2, set delay time.(2);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask015(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask015", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_016.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_016.c
new file mode 100644
index 0000000000000000000000000000000000000000..4d8d6dadd689b1d1874bed8ccda40977a92da8ce
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_016.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF04(UINTPTR arg1, UINTPTR arg2, UINTPTR arg3, UINTPTR arg4)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(arg1, 1, arg1);
+ ICUNIT_ASSERT_EQUAL_VOID(arg2, 0xffffffff, arg2);
+ ICUNIT_ASSERT_EQUAL_VOID(arg3, -1, arg3);
+ ICUNIT_ASSERT_EQUAL_VOID(arg4, 0xffffffff, arg4);
+ g_testCount++;
+
+ return;
+}
+
+static void TaskF03(UINTPTR arg1, UINTPTR arg2, UINTPTR arg3)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(arg1, 0, arg1);
+ ICUNIT_ASSERT_EQUAL_VOID(arg2, 0xffff, arg2);
+ ICUNIT_ASSERT_EQUAL_VOID(arg3, -1, arg3);
+
+ g_testCount++;
+
+ return;
+}
+
+static void TaskF02(UINTPTR arg1, UINTPTR arg2)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(arg1, 0, arg1);
+ ICUNIT_ASSERT_EQUAL_VOID(arg2, 0xffff, arg2);
+
+ g_testCount++;
+
+ return;
+}
+static void TaskF01(UINTPTR arg1)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(arg1, 0xffff, arg1);
+
+ g_testCount++;
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk016A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ // 0xffff, initializes the args. this parameter has no special meaning.
+ task1.auwArgs[0] = 0xffff;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.auwArgs[0] = 0;
+ // 0xffff, initializes the args. this parameter has no special meaning.
+ task1.auwArgs[1] = 0xffff;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF03;
+ task1.auwArgs[0] = 0;
+ // 0xffff, initializes the args. this parameter has no special meaning.
+ task1.auwArgs[1] = 0xffff;
+ // 2, auwArgs array subscript.
+ task1.auwArgs[2] = -1;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF04;
+ task1.auwArgs[0] = 1;
+ // 0xffffffff, initializes the args. this parameter has no special meaning.
+ task1.auwArgs[1] = 0xffffffff;
+ // 2, auwArgs array subscript.
+ task1.auwArgs[2] = -1;
+ // 3, auwArgs array subscript.
+ task1.auwArgs[3] = 0xffffffff;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask016(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask016", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_017.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_017.c
new file mode 100644
index 0000000000000000000000000000000000000000..bc91737a9b9955f664b82c6ec6bf113fb2f08029
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_017.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk017A";
+ task1.usTaskPrio = 1;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+void ItLosTask017(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask017", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_018.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..26fa787fdc91418ea5bab9dce428708fef007567
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_018.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk018A";
+ task1.usTaskPrio = OS_TASK_PRIORITY_LOWEST;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask018(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask018", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_019.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..dc15e92e493466ade11f4f935e5659dbc0375e94
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_019.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk019A";
+ task1.usTaskPrio = OS_TASK_PRIORITY_LOWEST + 1;
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_PRIOR_ERROR, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask019(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask019", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_020.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..394245d289b2b8cfd5d4d21bf270e099266af284
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_020.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_PTR_NULL, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask020(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask020", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_021.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..6951e15a547b55c9de5b6730997f20dc0d929585
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_021.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk021A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(NULL, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_ID_INVALID, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask021(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask021", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_022.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..c8a2720767d64d97b118b6ad47196eabf0d497de
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_022.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ ret = LOS_TaskDelete(-1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_ID_INVALID, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask022(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask022", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_023.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..d847798eace09fe3e4cdc2c55165d5812f6a65c0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_023.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskDelete(OsGetIdleTaskId());
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask023(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask023", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_024.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_024.c
new file mode 100644
index 0000000000000000000000000000000000000000..58de01ecc749c2270e2a338ff603c268794367b1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_024.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskDelete(LOSCFG_BASE_CORE_TSK_LIMIT + 1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_ID_INVALID, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask024(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask024", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_025.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_025.c
new file mode 100644
index 0000000000000000000000000000000000000000..738d30cdad1193de5a399c47ae328cb3c6fd2467
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_025.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk025A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ ret = LOS_TaskDelete(LOSCFG_BASE_CORE_TSK_LIMIT);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_ID_INVALID, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask025(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask025", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_026.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..3fca73f68bad69f8d49e22724ce4ad3eccc01556
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_026.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskDelay(0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask026(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask026", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_027.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..28c55086fda1cc4a552981d334664ec7811d70d9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_027.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ ret = LOS_TaskDelay(1); // 1, set delay time.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask027(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask027", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_028.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_028.c
new file mode 100644
index 0000000000000000000000000000000000000000..a9d694ef43b225a89ec14f1aacc95f34272fad8e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_028.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ // 200, set delay time.
+ ret = LOS_TaskDelay(200);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask028(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask028", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_029.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..1b913a63401c150c1d4877ae669146fb6214b05f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_029.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk029A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask029(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask029", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_031.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_031.c
new file mode 100644
index 0000000000000000000000000000000000000000..1a444084297c7c482ce3e7b2db7e0deed5cd7c7e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_031.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk031A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_ALREADY_SUSPENDED, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask031(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask031", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_032.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_032.c
new file mode 100644
index 0000000000000000000000000000000000000000..e62dd195777cd9450d6b73cb46facf85bdd3f76d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_032.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskSuspend(OsGetIdleTaskId());
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ ret = LOS_TaskResume(OsGetIdleTaskId());
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask032(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask032", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_033.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_033.c
new file mode 100644
index 0000000000000000000000000000000000000000..39712122f2246671b060de42a6d8dbc46bfa44ce
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_033.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ char *taskName = NULL;
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ g_testCount++;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ char *taskName = NULL;
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task1.pcName = "Tsk033A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask033(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask033", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_034.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_034.c
new file mode 100644
index 0000000000000000000000000000000000000000..7ee7868fc261bfd55b4bbbe3a32d6b1cf40934f4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_034.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskSuspend(0xFFFFFFFF);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_ID_INVALID, ret);
+
+ ret = LOS_TaskResume(0xFFFFFFFF);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_ID_INVALID, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask034(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask034", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_035.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_035.c
new file mode 100644
index 0000000000000000000000000000000000000000..18b941a9ae163c2a68b1926a329cdb508f3c0a8a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_035.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskSuspend(0xFFFFFFFE);
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_TSK_ID_INVALID, ret);
+
+ ret = LOS_TaskResume(0xFFFFFFFE);
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_TSK_ID_INVALID, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask035(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask035", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_036.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_036.c
new file mode 100644
index 0000000000000000000000000000000000000000..e7c54821697e530f0edb1bb4bd7733e6701a7f73
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_036.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ LOS_TaskLock();
+
+ LOS_TaskUnlock();
+
+ return LOS_OK;
+}
+
+void ItLosTask036(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask036", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_037.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_037.c
new file mode 100644
index 0000000000000000000000000000000000000000..2547e4905fdc5743a8f1e59185de7833bfb65c49
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_037.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskDelay(2); // 2, set delay time.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_DELAY_IN_LOCK, ret);
+
+ LOS_TaskUnlock();
+
+ ret = LOS_TaskDelay(2); // 2, set delay time.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask037(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask037", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_038.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_038.c
new file mode 100644
index 0000000000000000000000000000000000000000..d7965f318e6ab1fec7f496c19e61bc17bf780156
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_038.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk038A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ g_testCount = 0;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ LOS_TaskLock();
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk038B";
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskUnlock();
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask038(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask038", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_039.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_039.c
new file mode 100644
index 0000000000000000000000000000000000000000..9ec8fb1477f394287a9c1078777886f50fa058c2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_039.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT8 index;
+ CHAR acName[TASK_NAME_NUM] = "Tsk";
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskID[LOSCFG_BASE_CORE_TSK_LIMIT];
+ UINT32 taskCnt;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ taskCnt = OsShellCmdTaskCntGet();
+ LOS_TaskLock();
+
+ for (index = 0; index < LOSCFG_BASE_CORE_TSK_LIMIT - taskCnt; index++) {
+ task1.usTaskPrio = index % OS_TASK_PRIORITY_LOWEST;
+ task1.pcName = acName;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ ret = LOS_TaskCreate(&testTaskID[index], &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ task1.usTaskPrio = index % OS_TASK_PRIORITY_LOWEST;
+ task1.pcName = "TskA";
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ ret = LOS_TaskCreate(&testTaskID[index], &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_TCB_UNAVAILABLE, ret, EXIT);
+EXIT:
+ for (index = 0; index < LOSCFG_BASE_CORE_TSK_LIMIT - taskCnt; index++) {
+ ret = LOS_TaskDelete(testTaskID[index]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskUnlock();
+
+ return LOS_OK;
+}
+
+void ItLosTask039(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask039", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_040.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_040.c
new file mode 100644
index 0000000000000000000000000000000000000000..005d3b834024d6f96b03579d0d7cd17448c00599
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_040.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR acName[TASK_NAME_NUM] = "";
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ LOS_TaskLock();
+ // 32, number of cycles
+ for (index = 0; index < 32; index++) {
+ task1.usTaskPrio = index;
+ snprintf(acName, 10, "Tsk040A%2d", index); // 10, snprintf size.
+ task1.pcName = acName;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskUnlock();
+
+ return LOS_OK;
+}
+
+void ItLosTask040(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask040", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_041.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_041.c
new file mode 100644
index 0000000000000000000000000000000000000000..02f46c114442c4c42a4894c4676f2810d1f6faeb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_041.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk041A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_ALREADY_SUSPENDED, ret);
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskSuspend(g_testTskHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_SUSPEND_LOCKED, ret);
+
+ LOS_TaskUnlock();
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask041(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask041", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_042.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_042.c
new file mode 100644
index 0000000000000000000000000000000000000000..21e5fa0cad97f35407d155d83a57e11735b16863
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_042.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ // 4, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 4;
+ task1.pcName = "Tsk042A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ return LOS_OK;
+EXIT:
+ LOS_TaskUnlock();
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask042(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask042", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_043.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_043.c
new file mode 100644
index 0000000000000000000000000000000000000000..881b968959691984a2bb108514dad93fd7869acf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_043.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ LOS_TaskDelay(3); // 3, set delay time.
+
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk043A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskResume(g_testTskHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_TaskDelay(30); // 30, set delay time.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask043(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask043", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_047.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_047.c
new file mode 100644
index 0000000000000000000000000000000000000000..00c359103a997f30818fb5d4a349a78fb6c85c5e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_047.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static EVENT_CB_S g_eventCb01;
+static void TaskF01(void)
+{
+ UINT32 ret;
+ g_testCount++;
+ ret = LOS_CurTaskPriSet(OS_TASK_PRIORITY_HIGHEST);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, OS_TASK_PRIORITY_HIGHEST, OsCurrTaskGet()->priority);
+ // 4, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_CurTaskPriSet(TASK_PRIO_TEST_TASK - 4);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ // 4, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, TASK_PRIO_TEST_TASK - 4, OsCurrTaskGet()->priority);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ret = LOS_CurTaskPriSet(OS_TASK_PRIORITY_LOWEST);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk047A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItLosTask047(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask047", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_048.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_048.c
new file mode 100644
index 0000000000000000000000000000000000000000..6d2443de8a6d8afd90951f4b8a8f50e161f09533
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_048.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 taskCnt;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk048A";
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ taskCnt = LOSCFG_BASE_CORE_TSK_CONFIG - OsShellCmdTaskCntGet();
+ // 4, Possible range of parameters
+ if (taskCnt >= 4)
+ // 2, Set the priority according to the task purpose
+ task1.usTaskPrio = 2;
+ // 2, 3, Possible range of parameters
+ else if ((taskCnt == 3) || (taskCnt == 2))
+ // 1, Set the priority according to the task purpose
+ task1.usTaskPrio = 1;
+ else
+ task1.usTaskPrio = 0;
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk048B";
+ task1.usTaskPrio = OS_TASK_PRIORITY_LOWEST - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelay(4); // 4, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT1); // 2, assert that g_testCount is equal to this.
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask048(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask048", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_050.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_050.c
new file mode 100644
index 0000000000000000000000000000000000000000..3352043d4f436995b78812db2d78275990ab5af0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_050.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk050B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk050A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask050(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask050", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_051.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_051.c
new file mode 100644
index 0000000000000000000000000000000000000000..567e698be1ba42242f49407389907da2025a9aea
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_051.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task1.pcName = "Tsk051B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(2); // 2, set delay time.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk051A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelay(3); // 3, set delay time.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask051(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask051", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_052.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_052.c
new file mode 100644
index 0000000000000000000000000000000000000000..9e8b569921b080de39a641ffa1ae7baf1de19eb7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_052.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk052B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk052A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask052(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask052", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_053.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_053.c
new file mode 100644
index 0000000000000000000000000000000000000000..710cae51985032b92e1a14e16c47a9d13de850bf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_053.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk053A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(20); // 20, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+void ItLosTask053(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask053", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_054.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_054.c
new file mode 100644
index 0000000000000000000000000000000000000000..09a7c3c0081acf0877923cb79959ab6094c4b80f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_054.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static void TaskF02(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk054B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk054A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, assert that g_testCount is equal to this.
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ return LOS_OK;
+}
+
+void ItLosTask054(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask054", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_055.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_055.c
new file mode 100644
index 0000000000000000000000000000000000000000..b4edf7d7a6bd1bb37131e7acc048159cbd2b65bc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_055.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ g_testCount++;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk055B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task1.pcName = "Tsk055A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_OK;
+}
+
+void ItLosTask055(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask055", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_056.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_056.c
new file mode 100644
index 0000000000000000000000000000000000000000..0f4535809535c8425579f76525897e1cace2f311
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_056.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk056B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskDelay(2); // 2, set delay time.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk056A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask056(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask056", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_057.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_057.c
new file mode 100644
index 0000000000000000000000000000000000000000..f38e21ca6bc7f3a4613565e557f0325104667d4a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_057.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk057A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk057B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask057(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask057", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_058.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_058.c
new file mode 100644
index 0000000000000000000000000000000000000000..f5684124c6f9a46ff5c2de22457c482dce6e2352
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_058.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT1); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT2); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT2);
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk058A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk058B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask058(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask058", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_060.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_060.c
new file mode 100644
index 0000000000000000000000000000000000000000..6673370ba374740297281e7f5a7bc7cb07f44426
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_060.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk060A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk060B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask060(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask060", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_061.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_061.c
new file mode 100644
index 0000000000000000000000000000000000000000..59a683a0400e8db280e1ddc82fde5d5f58b173c8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_061.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, assert that g_testCount is equal to this.
+
+ g_testCount++;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk061A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk061B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT2); // 6, assert that g_testCount is equal to this.
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+EXIT2:
+ TEST_HwiDelete(HWI_NUM_TEST);
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask061(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask061", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_063.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_063.c
new file mode 100644
index 0000000000000000000000000000000000000000..922a2f9932c449d9ac62a747c92860b8423f0625
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_063.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 index;
+ int value;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+ HAL_READ_UINT32(&g_testCount, value);
+
+ while (value != 4) { // 4, assert value .
+ HAL_READ_UINT32(&g_testCount, value);
+ }
+
+ HAL_READ_UINT32(&g_testCount, value);
+ g_testCount = value;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static void TaskF01(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ LOS_TaskDelay(5); // 5, set delay time.
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk063A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk063B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask063(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask063", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_064.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_064.c
new file mode 100644
index 0000000000000000000000000000000000000000..2571a8455823365c913cab334bd898dd88e81127
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_064.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ UINT32 index;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ for (index = 0; index < TASK_LOOP_NUM; index++) {
+ }
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk064B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(5); // 5, set delay time.
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk064A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_HwiTriggerDelay;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT2); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT2); // 6, assert that g_testCount is equal to this.
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+EXIT2:
+ TEST_HwiDelete(HWI_NUM_TEST);
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask064(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask064", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_065.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_065.c
new file mode 100644
index 0000000000000000000000000000000000000000..ed904307f4674daa6b6af5a414938f7fc3057c5e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_065.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk065B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk065A";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask065(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask065", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_066.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_066.c
new file mode 100644
index 0000000000000000000000000000000000000000..b5509d4d16f382dd44b209ed1b4b35b9701cfc62
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_066.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF03(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID03);
+}
+
+static void TaskF02(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk066B";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF03;
+ task1.pcName = "Tsk066C";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID03, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk066A";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask066(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask066", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_067.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_067.c
new file mode 100644
index 0000000000000000000000000000000000000000..5d1a7f05769154071c8e2889f322f05e8d8ff604
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_067.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_NOT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk067B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk067A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask067(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask067", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_068.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_068.c
new file mode 100644
index 0000000000000000000000000000000000000000..93a1149f48b9db2b9fd9693cac56c904cf611178
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_068.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_NOT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk068B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk068A";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask068(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask068", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_069.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_069.c
new file mode 100644
index 0000000000000000000000000000000000000000..fd08e7ffd655793ca17dab0153427466fac4fd06
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_069.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk069B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID02);
+ ICUNIT_ASSERT_NOT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk069A";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItLosTask069(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask069", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_071.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_071.c
new file mode 100644
index 0000000000000000000000000000000000000000..5d043d0ec1f7a315a4d5b7290667cbf6b21306e2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_071.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk071A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT1);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT2);
+
+ return LOS_OK;
+
+EXIT1:
+ LOS_TaskUnlock();
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+EXIT3:
+ LOS_TaskUnlock();
+
+ return LOS_OK;
+}
+
+void ItLosTask071(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask071", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_072.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_072.c
new file mode 100644
index 0000000000000000000000000000000000000000..ae27bf8b42f26b2e4a56d9ae05c090e11dd212dc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_072.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk072A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ LOS_TaskUnlock();
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT2);
+
+ LOS_TaskUnlock();
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT3);
+
+ return LOS_OK;
+
+EXIT1:
+ LOS_TaskUnlock();
+ LOS_TaskUnlock();
+
+ return LOS_OK;
+EXIT2:
+ LOS_TaskUnlock();
+EXIT3:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask072(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask072", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_073.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_073.c
new file mode 100644
index 0000000000000000000000000000000000000000..7e0cb5dd6d72adfff52e5197d76e603cb513880c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_073.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT2); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk073A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk073B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT1);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+EXIT2:
+ LOS_TaskUnlock();
+
+ return LOS_OK;
+}
+
+void ItLosTask073(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask073", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_074.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_074.c
new file mode 100644
index 0000000000000000000000000000000000000000..e8a003d4c35773549a557c419897ea39efce1f8d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_074.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2; // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.pcName = "Tsk074A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskUnlock();
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask074(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask074", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_075.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_075.c
new file mode 100644
index 0000000000000000000000000000000000000000..9d9a81ba0586c09a16b0651a6861a0850b28a9d9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_075.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ int value;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
+ g_testCount++;
+
+ HAL_READ_UINT32(&g_testCount, value);
+
+ while (value <= 2) { // 2, Waiting for the change of value.
+ HAL_READ_UINT32(&g_testCount, value);
+ }
+
+ HAL_READ_UINT32(&g_testCount, value);
+ g_testCount = value;
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT2); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskDelay(1); // 1, set delay time.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk075A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ ret = LOS_TaskDelay(2); // 2, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_DELAY_IN_LOCK, ret, EXIT2);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT2);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk075B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = LOS_TaskDelay(2); // 2, set delay time.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_DELAY_IN_LOCK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT1);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+EXIT3:
+ LOS_TaskLock();
+ return LOS_OK;
+}
+
+void ItLosTask075(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask075", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_076.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_076.c
new file mode 100644
index 0000000000000000000000000000000000000000..2074443e3a7690b1c98ce9d801985f4dd698c8b5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_076.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskDelay(0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk076A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk076B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT1);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+EXIT3:
+ LOS_TaskUnlock();
+ return LOS_OK;
+}
+
+void ItLosTask076(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask076", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_077.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_077.c
new file mode 100644
index 0000000000000000000000000000000000000000..0c0dc6eaa352cd4454d86431aadb7cd6e1cb790a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_077.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF03(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID03);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk077A";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk077B";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF03;
+ task1.pcName = "Tsk077C";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID03);
+
+ return LOS_OK;
+}
+
+void ItLosTask077(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask077", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_078.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_078.c
new file mode 100644
index 0000000000000000000000000000000000000000..1c02aa73573563f21c2fc64b7b75709453e9e7c5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_078.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+ LOS_TaskLock();
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_DELETE_LOCKED, ret, EXIT);
+
+ LOS_TaskUnlock();
+
+ g_testCount++;
+
+EXIT:
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk078A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ return LOS_OK;
+}
+
+void ItLosTask078(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask078", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_079.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_079.c
new file mode 100644
index 0000000000000000000000000000000000000000..885f2c15d3e537f6e8baf391d059724ae2133a64
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_079.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+ ret = LOS_SemPend(g_semID, 0x2);
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_SEM_TIMEOUT, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT:
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk079A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(3); // 3, set delay time.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItLosTask079(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask079", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_080.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_080.c
new file mode 100644
index 0000000000000000000000000000000000000000..b2209d73e3b8a9b7ab5c27a41992f1d16536ede6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_080.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LOS_TaskYield();
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_YIELD_IN_INT, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ HWI_PRIOR_T hwiPrio = 3;
+ HWI_MODE_T mode = 0;
+ HWI_ARG_T arg = 0;
+
+ g_testCount = 0;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, (HwiIrqParam *)arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+}
+
+void ItLosTask080(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask080", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_082.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_082.c
new file mode 100644
index 0000000000000000000000000000000000000000..f270941a71dd16d36ec249b86e29ca12e14d38f0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_082.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static EVENT_CB_S g_eventCb01;
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_eventCb01, 0x11, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x1, ret, EXIT);
+ g_testCount++;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ LOS_EventInit(&g_eventCb01);
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "Tsk082A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_EventWrite(&g_eventCb01, 0x80000000);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_EventWrite(&g_eventCb01, 0x1);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItLosTask082(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask082", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_090.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_090.c
new file mode 100644
index 0000000000000000000000000000000000000000..3154d94528cc9df872dcf5124c50a35cc8115816
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_090.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+ ret = LOS_TaskYield();
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk090A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ LOS_TaskLock();
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk090B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask090(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask090", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_092.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_092.c
new file mode 100644
index 0000000000000000000000000000000000000000..c04bf8d899e7499aff51c6a80182bc7d70cbad1c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_092.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = LOS_TASK_MIN_STACK_SIZE + 1;
+ task1.pcName = "Tsk092A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItLosTask092(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask092", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_093.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_093.c
new file mode 100644
index 0000000000000000000000000000000000000000..6bcfc35084fc5a1949a78eacfb663038481702e3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_093.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff1, sizeof(UINTPTR), 0xff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT:
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ // 3, queue len.
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR));
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk093A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItLosTask093(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask093", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_094.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_094.c
new file mode 100644
index 0000000000000000000000000000000000000000..c3712a2b3251457224c44957c34979ddcfa4a9ee
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_094.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF03(UINTPTR arg1, UINTPTR arg2, UINTPTR arg3, UINTPTR arg4)
+{
+ g_testCount++;
+
+ ICUNIT_GOTO_EQUAL(arg1, 1, arg1, EXIT);
+ ICUNIT_GOTO_EQUAL(arg2, 0xffff, arg2, EXIT);
+ ICUNIT_GOTO_EQUAL(arg3, -1, arg3, EXIT);
+ ICUNIT_GOTO_EQUAL(arg4, 0xffffffff, arg4, EXIT);
+EXIT:
+ return;
+}
+
+static void TaskF02(UINTPTR arg1, UINTPTR arg2)
+{
+ ICUNIT_GOTO_EQUAL(arg1, 0, arg1, EXIT);
+ ICUNIT_GOTO_EQUAL(arg2, 0xffff, arg2, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ return;
+}
+
+static void TaskF01(UINTPTR arg1)
+{
+ ICUNIT_GOTO_EQUAL(arg1, 0xffff, arg1, EXIT);
+
+ g_testCount++;
+EXIT:
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk094A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = 0;
+ // 0xffff, initializes the args. this parameter has no special meaning.
+ task1.auwArgs[0] = 0xffff;
+ task1.processID = LOS_GetCurrProcessID();
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ task1.processID = LOS_GetCurrProcessID();
+ ret = LOS_TaskCreateOnly(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SetTaskScheduler(g_testTaskID01, LOS_SCHED_RR, task1.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.auwArgs[0] = 0;
+ // 0xffff, initializes the args. this parameter has no special meaning.
+ task1.auwArgs[1] = 0xffff;
+ task1.pcName = "Tsk094B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.processID = LOS_GetCurrProcessID();
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ task1.processID = LOS_GetCurrProcessID();
+ ret = LOS_TaskCreateOnly(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_SetTaskScheduler(g_testTaskID02, LOS_SCHED_RR, task1.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF03;
+ task1.auwArgs[0] = 1;
+ // 0xffff, initializes the args. this parameter has no special meaning.
+ task1.auwArgs[1] = 0xffff;
+ // 2, auwArgs array subscript.
+ task1.auwArgs[2] = -1;
+ // 3, auwArgs array subscript.
+ task1.auwArgs[3] = 0xffffffff;
+ task1.pcName = "Tsk094C";
+ // 4, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 4;
+ task1.processID = LOS_GetCurrProcessID();
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ task1.processID = LOS_GetCurrProcessID();
+ ret = LOS_TaskCreateOnly(&g_testTaskID03, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_SetTaskScheduler(g_testTaskID03, LOS_SCHED_RR, task1.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID03);
+ return LOS_OK;
+}
+
+void ItLosTask094(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask094", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_095.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_095.c
new file mode 100644
index 0000000000000000000000000000000000000000..ffde8962c0cbd77382d72a4c3c85c73e17d6373f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_095.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk095A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ task1.processID = LOS_GetCurrProcessID();
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ task1.processID = LOS_GetCurrProcessID();
+
+ g_testCount = 0;
+ ret = LOS_TaskCreateOnly(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SetTaskScheduler(g_testTaskID01, LOS_SCHED_RR, task1.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ret = LOS_TaskCreateOnly(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask095(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask095", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_096.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_096.c
new file mode 100644
index 0000000000000000000000000000000000000000..09be07083475f5b2deb4e74a3f667599c7c7c665
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_096.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ g_testCount++;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk059B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk096A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = 0;
+ task1.processID = LOS_GetCurrProcessID();
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ task1.processID = LOS_GetCurrProcessID();
+ g_testCount = 0;
+ ret = LOS_TaskCreateOnly(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SetTaskScheduler(g_testTaskID01, LOS_SCHED_RR, task1.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask096(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask096", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_098.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_098.c
new file mode 100644
index 0000000000000000000000000000000000000000..0be50c2c4cbce3f2ae94573aff559047fbb71919
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_098.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ g_testCount++;
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk098B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ task1.processID = LOS_GetCurrProcessID();
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ task1.processID = LOS_GetCurrProcessID();
+ ret = LOS_TaskCreateOnly(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SetTaskScheduler(g_testTaskID02, LOS_SCHED_RR, task1.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
+ g_testCount++;
+ return;
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk098A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+ task1.processID = LOS_GetCurrProcessID();
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ task1.processID = LOS_GetCurrProcessID();
+ g_testCount = 0;
+
+ ret = LOS_TaskCreateOnly(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SetTaskScheduler(g_testTaskID01, LOS_SCHED_RR, task1.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask098(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask098", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_100.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_100.c
new file mode 100644
index 0000000000000000000000000000000000000000..6cbc00f24a2163fe5dfdebfb7f2a9d3c7c31c7a3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_100.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk100A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ g_testTaskID01 = 0xffff;
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, (UINT16)OS_INVALID, ret);
+
+ ret = LOS_TaskPriGet(g_taskMaxNum + 1);
+ ICUNIT_GOTO_EQUAL(ret, (UINT16)OS_INVALID, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, (UINT16)OS_INVALID, ret);
+
+ return LOS_OK;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask100(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask100", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_102.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_102.c
new file mode 100644
index 0000000000000000000000000000000000000000..b6669305f2b106881236f6f5febfcfba6716f0c8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_102.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk102A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+void ItLosTask102(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask102", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_103.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_103.c
new file mode 100644
index 0000000000000000000000000000000000000000..46ac159b7abc76e956208ab1f238d9476f0aadbf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_103.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk103B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskPriGet(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk103A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask103(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask103", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_104.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_104.c
new file mode 100644
index 0000000000000000000000000000000000000000..3d5b1923408bb20733bd0c7aeae6eacbbb8460dc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_104.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_TaskPriGet(g_testTaskID02);
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 3, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk104B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
+
+ ret = LOS_TaskPriGet(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(ret, (UINT16)OS_INVALID, ret, EXIT1);
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk104A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask104(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask104", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_106.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_106.c
new file mode 100644
index 0000000000000000000000000000000000000000..ad16613823a08465b0a0c0a64db43910d7d2fee0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_106.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_TaskPriSet(g_testTaskID02, TASK_PRIO_TEST_TASK - 2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskPriGet(g_testTaskID02);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk106A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Tsk106B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+
+ LOS_TaskUnlock();
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT2); // 5, assert that g_testCount is equal to this.
+
+EXIT2:
+ TEST_HwiDelete(HWI_NUM_TEST);
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask106(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask106", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_107.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_107.c
new file mode 100644
index 0000000000000000000000000000000000000000..6674235ddaffb38da0624b227096542cbf9711fc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_107.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ g_testCount++;
+
+ // 4, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_TaskPriSet(g_testTaskID02, TASK_PRIO_TEST_TASK - 4);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk107B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskPriGet(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, (UINT16)OS_INVALID, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk107A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask107(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask107", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_108.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_108.c
new file mode 100644
index 0000000000000000000000000000000000000000..72c0b976ffb26563dcb40a647eaabe1c934e1d83
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_108.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_TaskPriSet(g_testTaskID02, TASK_PRIO_TEST_TASK - 1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk108B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskPriGet(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk108A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask108(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask108", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_109.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_109.c
new file mode 100644
index 0000000000000000000000000000000000000000..627369e7f9e4d1137c871b3df14529ce0a2490c9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_109.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk109B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk109A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask109(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask109", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_110.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_110.c
new file mode 100644
index 0000000000000000000000000000000000000000..bdf1791fb785c8e75a0bdfeee7e5afb23a8007a9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_110.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ // 4, Used to calculate priority
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 4);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk110B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 4, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 4, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk110A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask110(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask110", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_111.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_111.c
new file mode 100644
index 0000000000000000000000000000000000000000..5fd53d2cc778a58970ba6ec02ea643ba30ba8228
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_111.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ g_testCount++;
+
+ // 3, Used to calculate priority.
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 3);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk111B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3; // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 3, ret);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk111A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask111(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask111", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_112.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_112.c
new file mode 100644
index 0000000000000000000000000000000000000000..62d01f3f0d39bd6fcc4b94da3263acf1ff2f5b9e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_112.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_TaskPriSet(g_testTaskID02, TASK_PRIO_TEST_TASK - 1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk112B";
+ // 4, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 4;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ ret = LOS_TaskPriGet(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(ret, TASK_PRIO_TEST_TASK - 1, ret, EXIT);
+
+ // 4, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_TaskPriSet(g_testTaskID02, TASK_PRIO_TEST_TASK - 4);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk112A";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(15); // 15, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask112(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask112", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_113.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_113.c
new file mode 100644
index 0000000000000000000000000000000000000000..bfc87872aa786f4e9f659a8c2e02a5bfa3ec42ec
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_113.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ g_testCount++;
+
+ ret = LOS_TaskPriGet(g_testTaskID02);
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_GOTO_EQUAL(ret, TASK_PRIO_TEST_TASK - 3, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk113B";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_TaskPriSet(g_testTaskID02, TASK_PRIO_TEST_TASK - 3);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk113A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask113(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask113", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_114.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_114.c
new file mode 100644
index 0000000000000000000000000000000000000000..2eb472f204e85bafc559d694502fffcdb4675cc3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_114.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_CurTaskPriSet(TASK_PRIO_TEST_TASK - 3);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+EXIT:
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ HWI_PRIOR_T hwiPrio = 3;
+ HWI_MODE_T mode = 0;
+ HWI_ARG_T arg = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, (HwiIrqParam *)arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_GOTO_EQUAL(ret, TASK_PRIO_TEST_TASK - 3, ret, EXIT1);
+
+EXIT1:
+ TEST_HwiDelete(HWI_NUM_TEST);
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk114A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask114(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask114", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_115.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_115.c
new file mode 100644
index 0000000000000000000000000000000000000000..2677f9188c475a1d5630ec044d2d743cd5803196
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_115.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ g_testCount++;
+
+ LOS_TaskLock();
+
+ ret = LOS_CurTaskPriSet(TASK_PRIO_TEST_TASK - 1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk078B";
+ // 4, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 4;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskPriGet(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(ret, TASK_PRIO_TEST_TASK - 1, ret, EXIT);
+
+ // 4, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_TaskPriSet(g_testTaskID02, TASK_PRIO_TEST_TASK - 4);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk078A";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(15); // 15, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask115(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask115", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_116.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_116.c
new file mode 100644
index 0000000000000000000000000000000000000000..b1e2806cdfcf6cdcb8a58911bbda7c83e5f74444
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_116.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void SwtmrF01(UINTPTR arg)
+{
+ UINT32 ret;
+ if (arg != 0xffff) {
+ return;
+ }
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_CurTaskPriSet(TASK_PRIO_TEST_TASK - 3);
+
+ g_testCount++;
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+
+ // 2, Used to set swtmr
+ ret = LOS_SwtmrCreate(2, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
+ g_testCount++;
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_GOTO_EQUAL(ret, TASK_PRIO_TEST_TASK - 2, ret, EXIT);
+
+#if SELF_DELETED
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return;
+#endif
+ return;
+
+EXIT1:
+ LOS_SwtmrDelete(swTmrID);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk116A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask116(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask116", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_118.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_118.c
new file mode 100644
index 0000000000000000000000000000000000000000..85531ef9bf0ff9888ef1aea288c9a88dc00ad1e8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_118.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sumSize;
+static void *g_ptr1 = NULL;
+static void *g_ptr2 = NULL;
+extern UINT32 OsTaskMemUsage(UINT32 taskID);
+static void HwiF01(void)
+{
+ UINT32 size = 2;
+ UINT32 ret;
+ UINT32 sumSize;
+ g_ptr1 = LOS_MemAlloc((void *)OS_SYS_MEM_ADDR, size);
+ ICUNIT_GOTO_NOT_EQUAL(g_ptr1, NULL, g_ptr1, EXIT);
+ sumSize = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(sumSize, g_sumSize, sumSize, EXIT);
+ LOS_MemFree((void *)OS_SYS_MEM_ADDR, g_ptr1);
+ sumSize = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(sumSize, g_sumSize, sumSize, EXIT);
+EXIT:
+ TEST_HwiClear(HWI_NUM_TEST);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ UINT32 sumSize;
+
+ LOS_MemFree((void *)OS_SYS_MEM_ADDR, g_ptr2);
+ sumSize = OsTaskMemUsage(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(sumSize, 0, sumSize, EXIT);
+ sumSize = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(sumSize, 0, sumSize, EXIT);
+
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ UINT32 sumSize1, sumSize2;
+ UINT32 size = 2;
+ HWI_PRIOR_T hwiPrio = 3;
+ HWI_MODE_T mode = 0;
+ HWI_ARG_T arg = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ g_sumSize = OsTaskMemUsage(g_testTaskID01);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ g_ptr2 = LOS_MemAlloc((void *)OS_SYS_MEM_ADDR, size);
+ ICUNIT_GOTO_NOT_EQUAL(g_ptr2, NULL, g_ptr2, EXIT);
+ sumSize1 = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_NOT_EQUAL(sumSize1, 0, sumSize1, EXIT);
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ size = 0x200;
+ g_ptr1 = LOS_MemAlloc((void *)OS_SYS_MEM_ADDR, size);
+ ICUNIT_GOTO_NOT_EQUAL(g_ptr1, NULL, g_ptr1, EXIT);
+ sumSize1 = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_NOT_EQUAL(sumSize1, 0, sumSize1, EXIT);
+
+ size = 0x2;
+ g_ptr2 = LOS_MemAlloc((void *)OS_SYS_MEM_ADDR, size);
+ ICUNIT_GOTO_NOT_EQUAL(g_ptr2, NULL, g_ptr2, EXIT);
+ sumSize2 = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_NOT_EQUAL(sumSize2, sumSize1, sumSize2, EXIT);
+
+ LOS_MemFree((void *)OS_SYS_MEM_ADDR, g_ptr2);
+ sumSize2 = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(sumSize2, sumSize1, sumSize2, EXIT);
+
+ LOS_MemFree((void *)OS_SYS_MEM_ADDR, g_ptr1);
+ sumSize2 = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(sumSize2, 0, sumSize2, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk118A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk118B";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_OK;
+}
+
+void ItLosTask118(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask118", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_119.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_119.c
new file mode 100644
index 0000000000000000000000000000000000000000..467c8d390ccb624238092edcc1852fab9f5ce6bf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_119.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_119";
+ // 32, Set the priority according to the task purpose
+ task1.usTaskPrio = 32;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_PRIOR_ERROR, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask119(void)
+{
+ TEST_ADD_CASE("ItLosTask119", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_120.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_120.c
new file mode 100644
index 0000000000000000000000000000000000000000..d1f4a1e44eacc2619f80ea822178c9b8a09798c6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_120.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return;
+EXIT:
+ g_testCount = 0;
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = NULL;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST; // TASK_STACK_SIZE_TEST = 1024
+ task1.pcName = "Task_120";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_ENTRY_NULL, ret, EXIT);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "";
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ task1.pcName = "Task_120";
+ task1.uwStackSize = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(task1.uwStackSize, LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE, task1.uwStackSize, EXIT);
+
+ TestExtraTaskDelay(2); // 2, set delay time.(2);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask120(void)
+{
+ TEST_ADD_CASE("ItLosTask120", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_121.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_121.c
new file mode 100644
index 0000000000000000000000000000000000000000..0e8aef7f3c5e85e67c583ebbe3b6f92b2f427c91
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_121.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = 0x101;
+ task1.pcName = "Task_121";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_STKSZ_TOO_SMALL, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask121(void)
+{
+ TEST_ADD_CASE("ItLosTask121", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_122.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_122.c
new file mode 100644
index 0000000000000000000000000000000000000000..94d362866cafc5a84ee7b362ee44b0e3bb6fa694
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_122.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_122_1";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_122";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask122(void)
+{
+ TEST_ADD_CASE("ItLosTask122", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_123.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_123.c
new file mode 100644
index 0000000000000000000000000000000000000000..f2636d2c4aa4d508cb1571bcda69b05a36bd0f66
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_123.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ g_testCount++;
+
+ while (1) {
+ }
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_123_1";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_TaskDelay(2); // 2, set delay time.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_123";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask123(void)
+{
+ TEST_ADD_CASE("ItLosTask123", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_124.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_124.c
new file mode 100644
index 0000000000000000000000000000000000000000..d51caa7c943dd540f7fa8903ab4f9ff84eb2b73d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_124.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ INT32 ret;
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_124_1";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_124";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItLosTask124(void)
+{
+ TEST_ADD_CASE("ItLosTask124", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_125.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_125.c
new file mode 100644
index 0000000000000000000000000000000000000000..24b56ca1e8f3e2b545fbeca39b4048e90974ebea
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_125.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ return;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_125";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_HwiTriggerDelay;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TEST_HwiTriggerDelay;
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask125(void)
+{
+ TEST_ADD_CASE("ItLosTask125", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_126.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_126.c
new file mode 100644
index 0000000000000000000000000000000000000000..030ac91e114b14329d91cf6d234ca8ee245b27a2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_126.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+}
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LOS_TaskSuspend(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ return;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_126_1";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
+
+ g_testCount++;
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT2:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_126";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return LOS_OK;
+}
+
+void ItLosTask126(void)
+{
+ TEST_ADD_CASE("ItLosTask126", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_127.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_127.c
new file mode 100644
index 0000000000000000000000000000000000000000..c9ed5a99cb0624b1d1e4392405da8dd71e6063b9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_127.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ g_testCount++;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_127_1";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskSuspend(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_127";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_OK;
+}
+
+void ItLosTask127(void)
+{
+ TEST_ADD_CASE("ItLosTask127", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_128.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_128.c
new file mode 100644
index 0000000000000000000000000000000000000000..04614748e594f66009ec3888ef50b2d4c276986d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_128.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ UINT32 index;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ for (index = 0; index < 0x1000; index++) {
+ }
+
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_128_1";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_TaskDelay(2); // 2, set delay time.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_128";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask128(void)
+{
+ TEST_ADD_CASE("ItLosTask128", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_129.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_129.c
new file mode 100644
index 0000000000000000000000000000000000000000..c80a883e59fda0eba73425cb9cdee815d816ede6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_129.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ return;
+}
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_129_1";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_YIELD_IN_INT, ret, EXIT);
+
+EXIT:
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ g_testCount = 0;
+ g_testCount++;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ret = LOS_TaskDelay(1); // 1, set delay time.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+void ItLosTask129(void)
+{
+ TEST_ADD_CASE("ItLosTask129", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_130.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_130.c
new file mode 100644
index 0000000000000000000000000000000000000000..1af58128ee9627d206012199c271781f8ca2b2d7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_130.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT1); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT2); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT2);
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_130";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Task_130_1";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask130(void)
+{
+ TEST_ADD_CASE("ItLosTask130", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_131.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_131.c
new file mode 100644
index 0000000000000000000000000000000000000000..136011b10b1733656bc45115de48a47488dc7267
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_131.c
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT1); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ret = LOS_TaskDelay(1); // 1, set delay time.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT2); // 5, assert that g_testCount is equal to this.
+
+ g_testCount++;
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT2);
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT1); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_131";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "Task_131_1";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(1); // 1, set delay time.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 6, g_testCount); // 6, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask131(void)
+{
+ TEST_ADD_CASE("ItLosTask131", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_132.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_132.c
new file mode 100644
index 0000000000000000000000000000000000000000..a0728a9d520bebf1ebbf3914673096e281495057
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_132.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ g_swTmrID = OsPercpuGet()->swtmrTaskID;
+
+ ret = LOS_TaskSuspend(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ ret = LOS_TaskResume(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask132(void)
+{
+ TEST_ADD_CASE("ItLosTask132", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_133.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_133.c
new file mode 100644
index 0000000000000000000000000000000000000000..a607f4f84ce8524983c5f70ee9f412f06308e87a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_133.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ ret = LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 taskID02;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ LOS_TaskLock();
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_133";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&taskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskUnlock();
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ ret = LOS_TaskDelete(taskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask133(void)
+{
+ TEST_ADD_CASE("ItLosTask133", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_134.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_134.c
new file mode 100644
index 0000000000000000000000000000000000000000..ceb015fc4dae312cd164f1f04bf42c641db96f83
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_134.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_134__";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 3;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ return LOS_OK;
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ return LOS_OK;
+}
+
+void ItLosTask134(void)
+{
+ TEST_ADD_CASE("ItLosTask134", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_135.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_135.c
new file mode 100644
index 0000000000000000000000000000000000000000..03f5ba0c1c017cd7a732a57bd240aef1c41259ce
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_135.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ g_testCount = 0;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk138A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ ret = LOS_TaskResume(OsGetIdleTaskId());
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ ret = LOS_TaskResume(LOSCFG_BASE_CORE_TSK_LIMIT + 1);
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_TSK_ID_INVALID, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask135(void)
+{
+ TEST_ADD_CASE("ItLosTask135", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_136.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_136.c
new file mode 100644
index 0000000000000000000000000000000000000000..78e86856a8d5ed6a4c28d01cd5024a3cee5f4e7b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_136.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+ return;
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskSuspend(g_testTaskID02);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret, i;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ TSK_INIT_PARAM_S task2 = { 0 };
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Task_136_1";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.pcName = "Task_136_2";
+ task2.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task2.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task2.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ for (i = 0; i < IT_TASK_SMP_LOOP; i++) {
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskResume(g_testTaskID02);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskUnlock();
+ }
+
+ LOS_TaskDelay(1); // 1, set delay time.
+
+ return LOS_OK;
+}
+
+void ItLosTask136(void)
+{
+ TEST_ADD_CASE("ItLosTask136", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_138.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_138.c
new file mode 100644
index 0000000000000000000000000000000000000000..74aa61fb9bec43b3d84c00f994409fed87734342
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_138.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sumSize;
+static void *g_ptr1 = NULL;
+static void *g_ptr2 = NULL;
+extern UINT32 OsTaskMemUsage(UINT32 taskID);
+static void HwiF01(void)
+{
+ UINT32 size = 2;
+ UINT32 ret;
+ UINT32 sumSize;
+ g_ptr1 = LOS_MemAlloc((void *)OS_SYS_MEM_ADDR, size);
+ ICUNIT_GOTO_NOT_EQUAL(g_ptr1, NULL, g_ptr1, EXIT);
+ sumSize = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(sumSize, g_sumSize, sumSize, EXIT);
+ LOS_MemFree((void *)OS_SYS_MEM_ADDR, g_ptr1);
+ sumSize = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(sumSize, g_sumSize, sumSize, EXIT);
+EXIT:
+ TEST_HwiClear(HWI_NUM_TEST);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ UINT32 sumSize;
+
+ LOS_MemFree((void *)OS_SYS_MEM_ADDR, g_ptr2);
+ sumSize = OsTaskMemUsage(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(sumSize, 0, sumSize, EXIT);
+ sumSize = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(sumSize, 0, sumSize, EXIT);
+
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ return;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ UINT32 sumSize1, sumSize2;
+ UINT32 size = 2;
+ HWI_PRIOR_T hwiPrio = 3;
+ HWI_MODE_T mode = 0;
+ HWI_ARG_T arg = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, (HwiIrqParam *)arg);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ g_sumSize = OsTaskMemUsage(g_testTaskID01);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ g_ptr2 = LOS_MemAlloc((void *)OS_SYS_MEM_ADDR, size);
+ ICUNIT_GOTO_NOT_EQUAL(g_ptr2, NULL, g_ptr2, EXIT);
+ sumSize1 = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_NOT_EQUAL(sumSize1, 0, sumSize1, EXIT);
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ size = 0x200;
+ g_ptr1 = LOS_MemAlloc((void *)OS_SYS_MEM_ADDR, size);
+ ICUNIT_GOTO_NOT_EQUAL(g_ptr1, NULL, g_ptr1, EXIT);
+ sumSize1 = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_NOT_EQUAL(sumSize1, 0, sumSize1, EXIT);
+
+ size = 0x2;
+ g_ptr2 = LOS_MemAlloc((void *)OS_SYS_MEM_ADDR, size);
+ ICUNIT_GOTO_NOT_EQUAL(g_ptr2, NULL, g_ptr2, EXIT);
+ sumSize2 = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_NOT_EQUAL(sumSize2, sumSize1, sumSize2, EXIT);
+
+ LOS_MemFree((void *)OS_SYS_MEM_ADDR, g_ptr2);
+ sumSize2 = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(sumSize2, sumSize1, sumSize2, EXIT);
+
+ LOS_MemFree((void *)OS_SYS_MEM_ADDR, g_ptr1);
+ sumSize2 = OsTaskMemUsage(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(sumSize2, 0, sumSize2, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk118A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk118B";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_OK;
+}
+
+void ItLosTask138(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask138", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_141.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_141.c
new file mode 100644
index 0000000000000000000000000000000000000000..8e56235ae2382b147596aaafc48211740bbddf58
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_141.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#ifndef TESTHI1980IMU
+
+static EVENT_CB_S g_eventCb01;
+static UINT32 g_fpsrc01;
+static UINT32 g_fpsrc02;
+static UINT32 g_fpsrc03;
+
+__attribute__((noinline, used, optimize("-O0"))) static void FloatTestInTask()
+{
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+ float d1 = 100.0f;
+ UINT32 n1 = 0;
+
+ __asm__("vldr s15, %0" ::"m"(d1));
+ __asm__("vcmp.f32 s15, #0");
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ g_testCount++;
+
+ __asm__ __volatile__("vmrs %0, fpscr\n" : "=r"(n1)::); // n1 is fpscr
+ g_fpsrc01 = n1;
+ dprintf("before schual fpscr = %x\n", n1);
+ LOS_EventWrite(&g_eventCb01, 0x1);
+ __asm__ __volatile__("vmrs %0, fpscr\n" : "=r"(n1)::); // need equals to before delay 's fpscr
+
+ g_fpsrc02 = n1;
+ dprintf("after resume fpscr = %x\n", n1);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ LOS_EventWrite(&g_eventCb01, 0x1);
+#endif
+}
+
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ LOS_EventInit(&g_eventCb01);
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)FloatTestInTask;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "TskTstA";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ g_fpsrc01 = 0;
+ g_fpsrc02 = 0;
+ g_fpsrc03 = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_EventRead(&g_eventCb01, 0x11, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x1, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ float d1 = -100.0f;
+ UINT32 n1 = 0;
+
+ __asm__("vldr s15, %0" ::"m"(d1));
+ __asm__("vcmp.f32 s15, #0");
+
+ __asm__ __volatile__("vmrs %0, fpscr\n" : "=r"(n1)::); // fpscr need not equals to up value
+ g_fpsrc03 = n1;
+ dprintf("after change fpscr = %x\n", n1);
+
+ g_testCount += 1;
+
+ ret = LOS_EventRead(&g_eventCb01, 0x11, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x1, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_fpsrc01, g_fpsrc02, g_fpsrc01, EXIT);
+ ICUNIT_GOTO_NOT_EQUAL(g_fpsrc01, g_fpsrc03, g_fpsrc03, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_EventDestroy(&g_eventCb01);
+
+ return LOS_OK;
+}
+#endif
+
+void ItLosTask141(void)
+{
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+ TEST_ADD_CASE("ItLosTask141", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+#endif
+}
+
+#endif
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_142.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_142.c
new file mode 100644
index 0000000000000000000000000000000000000000..daeb6075275b1d7f94483ecc8c04174b27d7374b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_142.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#ifndef TESTHI1980IMU
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+
+static UINT32 g_fpsrc01;
+static UINT32 g_fpsrc02;
+static UINT32 g_fpsrc03;
+
+static void ItHwi()
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ float d1 = -100.0f;
+ UINT32 n1 = 0;
+ __asm__("vldr s15, %0" ::"m"(d1));
+ __asm__("vcmp.f32 s15, #0");
+
+ __asm__ __volatile__("vmrs %0, fpscr\n" : "=r"(n1)::); // n1 is fpscr
+ g_fpsrc03 = n1;
+ dprintf("after change fpscr = %x\n", n1);
+
+ g_testCount += 1;
+ return;
+}
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ HWI_PRIOR_T hwiPrio = 3;
+ HWI_MODE_T mode = 0;
+ HWI_ARG_T arg = 0;
+
+ g_testCount = 0;
+ g_fpsrc01 = 0;
+ g_fpsrc02 = 0;
+ g_fpsrc03 = 0;
+ ret = LOS_HwiCreate(HWI_NUM_TEST3, hwiPrio, mode, (HWI_PROC_FUNC)ItHwi, arg);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST3, ArchCurrCpuid() + 1); // curret cpu
+#endif
+ float d1 = 100.0f;
+ UINT32 n1 = 0;
+ __asm__("vldr s15, %0" ::"m"(d1));
+ __asm__("vcmp.f32 s15, #0");
+
+ __asm__ __volatile__("vmrs %0, fpscr\n" : "=r"(n1)::); // n1 is fpscr
+ g_fpsrc01 = n1;
+ dprintf("before schual fpscr = %x\n", n1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+ g_testCount++;
+ TestHwiTrigger(HWI_NUM_TEST3);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+ __asm__ __volatile__("vmrs %0, fpscr\n" : "=r"(n1)::);
+ g_fpsrc02 = n1;
+ dprintf("after resume fpscr = %x\n", n1);
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ TEST_HwiDelete(HWI_NUM_TEST3);
+ ICUNIT_ASSERT_EQUAL(g_fpsrc01, g_fpsrc02, g_fpsrc01);
+ ICUNIT_ASSERT_NOT_EQUAL(g_fpsrc01, g_fpsrc03, g_fpsrc03);
+ return LOS_OK;
+}
+#endif
+
+void ItLosTask142(void)
+{
+#ifndef LOSCFG_ARCH_FPU_DISABLE
+ TEST_ADD_CASE("ItLosTask142", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL2, TEST_FUNCTION);
+#endif
+ return;
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_002.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..9b5b56ef2e17650d47f658faad1d46459fe86d96
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_002.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void const * argument)
+{
+ g_timesliceTestCount++;
+}
+
+static void TaskF01(void const * argument)
+{
+ UINT32 ret;
+ UINT32 intSave;
+
+ intSave = LOS_IntLock();
+
+ g_itTimesliceTestCount1 = TestTickCountGet();
+
+ LOS_IntRestore(intSave);
+
+ while (1) {
+ dprintf("");
+ intSave = LOS_IntLock();
+ if ((g_itTimesliceTestCount1 + 1) <= TestTickCountGet()) {
+ LOS_IntRestore(intSave);
+ break;
+ }
+ LOS_IntRestore(intSave);
+ }
+ ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 0, g_timesliceTestCount, EXIT);
+
+EXIT:;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ g_itTimesliceTestCount1 = 0;
+ g_timesliceTestCount = 0;
+
+ LOS_TaskLock();
+
+ TSK_INIT_PARAM_S task;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "TimesTsk002A";
+ // 2, Used to calculate stack space
+ task.uwStackSize = TASK_STACK_SIZE_TEST * 2;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.pcName = "TimesTsk002B";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskUnlock();
+
+ LOS_TaskDelay(5); // 5, set delay time.
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTaskTimeslice002(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTaskTIMESLICE_002", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_003.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..c8de1cc6df2cd512e6b3fdeccb4c30f497916808
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_003.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF03(void const * argument)
+{
+ UINT32 ret;
+
+ // 2, assert that result is equal to this.
+ ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 2, g_timesliceTestCount, EXIT);
+ g_timesliceTestCount++;
+
+EXIT:;
+}
+
+static void TaskF02(void const * argument)
+{
+ UINT32 ret;
+ UINT32 intSave;
+ UINT64 itTimesliceCount11;
+
+ ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 1, g_timesliceTestCount, EXIT);
+ g_timesliceTestCount++;
+
+ intSave = LOS_IntLock();
+
+ itTimesliceCount11 = TestTickCountGet();
+
+ LOS_IntRestore(intSave);
+
+ while (1) {
+ dprintf("");
+ intSave = LOS_IntLock();
+ if ((itTimesliceCount11 + LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT) < TestTickCountGet()) {
+ LOS_IntRestore(intSave);
+ break;
+ }
+ LOS_IntRestore(intSave);
+ }
+ // 4, assert that result is equal to this.
+ ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 4, g_timesliceTestCount, EXIT);
+ g_timesliceTestCount++;
+
+EXIT:;
+}
+
+static void TaskF01(void const * argument)
+{
+ UINT32 ret;
+ UINT32 intSave;
+
+ intSave = LOS_IntLock();
+
+ ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 0, g_timesliceTestCount, EXIT);
+ g_timesliceTestCount++;
+
+ g_itTimesliceTestCount1 = TestTickCountGet();
+
+ LOS_IntRestore(intSave);
+
+ while (1) {
+ dprintf("");
+ intSave = LOS_IntLock();
+ if ((g_itTimesliceTestCount1 + LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT) < TestTickCountGet()) {
+ LOS_IntRestore(intSave);
+ break;
+ }
+ LOS_IntRestore(intSave);
+ }
+ // 3, assert that result is equal to this.
+ ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 3, g_timesliceTestCount, EXIT);
+ g_timesliceTestCount++;
+
+EXIT:;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ g_itTimesliceTestCount1 = 0;
+ g_timesliceTestCount = 0;
+
+ LOS_TaskLock();
+
+ TSK_INIT_PARAM_S task;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "TimesTsk003A";
+ // 2, Used to calculate stack space
+ task.uwStackSize = TASK_STACK_SIZE_TEST * 2;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.pcName = "TimesTsk003B";
+ // 2, Used to calculate stack space
+ task.uwStackSize = TASK_STACK_SIZE_TEST * 2;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF03;
+ task.pcName = "TimesTsk003C";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskUnlock();
+
+ LOS_TaskDelay(20); // 20, set delay time.
+ // 5, assert that result is equal to this.
+ ICUNIT_ASSERT_EQUAL(g_timesliceTestCount, 5, g_timesliceTestCount);
+ LOS_TaskDelete(g_testTaskID03);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTaskTimeslice003(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTaskTIMESLICE_003", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_004.c b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..c96e453ac3eaac2759b0029d6c3a000236fccfea
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/full/It_los_task_timeslice_004.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+UINT32 g_cmsisRobinTestCount2 = 0;
+static void TaskF02(void const * argument)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 1, ret, EXIT);
+ g_timesliceTestCount++;
+ return;
+
+EXIT:;
+}
+
+static void SwtmrF01(UINT32 *arg)
+{
+ // 100, set g_cmsisRobinTestCount2 num
+ g_cmsisRobinTestCount2 = 100;
+ return;
+}
+
+static void TaskF01(void const * argument)
+{
+ UINT32 ret;
+ UINT32 arg;
+ UINT32 intSave;
+
+ ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 0, ret, EXIT);
+ g_timesliceTestCount++;
+
+ ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swTmrID, 0xffff);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(g_swTmrID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ intSave = LOS_IntLock();
+ g_itTimesliceTestCount1 = TestTickCountGet();
+
+ LOS_IntRestore(intSave);
+
+ while (1) {
+ dprintf("");
+ intSave = LOS_IntLock();
+
+ if ((g_itTimesliceTestCount1 + LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT) < TestTickCountGet()) {
+ LOS_IntRestore(intSave);
+ break;
+ }
+
+ LOS_IntRestore(intSave);
+ }
+
+ // 2, assert that result is equal to this.
+ ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 2, ret, EXIT);
+ g_timesliceTestCount++;
+
+ // 100, assert that result is equal to this.
+ if (g_cmsisRobinTestCount2 == 100) {
+ // 2, set g_cmsisRobinTestCount2 for future Tests.
+ g_cmsisRobinTestCount2 = 2;
+ } else {
+ dprintf("ERROR It_Timeslice_004_f01 g_cmsis_robinTestCount %d\n", g_cmsisRobinTestCount2);
+ }
+
+ ret = LOS_SwtmrDelete(g_swTmrID); // Los_SwTmrDelete
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+
+EXIT:
+ ret = LOS_SwtmrDelete(g_swTmrID); // Los_SwTmrDelete
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ // 2, set g_cmsisRobinTestCount2 for future Tests.
+ g_cmsisRobinTestCount2 = 2;
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ g_cmsisRobinTestCount2 = 0;
+ g_itTimesliceTestCount1 = 0;
+ g_timesliceTestCount = 0;
+
+ LOS_TaskLock();
+ TSK_INIT_PARAM_S task;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "TimesTsk004A";
+ // 3, Used to calculate stack space
+ task.uwStackSize = TASK_STACK_SIZE_TEST * 3;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.pcName = "TimesTsk004B";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskUnlock();
+
+ return LOS_OK;
+}
+
+void ItLosTaskTimeslice004(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTaskTIMESLICE_004", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_045.c b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_045.c
new file mode 100644
index 0000000000000000000000000000000000000000..b8894d8c2514000bc404695f85028aced708be8b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_045.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void SwtmrF01(UINT32 arg)
+{
+ UINT32 uwSwTmrTaskID;
+ UINT32 ret;
+
+ g_testCount++;
+
+ uwSwTmrTaskID = LOS_CurTaskIDGet();
+ ret = LOS_TaskSuspend(uwSwTmrTaskID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ ret = LOS_TaskResume(uwSwTmrTaskID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+
+ g_testCount = 0;
+ // 4, time interval of swtmr.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+
+ return LOS_OK;
+}
+
+void ItLosTask045(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask045", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_046.c b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_046.c
new file mode 100644
index 0000000000000000000000000000000000000000..29167d4a03103d3f6e16355b124b7ed8f3810ed2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_046.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ ret = LOS_CurTaskPriSet(-1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_PRIOR_ERROR, ret);
+
+ ret = LOS_CurTaskPriSet(OS_TASK_PRIORITY_LOWEST + 1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_PRIOR_ERROR, ret);
+ return LOS_OK;
+}
+
+void ItLosTask046(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask046", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_049.c b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_049.c
new file mode 100644
index 0000000000000000000000000000000000000000..b3e8d03a1e3e6652b2f4d6a2462e066fa2905d8a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_049.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static TSK_INFO_S g_taskInfo;
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskInfoGet(-1, &g_taskInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_ID_INVALID, ret, EXIT1);
+
+ ret = LOS_TaskInfoGet(LOSCFG_BASE_CORE_TSK_CONFIG - 1, &g_taskInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret, EXIT1);
+
+ ret = LOS_TaskInfoGet(g_testTaskID01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_PTR_NULL, ret, EXIT1);
+
+ ret = LOS_TaskInfoGet(g_testTaskID01, &g_taskInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(g_taskInfo.acName, "Tsk049A", g_taskInfo.acName, EXIT1);
+ ICUNIT_GOTO_EQUAL(g_taskInfo.uwTaskID, g_testTaskID01, g_taskInfo.uwTaskID, EXIT1);
+ // 2, assert usTaskPrio change.
+ ICUNIT_GOTO_EQUAL(g_taskInfo.usTaskPrio, TASK_PRIO_TEST_TASK - 2, g_taskInfo.usTaskPrio, EXIT1);
+ ICUNIT_GOTO_EQUAL(OS_TASK_STATUS_RUNNING & g_taskInfo.usTaskStatus, OS_TASK_STATUS_RUNNING,
+ OS_TASK_STATUS_RUNNING & g_taskInfo.usTaskStatus, EXIT1);
+ ICUNIT_GOTO_EQUAL(g_taskInfo.uwBottomOfStack, g_taskInfo.uwSP + g_taskInfo.uwCurrUsed, g_taskInfo.uwBottomOfStack,
+ EXIT1);
+
+ g_testCount++;
+ return;
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk049A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItLosTask049(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask049", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_081.c b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_081.c
new file mode 100644
index 0000000000000000000000000000000000000000..359c9aee7bcfc6b0c89c990fd8daee52218d2f1e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_081.c
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ UINT32 semHandle;
+ volatile UINT64 tick1, tick2;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+ tick1 = TestTickCountGet();
+ LOS_TaskDelay(10); // 10, set delay time.
+ tick2 = TestTickCountGet();
+
+ // 10, assert that tick2 - tick1 is equal to this.
+ ICUNIT_ASSERT_EQUAL_TIME((tick2 - tick1), 10, (tick2 - tick1), EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ UINT32 semHandle;
+ UINT32 tick1, tick2;
+
+ ret = LOS_SemCreate(0, &semHandle);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ tick1 = TestTickCountGet();
+ // 10, Timeout interval of sem.
+ ret = LOS_SemPend(semHandle, 10);
+ tick2 = TestTickCountGet();
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SEM_TIMEOUT, ret, EXIT);
+
+ // 10, assert that tick2 - tick1 is equal to this.
+ ICUNIT_ASSERT_EQUAL_TIME((tick2 - tick1), 10, (tick2 - tick1), EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_SemDelete(semHandle);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk081A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ // 11, set delay time.
+ LOS_TaskDelay(11);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 6, g_testCount); // 6, assert that g_testCount is equal to this.
+ return LOS_OK;
+}
+
+void ItLosTask081() // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask081", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_089.c b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_089.c
new file mode 100644
index 0000000000000000000000000000000000000000..333b92c6afa63410379e8d574b2560b0279ae583
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_089.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ ret = LOS_TaskYield();
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+void ItLosTask089(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask089", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_097.c b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_097.c
new file mode 100644
index 0000000000000000000000000000000000000000..5b67c366e889ba41ed769fe82c8018107e755c14
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_097.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ g_testCount++;
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk097B";
+ // 3, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 3;
+ task1.uwResved = 0;
+ task1.processID = LOS_GetCurrProcessID();
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ task1.processID = LOS_GetCurrProcessID();
+
+ ret = LOS_TaskCreateOnly(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_SetTaskScheduler(g_testTaskID02, LOS_SCHED_RR, task1.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk097A";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ task1.processID = -1;
+ g_testCount = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask097(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask097", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_099.c b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_099.c
new file mode 100644
index 0000000000000000000000000000000000000000..5b88457275e3a3cd1f2327acbcf237b4ab0a1f43
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_099.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "TskB099";
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 2;
+ task1.processID = LOS_GetCurrProcessID();
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ task1.processID = LOS_GetCurrProcessID();
+
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreateOnly(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT3);
+
+ ret = LOS_SetTaskScheduler(g_testTaskID01, LOS_SCHED_RR, task1.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT1);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT2);
+
+ return LOS_OK;
+
+EXIT1:
+ LOS_TaskUnlock();
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+EXIT3:
+ LOS_TaskUnlock();
+
+ return LOS_OK;
+}
+
+void ItLosTask099(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask099", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_101.c b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_101.c
new file mode 100644
index 0000000000000000000000000000000000000000..c84a68692dd632886532e7cc14ef76dbedfd4bc8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_101.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk101A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, (UINT16)OS_INVALID, ret);
+
+ ret = LOS_TaskPriGet(g_taskMaxNum + 1);
+ ICUNIT_GOTO_EQUAL(ret, (UINT16)OS_INVALID, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, (UINT16)OS_INVALID, ret);
+
+ return LOS_OK;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItLosTask101(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask101", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_105.c b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_105.c
new file mode 100644
index 0000000000000000000000000000000000000000..e186f8edb7163f555708b8424ad92eb1ba224349
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_105.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK + 1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "Tsk105A";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ ret = LOS_TaskPriSet(OsGetIdleTaskId(), TASK_PRIO_TEST_TASK - 1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ ret = LOS_TaskPriSet(g_taskMaxNum + 1, TASK_PRIO_TEST_TASK - 1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_ID_INVALID, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_TaskPriSet(g_testTaskID01, OS_TASK_PRIORITY_LOWEST + 1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_PRIOR_ERROR, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTask105(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTask105", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_timeslice_001.c b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_timeslice_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..9351568535b632fd6cb72a775221dd7bd5229fec
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smoke/It_los_task_timeslice_001.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void const * argument)
+{
+ g_timesliceTestCount++;
+}
+
+static void TaskF01(void const * argument)
+{
+ UINT32 ret;
+ UINT32 intSave;
+
+ g_itTimesliceTestCount1 = TestTickCountGet();
+
+ while (1) {
+ dprintf("");
+ // 15000, It is used to calculate g_itTimesliceTestCount1.
+ if ((g_itTimesliceTestCount1 + 15000) < TestTickCountGet()) {
+ break;
+ }
+ }
+ ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 1, ret, EXIT);
+
+EXIT:;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ g_itTimesliceTestCount1 = 0;
+ g_timesliceTestCount = 0;
+ LOS_TaskLock();
+ TSK_INIT_PARAM_S task;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "TimesTsk001A";
+ // 2, It is used to calculate uwStackSize.
+ task.uwStackSize = TASK_STACK_SIZE_TEST * 2;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.pcName = "TimesTsk001B";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskUnlock();
+
+ LOS_TaskDelay(5); // 5, set delay time.
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+void ItLosTaskTimeslice001(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosTaskTIMESLICE_001", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_001.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..dae3e1d31ab7edc8449b6e441e4f26717da7f709
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_001.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static SPIN_LOCK_INIT(g_TestSpin);
+
+static void TaskF01(void)
+{
+ UINT32 puvIntSave;
+
+ LOS_SpinLockSave(&g_TestSpin, &puvIntSave);
+ g_testCount |= 1 << ArchCurrCpuid();
+ Dmb();
+ LOS_SpinUnlockRestore(&g_TestSpin, puvIntSave);
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 testid;
+ UINT32 coreIdx = 0;
+
+ g_testCount = 0;
+
+ while (coreIdx < LOSCFG_KERNEL_CORE_NUM) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_task_001", TaskF01, TASK_PRIO_TEST_TASK + 1,
+ CPUID_TO_AFFI_MASK(coreIdx));
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ coreIdx++;
+ }
+
+ LOS_TaskDelay(5); // 5, set delay time.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, LOSCFG_KERNEL_CPU_MASK, g_testCount);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask001(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask001", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_002.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..cb28d377609f139d8e1add5d0c5b7be95f22f67c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_002.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ while (1) {
+ Wfi();
+ };
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, currCpuid;
+ UINT32 testid = 0xff;
+
+ /* make sure that created test task is definitely on another core */
+ currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_task_002", TaskF01, OS_TASK_PRIORITY_LOWEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid));
+
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(2); // 2, set delay time.
+ ret = LOS_TaskDelete(testid);
+
+#if (LOSCFG_KERNEL_SMP_TASK_SYNC == NO)
+ /* delay and check */
+ LOS_TaskDelay(10); // 10, set delay time.
+#endif
+
+ ret = OS_TCB_FROM_TID(testid)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret & OS_TASK_STATUS_UNUSED, OS_TASK_STATUS_UNUSED, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask002(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask002", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_003.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..f845f457740108ee67a0638c73840e1fa0eae52c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_003.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ while (1) {
+ Wfi();
+ };
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, currCpuid;
+ UINT32 testid = 0xff;
+
+ /* make sure that created test task is definitely on another core */
+ currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_task_003", TaskF01, OS_TASK_PRIORITY_LOWEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid));
+
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(2); // 2, set delay time.
+ LOS_TaskSuspend(testid);
+
+ /* delay and check */
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ret = OS_TCB_FROM_TID(testid)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret & OS_TASK_STATUS_SUSPEND, OS_TASK_STATUS_SUSPEND, ret, EXIT);
+
+ LOS_TaskResume(testid);
+
+EXIT:
+ LOS_TaskDelay(2); // 2, set delay time.
+ LOS_TaskDelete(testid);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask003(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask003", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_004.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..6204ca15519e9063b9d84a65645b6a8f0bdd494f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_004.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ TEST_TASK_PARAM_INIT_AFFI(task1, "it_smp_task_004", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 2, 0);
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ while (g_testCount == 0) {
+ }
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ LosTaskCB *runTask;
+
+ runTask = OsCurrTaskGet();
+ ICUNIT_ASSERT_EQUAL(strcmp(runTask->taskName, "IT_TST_INI"), 0, 1);
+
+ return LOS_OK;
+
+EXIT:
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask004(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask004", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_021.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..c3133c34d5e62dea011c17fb527110ba8742433b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_021.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+#include "los_atomic.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static void TaskF02Preempt(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM];
+
+ g_testCount = 0;
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_021", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 2);
+ int i;
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ /* take control of every cores */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(i);
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ /* give up this core to task_f01 of this core */
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ /* take this core back to control, create an unbinded task */
+ ICUNIT_ASSERT_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount);
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02Preempt;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ /* take this core back to control */
+ ICUNIT_ASSERT_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM + 1, g_testCount);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask021(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask021", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_022.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..888f0a47e06c0c6bfd618dd28aab15c3a5bb55db
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_022.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+#include "los_atomic.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static void TaskF02Preempt(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM];
+
+ g_testCount = 0;
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_022", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 2);
+ int i;
+ for (i = 1; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ /* take control of every cores except this one */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(i);
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ /* wait task_f01 to run */
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM - 1, g_testCount, EXIT);
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02Preempt;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ /* give up this core to task_f02 */
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ /* take this core back to control */
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+
+ for (i = 1; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ return LOS_OK;
+EXIT:
+ for (i = 1; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask022(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask022", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_023.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..67ec758f02ab689cd43d297b3b0add4c8eaa1b67
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_023.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+
+ /* delay for a long time */
+ LOS_TaskDelay(1000); // 1000, set delay time.
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, currCpuid;
+ UINT32 testid = 0xff;
+ g_testCount = 0;
+
+ /* make sure that created test task is definitely on another core */
+ currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_task_003", TaskF01, OS_TASK_PRIORITY_LOWEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid));
+
+ ret = LOS_TaskCreate(&testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* Wait TaskF01 to start */
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; 1, test runing count
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(testid)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret & OS_TASK_STATUS_DELAY, OS_TASK_STATUS_DELAY, ret, EXIT);
+
+ LOS_TaskSuspend(testid);
+
+ /* delay and check */
+ LOS_TaskDelay(2); // 2, set delay time.
+
+ ret = OS_TCB_FROM_TID(testid)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret & OS_TASK_STATUS_SUSPEND, OS_TASK_STATUS_SUSPEND, ret, EXIT);
+
+ LOS_TaskResume(testid);
+
+EXIT:
+ LOS_TaskDelay(2); // 2, set delay time.
+ LOS_TaskDelete(testid);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask023(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask023", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_024.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_024.c
new file mode 100644
index 0000000000000000000000000000000000000000..a35fcfc9fb98f18c6caeb4a1d1cc40b7e095d287
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_024.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_itTestTaskID01;
+static UINT32 g_itTestTaskID02;
+static volatile int g_itTimesliceTestCount = 0;
+static volatile UINT32 g_itTestResult = LOS_OK;
+
+static UINT32 ItTimeslice001F02(void const * argument)
+{
+ g_itTimesliceTestCount++;
+ return LOS_OK;
+}
+
+static UINT32 ItTimeslice001F01(void const * argument)
+{
+ UINT64 timesliceCount;
+
+ // 2, 1000, Used to calculate timesliceCount.
+ timesliceCount = TestTickCountGet() + (LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT / 1000) * 2;
+
+ while (1) {
+ if (timesliceCount <= TestTickCountGet()) { // modify
+ break;
+ }
+ }
+ if (1 != g_itTimesliceTestCount) {
+ g_itTestResult = LOS_NOK;
+ }
+ return LOS_OK;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 currCpuid;
+ TSK_INIT_PARAM_S task;
+
+ g_itTimesliceTestCount = 0;
+ g_itTestResult = LOS_OK;
+
+ LOS_TaskLock();
+#if (LOSCFG_KERNEL_SMP == YES)
+ currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+#endif
+
+ memset(&task, 0, sizeof(TSK_INIT_PARAM_S));
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)ItTimeslice001F01;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ task.pcName = "it_timeslice_001_f01";
+ task.uwStackSize = LOS_TASK_MIN_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ task.processID = LOS_GetCurrProcessID();
+
+ ret = LOS_TaskCreateOnly(&g_itTestTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskCpuAffiSet(g_itTestTaskID01, CPUID_TO_AFFI_MASK(currCpuid));
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)ItTimeslice001F02;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ task.pcName = "it_timeslice_001_f02";
+ task.uwStackSize = LOS_TASK_MIN_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ task.processID = LOS_GetCurrProcessID();
+
+ ret = LOS_TaskCreateOnly(&g_itTestTaskID02, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskCpuAffiSet(g_itTestTaskID02, CPUID_TO_AFFI_MASK(currCpuid));
+
+ ret = LOS_SetTaskScheduler(g_itTestTaskID01, LOS_SCHED_RR, task.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ret = LOS_SetTaskScheduler(g_itTestTaskID02, LOS_SCHED_RR, task.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskUnlock();
+ // 10, Used to calculate delay time.
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT * 10);
+
+ ICUNIT_ASSERT_EQUAL(g_itTestResult, LOS_OK, g_itTestResult);
+ return LOS_OK;
+EXIT:
+ LOS_TaskUnlock();
+ return LOS_NOK;
+}
+
+void ItSmpLosTask024(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask024", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_025.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_025.c
new file mode 100644
index 0000000000000000000000000000000000000000..b0c7cd42f0b714daec3b6b9581949dca32769e3e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_025.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_itTestTaskID01;
+static UINT32 g_itTestTaskID02;
+static volatile UINT32 g_itTestResult = LOS_OK;
+static EVENT_CB_S g_eventCb01;
+
+static UINT32 ItTimeslice002F02(void const * argument)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskYield();
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ return LOS_OK;
+}
+
+static UINT32 ItTimeslice002F01(void const * argument)
+{
+ UINT64 timesliceCount;
+ UINT32 ret;
+
+ ret = LOS_SetTaskScheduler(g_itTestTaskID02, LOS_SCHED_RR, LOS_TaskPriGet(g_itTestTaskID02));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ /* Wait TaskF01 to yield, then testTask timeslice is LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT */
+ while (g_testCount != 1) {
+ }
+
+ timesliceCount = TestTickCountByCurrCpuid() + LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT - 1;
+
+ /* Task will not scheduled in timeslice - 1 */
+ while (1) {
+ if (timesliceCount <= TestTickCountByCurrCpuid) {
+ break;
+ }
+ }
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ ret = LOS_EventWrite(&g_eventCb01, 0x11);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 currCpuid;
+ TSK_INIT_PARAM_S task;
+ LOS_EventInit(&g_eventCb01);
+
+ g_testCount = 0;
+ g_itTestResult = LOS_NOK;
+
+ LOS_TaskLock();
+#if (LOSCFG_KERNEL_SMP == YES)
+ currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+#endif
+
+ memset(&task, 0, sizeof(TSK_INIT_PARAM_S));
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)ItTimeslice002F01;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ task.pcName = "it_timeslice_002_f01";
+ task.uwStackSize = LOS_TASK_MIN_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ task.processID = LOS_GetCurrProcessID();
+
+ ret = LOS_TaskCreateOnly(&g_itTestTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskCpuAffiSet(g_itTestTaskID01, CPUID_TO_AFFI_MASK(currCpuid));
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)ItTimeslice002F02;
+ task.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ task.pcName = "it_timeslice_002_f02";
+ task.uwStackSize = LOS_TASK_MIN_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ task.processID = LOS_GetCurrProcessID();
+
+ ret = LOS_TaskCreateOnly(&g_itTestTaskID02, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskCpuAffiSet(g_itTestTaskID02, CPUID_TO_AFFI_MASK(currCpuid));
+
+ ret = LOS_SetTaskScheduler(g_itTestTaskID01, LOS_SCHED_RR, task.usTaskPrio);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskUnlock();
+
+ ret = LOS_EventRead(&g_eventCb01, 0x11, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x11, ret, EXIT);
+
+ ret = LOS_EventDestroy(&g_eventCb01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_EventDestroy(&g_eventCb01);
+ LOS_TaskDelete(g_itTestTaskID01);
+ LOS_TaskDelete(g_itTestTaskID02);
+ return LOS_NOK;
+}
+
+void ItSmpLosTask025(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask025", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_026.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..6f2f81cc290a47718bc00b90e6a901ec412dd8c3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_026.c
@@ -0,0 +1,102 @@
+/*
+ * 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 "los_atomic.h"
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ Wfi();
+ }
+}
+
+static void TaskF02(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, currCpuid;
+ UINT32 testid[2];
+
+ g_testCount = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+
+ // 3, It is used to calculate a priority relative to OS_TASK_PRIORITY_LOWEST.
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_task_026_f01", TaskF01, OS_TASK_PRIORITY_LOWEST - 3,
+ CPUID_TO_AFFI_MASK(currCpuid));
+ ret = LOS_TaskCreate(&testid[0], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ // 2, It is used to calculate a priority relative to OS_TASK_PRIORITY_LOWEST.
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_task_026_f02", TaskF02, OS_TASK_PRIORITY_LOWEST - 2,
+ CPUID_TO_AFFI_MASK(currCpuid));
+ ret = LOS_TaskCreate(&testid[1], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* Wait TaskF1 to start */
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; 1, test runing count
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ /* lower down the priority of TaskF01 to trigger preeption */
+ LOS_TaskPriSet(testid[0], OS_TASK_PRIORITY_LOWEST - 1);
+
+ LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+EXIT:
+ LOS_TaskDelete(testid[0]);
+ LOS_TaskDelete(testid[1]);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask026(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask026", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_027.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..f9531987a8a0b401cda56414a23278d01b510e26
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_027.c
@@ -0,0 +1,99 @@
+/*
+ * 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 "los_atomic.h"
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testid, g_cpuid;
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ /* loop for 15 ticks */
+ LOS_TaskDelay(15); // 15, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testid)->currCpu;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_cpuid, ret);
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret, currCpuid;
+
+ g_testCount = 0;
+
+ currCpuid = ArchCurrCpuid();
+ /* make sure that created test task is definitely on another core */
+ g_cpuid = (currCpuid + 1) % LOSCFG_KERNEL_CORE_NUM;
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_task_027_f01", TaskF01, TASK_PRIO_TEST_TASK - 1,
+ CPUID_TO_AFFI_MASK(currCpuid));
+ ret = LOS_TaskCreate(&g_testid, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* loop for 2 ticks */
+ TestBusyTaskDelay(2); // 2, set delay time
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ /* set the affinity of test task */
+ LOS_TaskCpuAffiSet(g_testid, CPUID_TO_AFFI_MASK(g_cpuid));
+
+ /* loop for 20 ticks */
+ TestBusyTaskDelay(20); // 20, set delay time
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+EXIT:
+ LOS_TaskDelete(g_testid);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask027(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask027", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_028.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_028.c
new file mode 100644
index 0000000000000000000000000000000000000000..7739a515b6c3e88cf66ad9acdddfca716032d28e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_028.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTaskIdsmp[LOSCFG_KERNEL_CORE_NUM];
+static int g_runCpu[LOSCFG_KERNEL_CORE_NUM];
+static void TaskF01(UINT32 i)
+{
+ g_runCpu[i] = OS_TCB_FROM_TID(g_testTaskIdsmp[i])->currCpu;
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 gBitmap;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ int i;
+
+ g_testCount = 0;
+ gBitmap = LOSCFG_KERNEL_CPU_MASK;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_028", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ g_runCpu[i] = 3; // 3, It is used to calculate runcpu id.
+ /* take control of every cores */
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + i + 1;
+ task1.usCpuAffiMask = 0;
+ task1.auwArgs[0] = i;
+ ret = LOS_TaskCreate(&g_testTaskIdsmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ /* Calculate the field on the other core */
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = g_runCpu[i];
+ g_testCount |= (0x1 << ret);
+ ret = LOS_TaskDelete(g_testTaskIdsmp[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ /* Calculate the field on the current core */
+ ret = ArchCurrCpuid();
+ g_testCount |= (0x1 << ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, gBitmap, g_testCount);
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ LOS_TaskDelete(g_testTaskIdsmp[i]);
+ }
+}
+
+void ItSmpLosTask028(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask028", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_029.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..cbf2573bdc0854dcf60287f8a04ebeec3034d2f4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_029.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ while (1) {
+ }
+}
+
+static void TaskF02(void)
+{
+ LOS_AtomicInc(&g_testCount2);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 bitmap;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM + 1];
+
+ g_testCount = 0;
+ bitmap = LOSCFG_KERNEL_CPU_MASK;
+ g_testCount2 = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_029", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+ int i;
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + i + 1;
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ for (i = LOSCFG_KERNEL_CORE_NUM - 1; i < LOSCFG_KERNEL_CORE_NUM + 1; i++) {
+ /* take control of every cores */
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ /* Calculate the field on the other core */
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = OS_TCB_FROM_TID(testTaskIDSmp[i])->currCpu;
+ g_testCount |= (0x1 << ret);
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ /* Calculate the field on the current core */
+ ret = ArchCurrCpuid();
+ g_testCount |= (0x1 << ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, bitmap, g_testCount);
+ ICUNIT_ASSERT_EQUAL(g_testCount2, 2, g_testCount2); // 2, assert that g_testCount2 is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM + 1; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+}
+
+void ItSmpLosTask029(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask029", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_030.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_030.c
new file mode 100644
index 0000000000000000000000000000000000000000..0cca36c5f30831d4cd84afcf2855436326e62556
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_030.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTaskIdsmp[LOSCFG_KERNEL_CORE_NUM + 2];
+static int g_runCpu[LOSCFG_KERNEL_CORE_NUM];
+static void TaskF01(UINT32 i)
+{
+ g_runCpu[i] = OS_TCB_FROM_TID(g_testTaskIdsmp[i])->currCpu;
+ while (1) {
+ }
+}
+
+static void TaskF02(void)
+{
+ LOS_AtomicInc(&g_testCount2);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 gBitmap;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+ gBitmap = 0;
+ g_testCount2 = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_030", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+ int i;
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ // 3, It is used to calculate runcpu id.
+ g_runCpu[i] = 3;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + i + 1;
+ task1.usCpuAffiMask = 0;
+ task1.auwArgs[0] = i;
+ ret = LOS_TaskCreate(&g_testTaskIdsmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+ // 2, It is used to calculate number of cycles
+ for (i = LOSCFG_KERNEL_CORE_NUM - 1; i < LOSCFG_KERNEL_CORE_NUM + 2; i++) {
+ /* take control of every cores */
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&g_testTaskIdsmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ /* Calculate the field on the other core */
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = g_runCpu[i];
+ g_testCount |= (0x1 << ret);
+ gBitmap |= (0x1 << i);
+
+ ret = LOS_TaskDelete(g_testTaskIdsmp[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ /* Calculate the field on the current core */
+ ret = ArchCurrCpuid();
+ g_testCount |= (0x1 << ret);
+ gBitmap |= (0x1 << (LOSCFG_KERNEL_CORE_NUM - 1));
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, gBitmap, g_testCount);
+ ICUNIT_ASSERT_EQUAL(g_testCount2, 3, g_testCount2); // 3, assert that g_testCount2 is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM + 1; i++) {
+ LOS_TaskDelete(g_testTaskIdsmp[i]);
+ }
+}
+
+void ItSmpLosTask030(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask030", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_032.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_032.c
new file mode 100644
index 0000000000000000000000000000000000000000..a138c42ca1b9ad8c836bd4787c88f94b524c348f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_032.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ int i;
+
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_032", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+
+ /* make sure that created test task is definitely on another core */
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* wait for task_f01 to start */
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ /* take this core back to control */
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_NOK;
+}
+
+void ItSmpLosTask032(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask032", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_033.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_033.c
new file mode 100644
index 0000000000000000000000000000000000000000..425b88bcfa0212cf1e395c2662af5c9f36865512
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_033.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static void TaskF02Preempt(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM];
+
+ g_testCount = 0;
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_033", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 2);
+ int i;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 2 + i;
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ /* wait for task to schedule */
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ /* take this core back to control */
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM - 1 + 1, g_testCount, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED, ret, EXIT);
+
+ // 2, It is used to calculate number of cycles
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 2; i++) {
+ ret = OS_TCB_FROM_TID(testTaskIDSmp[i])->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED, ret, EXIT);
+ }
+ // 2, It is used to calculate number of cycles
+ ret = OS_TCB_FROM_TID(testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM - 2])->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED, ret, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount);
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask033(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask033", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_034.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_034.c
new file mode 100644
index 0000000000000000000000000000000000000000..5ed73c922a12701f43824c4b444994cd611039db
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_034.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static void TaskF02Preempt(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM];
+
+ g_testCount = 0;
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_034", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 2);
+ int i;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 2 + i;
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02Preempt;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret + 1, LOS_OK + 1, ret, EXIT);
+
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ /* wait for task to schedule */
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ /* take this core back to control */
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM + 1, g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask034(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask034", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_035.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_035.c
new file mode 100644
index 0000000000000000000000000000000000000000..be51a961f18ff4530e9a0ae95e2bc3e9b7192eed
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_035.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02Preempt(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM];
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_035", (TSK_ENTRY_FUNC)TaskF02Preempt, TASK_PRIO_TEST_TASK - 1);
+
+ /* creat preempt task */
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* wait for task to schedule */
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ /* take this core back to control */
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask035(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask035", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_036.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_036.c
new file mode 100644
index 0000000000000000000000000000000000000000..c2f1c956c4bd10c1f0b6956ce8c9128bf049fd4f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_036.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM + 1];
+ int i;
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_036", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+
+ task1.usCpuAffiMask = 0;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK;
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ /* wait for task to start */
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ /* take this core back to control */
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM - 1, g_testCount, EXIT);
+
+ /* check task status on other cores */
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = OS_TCB_FROM_TID(testTaskIDSmp[i])->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED, ret, EXIT);
+ }
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask036(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask036", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_037.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_037.c
new file mode 100644
index 0000000000000000000000000000000000000000..2425e03956fc7b7f3e11da743e4a34dc472bb455
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_037.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile UINT32 g_itTestResult = LOS_NOK;
+static volatile int g_flag = 0;
+
+static void TaskF02(void const * argument)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static void TaskF01(void const * argument)
+{
+ UINT64 timesliceCount;
+
+ LOS_AtomicInc(&g_testCount);
+ // 5, 1000, Used to calculate timesliceCount.
+ timesliceCount = TestTickCountGet() + (LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT / 1000) * 5;
+
+ while (1) {
+ if (timesliceCount <= TestTickCountGet()) {
+ break;
+ }
+ }
+ if (g_testCount == LOSCFG_KERNEL_CORE_NUM) {
+ g_itTestResult = LOS_OK;
+ g_flag = 1;
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM];
+ const CHAR *taskAll = "-a";
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_037", (TSK_ENTRY_FUNC)TaskF02, TASK_PRIO_TEST_TASK);
+ int i;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+ /* check if every core's task is running */
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ OsShellCmdDumpTask(1, &taskAll);
+ do {
+ ret = OS_TCB_FROM_TID(testTaskIDSmp[i])->taskStatus;
+ } while (ret & OS_TASK_STATUS_READY);
+
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED, ret, EXIT);
+ }
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* wait for task01 is finished */
+ while (g_flag != 1) {
+ }
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ return g_itTestResult;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask037(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask037", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_040.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_040.c
new file mode 100644
index 0000000000000000000000000000000000000000..4b4e6cbd389edaa842b64e4a1ce8888e0bd43fc6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_040.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile UINT32 g_itTestResult = LOS_NOK;
+
+static void TaskF01(void const * argument)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM];
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_040", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+ int i;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ /* take control of every cores */
+ task1.pfnTaskEntry = TaskF01;
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ /* wait for task to yeild */
+ TestBusyTaskDelay(LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT * 2); // 2, used to calculate delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+ return LOS_NOK;
+}
+
+void ItSmpLosTask040(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask040", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_042.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_042.c
new file mode 100644
index 0000000000000000000000000000000000000000..79cb1f1564bc881dba944c85ba400ac558fe9241
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_042.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile UINT32 g_itTestResult = LOS_NOK;
+
+static void TaskF01(void const * argument)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static void TaskF02(void const * argument)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM];
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_042", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+ int i;
+
+ /* creat high prio task on every cores */
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+ /* check every cores are running test task */
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = OS_TCB_FROM_TID(testTaskIDSmp[i])->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED, ret, EXIT);
+ }
+
+ /* Create a number of cores + 1 high priority task, this task is rotation */
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM - 1], &task1);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* Waiting for two time slices */
+ TestBusyTaskDelay(LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT * 2); // 2, used to calculate delay time
+
+ /* check task is executed */
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask042(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask042", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_043.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_043.c
new file mode 100644
index 0000000000000000000000000000000000000000..d8a1806898e4cf9feca2a42e00794fd1f5031128
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_043.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile UINT32 g_itTestResult = LOS_NOK;
+
+static void TaskF01(void const * argument)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static void TaskF02(void const * argument)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM];
+ const CHAR *taskAll = "-a";
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_043", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+ int i;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ /* wait test task to start */
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ /* check every cores is running test task */
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ do {
+ OsShellCmdDumpTask(1, &taskAll);
+ ret = OS_TCB_FROM_TID(testTaskIDSmp[i])->taskStatus;
+ } while (ret & OS_TASK_STATUS_READY);
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED, ret, EXIT);
+ }
+
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM - 1], &task1);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT * 2); // 2, used to calculate delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM + 1, g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask043(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask043", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_044.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_044.c
new file mode 100644
index 0000000000000000000000000000000000000000..927f3bd207a18e84b9077e9cbe0bbe6a6e0b0deb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_044.c
@@ -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.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT64 timesliceCount;
+ UINT64 timesliceCount2;
+
+ // 10, It is used to calculate timesliceCount
+ timesliceCount = TestTickCountGet() + 10;
+
+ ret = LOS_TaskDelay(10); // 10, set delay time.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ timesliceCount2 = TestTickCountGet();
+
+ ICUNIT_ASSERT_EQUAL(timesliceCount, timesliceCount2, timesliceCount);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask044(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask044", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_046.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_046.c
new file mode 100644
index 0000000000000000000000000000000000000000..6a3ce2f4278a73ec2a213d2dfc1eeb78b65fb020
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_046.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile UINT32 g_itTestResult = LOS_OK;
+
+static void TaskF01(void const * argument)
+{
+ UINT32 ret;
+ UINT64 timesliceCount;
+ UINT64 timesliceCount2;
+ LOS_AtomicInc(&g_testCount);
+
+ // 50, It is used to calculate timesliceCount
+ timesliceCount = TestTickCountGet() + 50;
+
+ ret = LOS_TaskDelay(50); // 50, set delay time.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ timesliceCount2 = TestTickCountGet();
+
+ dprintf("Time1 = 0x%llX ; Time2 = 0x%llX \n", timesliceCount, timesliceCount2);
+ if ((timesliceCount > (timesliceCount2 + 1)) || ((timesliceCount < timesliceCount2 - 1))) {
+ g_itTestResult = LOS_NOK;
+ }
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM];
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_046", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+ int i;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(30); // 30, set delay time.
+
+ /* check every cores is running test task */
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = OS_TCB_FROM_TID(testTaskIDSmp[i])->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_DELAY, 0, ret, EXIT);
+ }
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM - 1, g_testCount, EXIT);
+
+ TestBusyTaskDelay(60); // 60, set delay time
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_itTestResult, LOS_OK, g_itTestResult);
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask046(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask046", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_047.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_047.c
new file mode 100644
index 0000000000000000000000000000000000000000..b17ea88efb0bb0f26b3613d11715cde8a1f621ef
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_047.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile UINT32 g_itTestResult = LOS_OK;
+
+static void TaskF01(void const * argument)
+{
+ LOS_AtomicInc(&g_testCount);
+ LOS_TaskDelay(20); // 20, set delay time.
+ while (1) {
+ }
+}
+
+static void TaskF02(void const * argument)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM];
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_047", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+ int i;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* wait test task to start */
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_itTestResult, LOS_OK, g_itTestResult);
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask047(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask047", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_048.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_048.c
new file mode 100644
index 0000000000000000000000000000000000000000..5cbcf48e5da297b5b76405ec60e2b4e1704fe2d5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_048.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testRet;
+
+static void HwiF01(void)
+{
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ g_testRet = LOS_TaskDelay(10); // 10, set delay time.
+ ICUNIT_ASSERT_EQUAL_VOID(g_testRet, LOS_ERRNO_TSK_DELAY_IN_INT, g_testRet);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testRet, LOS_ERRNO_TSK_DELAY_IN_INT, g_testRet);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask048(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask048", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_049.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_049.c
new file mode 100644
index 0000000000000000000000000000000000000000..f0020a2bb57b074ea9acca99177e434fa189ea68
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_049.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTaskResult = LOS_OK;
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_049", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ /* take control of every cores */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ICUNIT_ASSERT_EQUAL(g_testTaskResult, LOS_OK, g_testTaskResult);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask049(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask049", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_050.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_050.c
new file mode 100644
index 0000000000000000000000000000000000000000..28094b4049888ab0fd29ff616742b64a168efeec
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_050.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_050", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ /* take control of every cores */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_RUNNING, 0, ret, EXIT);
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_DETACHED, 0, ret, EXIT);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_SUSPEND, 0, ret, EXIT);
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_DETACHED, 0, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_RUNNING, 0, ret, EXIT);
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_DETACHED, 0, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask050(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask050", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_051.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_051.c
new file mode 100644
index 0000000000000000000000000000000000000000..f73796969641bd0745640fb20f0a4ee08d720fb6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_051.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+UINT32 g_testTaskResult = LOS_OK;
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LOS_TaskSuspend(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ /* wait for Hwi is finished */
+ TestBusyTaskDelay(5); // 5, set delay time
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF02(void)
+{
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_051", (TSK_ENTRY_FUNC)TaskF02, TASK_PRIO_TEST_TASK - 1);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(5); // 5, set delay time
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_DETACHED, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ ICUNIT_GOTO_EQUAL(g_testTaskResult, LOS_OK, g_testTaskResult, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+void ItSmpLosTask051(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask051", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_052.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_052.c
new file mode 100644
index 0000000000000000000000000000000000000000..a34586ec037ac23107d269f4a60763ba80434091
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_052.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_052", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_DETACHED, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask052(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask052", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_053.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_053.c
new file mode 100644
index 0000000000000000000000000000000000000000..9ee9faa24c7f7fc480e6a9a201225c893fd14e98
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_053.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_TaskSuspend(g_testTaskID02);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ /* wait for Hwi is finished */
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF02(void)
+{
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_053", (TSK_ENTRY_FUNC)TaskF02, TASK_PRIO_TEST_TASK + 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_DETACHED, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask053(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask053", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_054.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_054.c
new file mode 100644
index 0000000000000000000000000000000000000000..3551b3a4f42ee3a862d2a61e26804f54ab884466
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_054.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskDelay(10); // 10, set delay time.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_054", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_DELAY | OS_TASK_STATUS_DETACHED, ret);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask054(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask054", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_055.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_055.c
new file mode 100644
index 0000000000000000000000000000000000000000..185da2745cd2fd4a105c96e26249af4d135aad51
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_055.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskDelay(100); // 100, set delay time.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_055", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_DELAY | OS_TASK_STATUS_DETACHED, ret, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_DELAY | OS_TASK_STATUS_DETACHED, ret, EXIT);
+
+ TestBusyTaskDelay(100); // 100, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask055(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask055", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_056.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_056.c
new file mode 100644
index 0000000000000000000000000000000000000000..6e4338a6ff98bd3c05742300f6bfb711060bada8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_056.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskDelay(50); // 50, set delay time.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_056", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* wait for task running and delay on the other core */
+ TestBusyTaskDelay(10); // 10, set delay time
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_DELAY | OS_TASK_STATUS_DETACHED, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* suspend task on the other core is asynchronous */
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_DELAY | OS_TASK_STATUS_DETACHED, ret);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask056(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask056", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_057.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_057.c
new file mode 100644
index 0000000000000000000000000000000000000000..0450aa71c24da3f65c354ad990ec8a75a9cbdb89
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_057.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_TaskSuspend(g_testTaskID01);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskDelay(50); // 50, set delay time.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_057", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(5); // 5, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_DELAY | OS_TASK_STATUS_DETACHED, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_DELAY | OS_TASK_STATUS_DETACHED, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask057(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask057", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_058.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_058.c
new file mode 100644
index 0000000000000000000000000000000000000000..31512ec2f2c00a552659c2035e34945c7ee08cc8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_058.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static EVENT_CB_S g_eventCb01;
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_eventCb01, 0x11, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x1, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ LOS_EventInit(&g_eventCb01);
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_058", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_PEND | OS_TASK_STATUS_DETACHED, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND | OS_TASK_STATUS_DETACHED, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_PEND | OS_TASK_STATUS_DETACHED, ret);
+
+ LOS_EventWrite(&g_eventCb01, 0x1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask058(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask058", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_059.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_059.c
new file mode 100644
index 0000000000000000000000000000000000000000..5de885a5ca40916076eac684af0a998c5e408ce6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_059.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ PRINTK("ItSmpLosTask059 4\n");
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ PRINTK("ItSmpLosTask059 5 ret:0x%x\n", ret);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ PRINTK("ItSmpLosTask059 6\n");
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_059", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret);
+ PRINTK("ItSmpLosTask059 1\n");
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ PRINTK("ItSmpLosTask059 2\n");
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+ PRINTK("ItSmpLosTask059 3\n");
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask059(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask059", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_060.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_060.c
new file mode 100644
index 0000000000000000000000000000000000000000..e38ac7451fb68de2b7d01c266108eb9f385fea88
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_060.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static EVENT_CB_S g_eventCb01;
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_eventCb01, 0x11, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x1, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ LOS_EventInit(&g_eventCb01);
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_060", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_PEND | OS_TASK_STATUS_DETACHED, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND | OS_TASK_STATUS_DETACHED, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_PEND | OS_TASK_STATUS_DETACHED, ret);
+
+ LOS_EventWrite(&g_eventCb01, 0x1);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask060(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask060", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_061.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_061.c
new file mode 100644
index 0000000000000000000000000000000000000000..9e2374edfcefa8f5518270705acb08e37149b909
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_061.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_061", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & (OS_TASK_STATUS_PEND | OS_TASK_STATUS_SUSPEND)), 0, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask061(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask061", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_062.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_062.c
new file mode 100644
index 0000000000000000000000000000000000000000..84267764090f6fddc98958ca082c8bd5b16f8731
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_062.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_queue;
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ UINT32 readbuf;
+
+ LOS_AtomicInc(&g_testCount);
+
+ // 50, queue buffer size.
+ ret = LOS_QueueRead(g_queue, &readbuf, 50, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ // 5, lengh of the queue; 50, max queue msg size.
+ ret = LOS_QueueCreate("queue", 5, &g_queue, 0, 50);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_062", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_queue);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_queue);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask062(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask062", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_063.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_063.c
new file mode 100644
index 0000000000000000000000000000000000000000..dca92afda11286486da32d85bd7f5aef79c54ac9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_063.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_queue;
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ UINT32 readbuf;
+
+ LOS_AtomicInc(&g_testCount);
+ // 50, queue buffer size.
+ ret = LOS_QueueRead(g_queue, &readbuf, 50, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ // 5, lengh of the queue; 50, max queue msg size.
+ ret = LOS_QueueCreate("queue", 5, &g_queue, 0, 50);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_063", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* Wait TaskF01 to start */
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_queue);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_queue);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask063(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask063", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_064.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_064.c
new file mode 100644
index 0000000000000000000000000000000000000000..77bffdac36f9202499b5bf37295743c1a4aa55c9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_064.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static EVENT_CB_S g_eventCb01;
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_TaskSuspend(g_testTaskID01);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_eventCb01, 0x11, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x1, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+ LOS_EventInit(&g_eventCb01);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_064", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask064(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask064", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_065.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_065.c
new file mode 100644
index 0000000000000000000000000000000000000000..b10d581ba3b931be7d1717c97441c99e3cfe63de
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_065.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static EVENT_CB_S g_eventCb01;
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_TaskSuspend(g_testTaskID01);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_eventCb01, 0x11, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x1, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+ LOS_EventInit(&g_eventCb01);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_065", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask065(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask065", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_066.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_066.c
new file mode 100644
index 0000000000000000000000000000000000000000..966da4f4450071e23d38b9293cecda40a778550f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_066.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_TaskSuspend(g_testTaskID01);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ int i;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_066", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask066(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask066", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_067.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_067.c
new file mode 100644
index 0000000000000000000000000000000000000000..655693a98588620c90d776eb1435b79f5e1dbf9f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_067.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_TaskSuspend(g_testTaskID01);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_067", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ /* Wait TaskF01 to start */
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, assert that g_testCount is equal to this.
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_SemDelete(g_semID);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask067(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask067", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_068.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_068.c
new file mode 100644
index 0000000000000000000000000000000000000000..ef09a714bb10b35a50f0d72eb2a77278d76a4250
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_068.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_queue;
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_TaskSuspend(g_testTaskID01);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ UINT32 readbuf;
+
+ LOS_AtomicInc(&g_testCount);
+
+ // 50, queue buffer size.
+ ret = LOS_QueueRead(g_queue, &readbuf, 50, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ // 5, lengh of the queue; 50, max queue msg size.
+ ret = LOS_QueueCreate("queue", 5, &g_queue, 0, 50);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_068", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_queue);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_queue);
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask068(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask068", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_069.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_069.c
new file mode 100644
index 0000000000000000000000000000000000000000..f74217e6b4cc74ef83e0b2ee0a43cfd31520e4e1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_069.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+UINT32 g_queue;
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_TaskSuspend(g_testTaskID01);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ UINT32 readbuf;
+
+ LOS_AtomicInc(&g_testCount);
+
+ // 50, queue buffer size.
+ ret = LOS_QueueRead(g_queue, &readbuf, 50, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+ // 5, lengh of the queue; 50, max queue msg size.
+ ret = LOS_QueueCreate("queue", 5, &g_queue, 0, 50);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_065", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueDelete(g_queue);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask069(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask069", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_070.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_070.c
new file mode 100644
index 0000000000000000000000000000000000000000..69fc2f79f8d728ebd9eb5f3fae15a5b8456bbff0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_070.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_ALREADY_SUSPENDED, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_070", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_ALREADY_SUSPENDED, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask070(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask070", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_071.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_071.c
new file mode 100644
index 0000000000000000000000000000000000000000..b18d826a6aba9e669d52e96e80088b89fb42bc17
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_071.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_ALREADY_SUSPENDED, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_071", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(50); // 50, set delay time
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_ALREADY_SUSPENDED, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask071(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask071", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_072.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_072.c
new file mode 100644
index 0000000000000000000000000000000000000000..a74f2e8103fcbeed76d581dcd66df077cb27a8c4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_072.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 uvIntSave;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskLock();
+
+ TestBusyTaskDelay(20); // 20, set delay time
+
+ LOS_TaskUnlock();
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_072", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* wait for other core's task being schduled */
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; 1, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_RUNNING), 0, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_SUSPEND_LOCKED,
+ ret); // expect RET=LOS_ERRNO_TSK_SUSPEND_LOCKED, but can't solve asynchronous problems
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_RUNNING), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ /* wait for other core's task being finished */
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask072(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask072", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_073.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_073.c
new file mode 100644
index 0000000000000000000000000000000000000000..f2021478077cdd0ec964279a5bb759031b2c78c3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_073.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_SUSPEND_LOCKED, ret);
+
+ LOS_TaskUnlock();
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_073", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask073(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask073", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_074.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_074.c
new file mode 100644
index 0000000000000000000000000000000000000000..638190bbb28babb25084dc62bfe4cbe4780ff9b0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_074.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_SUSPEND_LOCKED, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskLock();
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_074", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask074(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask074", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_075.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_075.c
new file mode 100644
index 0000000000000000000000000000000000000000..be729615e7e8f74bdcc814ecee64ce4bd4ce2e09
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_075.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskLock();
+
+ TestBusyTaskDelay(50); // 50, set delay time
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_075", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; 1, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, OS_TASK_STATUS_RUNNING, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 4); // 4, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask075(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask075", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_076.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_076.c
new file mode 100644
index 0000000000000000000000000000000000000000..ee9c7b8dfd2e9b627fc9c7d1d812d0724f3382db
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_076.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_076", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ ret = LOS_MuxInit(&g_mutexkernelTest, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ (void)LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+void ItSmpLosTask076(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask076", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_077.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_077.c
new file mode 100644
index 0000000000000000000000000000000000000000..87ebefe0783c6222230eed86526b40dd03b61977
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_077.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_077", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ ret = LOS_MuxInit(&g_mutexkernelTest, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ /* wait for other core's task being scheduled */
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; 1, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ /* wait for other core's task executed */
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+
+ TestBusyTaskDelay(4); // 4, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_MuxDestroy(&g_mutexkernelTest);
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask077(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask077", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_078.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_078.c
new file mode 100644
index 0000000000000000000000000000000000000000..13f519bdab047b5ad0d33e5c07d955f743ea3446
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_078.c
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_078", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ ret = LOS_MuxInit(&g_mutexkernelTest, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 6, g_testCount); // 6, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ (void)LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+void ItSmpLosTask078(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask078", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_079.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_079.c
new file mode 100644
index 0000000000000000000000000000000000000000..e2d50b333e105a8f2e33b78f8fad635596c4c96b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_079.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_079", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ ret = LOS_MuxInit(&g_mutexkernelTest, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_PEND)), 0, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 6); // 6, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 6, g_testCount); // 6, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ (void)LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+void ItSmpLosTask079(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask079", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_081.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_081.c
new file mode 100644
index 0000000000000000000000000000000000000000..8c209973b8db8ade32f3a45e07f386905409ca28
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_081.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 gTestIdleTaskID;
+ UINT32 gTestSwtmrTaskID;
+ UINT32 cpuid = ArchCurrCpuid();
+
+ gTestIdleTaskID = OsGetIdleTaskId();
+
+ ret = LOS_TaskSuspend(gTestIdleTaskID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ gTestSwtmrTaskID = g_percpu[cpuid].swtmrTaskID;
+
+ ret = LOS_TaskSuspend(gTestSwtmrTaskID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask081(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask081", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_082.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_082.c
new file mode 100644
index 0000000000000000000000000000000000000000..04398288ea1adb3e23da1eb154eb5c7620af293b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_082.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 gTestIdleTaskID;
+ UINT32 gTestSwtmrTaskID;
+ UINT32 cpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ gTestIdleTaskID = g_percpu[cpuid].idleTaskID;
+
+ ret = LOS_TaskSuspend(gTestIdleTaskID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ gTestSwtmrTaskID = g_percpu[cpuid].swtmrTaskID;
+
+ ret = LOS_TaskSuspend(gTestSwtmrTaskID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask082(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask082", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_084.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_084.c
new file mode 100644
index 0000000000000000000000000000000000000000..a0c51001124a8e72650afcd3584c28e1fc0f8dcf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_084.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, (OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED), ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestBusyTaskDelay(5); // 5, set delay time
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_084", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ /* take control of every cores */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask084(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask084", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_087.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_087.c
new file mode 100644
index 0000000000000000000000000000000000000000..ff2ff72d2f0f363b33646d6ea1ef65b0e93a3f78
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_087.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_087", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, (OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED), ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+}
+
+void ItSmpLosTask087(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask087", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_088.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_088.c
new file mode 100644
index 0000000000000000000000000000000000000000..12c2da62368c58756e85f6cb66ff4c31bdba98cd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_088.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, (OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED), ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_088", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, (OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED), ret, EXIT);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+}
+
+void ItSmpLosTask088(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask088", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_089.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_089.c
new file mode 100644
index 0000000000000000000000000000000000000000..18314bb3467f9fdefb86b7d71f6e757619b2fea7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_089.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskResume(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, (OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED), ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_087", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; 1, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, (OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED), ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask089(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask089", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_090.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_090.c
new file mode 100644
index 0000000000000000000000000000000000000000..b754fde23193285d9829cfd7648b127c530285e7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_090.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_090", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask090(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask090", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_091.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_091.c
new file mode 100644
index 0000000000000000000000000000000000000000..520136b29b1821039a4d40a2b2d849cc600bc397
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_091.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_091", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask091(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask091", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_092.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_092.c
new file mode 100644
index 0000000000000000000000000000000000000000..1282a723bc817c6b9bbd91fe4783959e649eccbb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_092.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL_VOID((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ int i;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_092", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask092(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask092", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_093.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_093.c
new file mode 100644
index 0000000000000000000000000000000000000000..ec6cefa44d196ce902c156f18d9e504d8ebb78c3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_093.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_NOT_SUSPENDED, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL_VOID((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_093", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 5); // 100, Set the timeout of runtime; 5, test runing count
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask093(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask093", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_094.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_094.c
new file mode 100644
index 0000000000000000000000000000000000000000..0d3b6055d87684031b77a23f8c47d14e84791bca
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_094.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_094", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask094(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask094", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_095.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_095.c
new file mode 100644
index 0000000000000000000000000000000000000000..0e33818761d48a9652cfdfa32d7a023d46b7f488
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_095.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskSuspend(g_testTaskID01);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_095", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_DETACHED), ret, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestBusyTaskDelay(1);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask095(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask095", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_096.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_096.c
new file mode 100644
index 0000000000000000000000000000000000000000..af4577b60e3235a76e18aa0ff817f27eda4e59bd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_096.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_096", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL(ret, (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_DETACHED), ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask096(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask096", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_097.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_097.c
new file mode 100644
index 0000000000000000000000000000000000000000..7b52785cf5a64da943d5603e892c70042f6aaecc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_097.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_094", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ while (g_testCount == 1) {
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ /* Wait other core's TaskF01 to resume */
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_NOK;
+}
+
+void ItSmpLosTask097(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask097", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_098.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_098.c
new file mode 100644
index 0000000000000000000000000000000000000000..39f93646419534d9d033f2ba1c50737f437a9a2d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_098.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_098", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret, EXIT);
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, (OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED), ret, EXIT);
+
+ LOS_TaskUnlock();
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_NOK;
+}
+
+void ItSmpLosTask098(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask098", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_099.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_099.c
new file mode 100644
index 0000000000000000000000000000000000000000..9fb8a0030d7ef41d04aaaed20dc87adc6895b88e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_099.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ // 3, assert that g_testCount is equal to this.
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskLock();
+
+ TestBusyTaskDelay(50); // 50, set delay time
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_099_1", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ while (g_testCount == 1) {
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret, EXIT);
+
+ task1.pcName = "it_smp_task_099_2";
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ while (g_testCount == 2) { // 2, assert that g_testCount is equal to this.
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_RUNNING), 0, ret, EXIT);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ while (g_testCount == 3) { // 3, assert that g_testCount is equal to this.
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_READY), 0, ret, EXIT);
+
+ TestBusyTaskDelay(60); // 60, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT); // 7, assert that g_testCount is equal to this.
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask099(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask099", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_100.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_100.c
new file mode 100644
index 0000000000000000000000000000000000000000..3fe94c2d9aebbe975257f2ea545ba75dd9e11014
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_100.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_100", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_READY), 0, ret, EXIT);
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret, EXIT);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask100(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask100", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_101.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_101.c
new file mode 100644
index 0000000000000000000000000000000000000000..29081da118143aca656fc192689fa1e40958c35b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_101.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile int g_flag = 0;
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_TaskLock();
+
+ LOS_AtomicInc(&g_testCount);
+
+ while (g_flag == 0) {
+ }
+
+ LOS_TaskUnlock();
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 gTestTaskLock;
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_101", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; 1, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_RUNNING), 0, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_READY), 0, ret, EXIT);
+
+ /* check if other core is Task_locked */
+ gTestTaskLock = g_percpu[(ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM)].taskLockCnt;
+ ICUNIT_ASSERT_NOT_EQUAL(gTestTaskLock, 0, gTestTaskLock);
+
+ ret = LOS_TaskSuspend(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret, EXIT);
+
+ /* unlock other core's tasklock */
+ g_flag = 1;
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask101(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask101", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_102.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_102.c
new file mode 100644
index 0000000000000000000000000000000000000000..994213f1c6ceb1e57874ca6d874007d6ab52c367
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_102.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile int g_flag = 0;
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_TaskLock();
+
+ LOS_AtomicInc(&g_testCount);
+
+ while (g_flag == 0) {
+ }
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskSuspend(g_testTaskID02);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 gTestTaskLock;
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_102", (TSK_ENTRY_FUNC)TaskF02, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* wait for other core's task to suspend */
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; 1, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret, EXIT);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK + 1;
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* wait for other core's task being running */
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_RUNNING), 0, ret, EXIT);
+
+ /* wait for other core is Task_locked */
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = LOS_TaskResume(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_READY), 0, ret, EXIT);
+
+ g_flag = 1;
+
+ // 4, assert that g_testCount is equal to this.
+ while (g_testCount != 4) {
+ }
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask102(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask102", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_103.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_103.c
new file mode 100644
index 0000000000000000000000000000000000000000..fc3a69c30f581644d12dfa15b40ee988784de551
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_103.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, (OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_DETACHED), ret);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, (OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED), ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_103", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret, EXIT);
+
+ LOS_TaskLock();
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, (OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED), ret, EXIT);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_NOK;
+}
+
+void ItSmpLosTask103(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask103", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_105.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_105.c
new file mode 100644
index 0000000000000000000000000000000000000000..ffa4955dae01df63ff2f567c98606eba7f620242
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_105.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ // 50, sem timeout.
+ ret = LOS_SemPend(g_semID, 50);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_105", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_UNUSED), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask105(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask105", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_106.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_106.c
new file mode 100644
index 0000000000000000000000000000000000000000..5cb451f00fda8de2687adc79b384ce0141e6b797
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_106.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ // 50, sem timeout.
+ ret = LOS_SemPend(g_semID, 50);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_106", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ // 2, set delay time.
+ TestBusyTaskDelay(2);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_UNUSED), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask106(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask106", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_107.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_107.c
new file mode 100644
index 0000000000000000000000000000000000000000..209b73eee9e16baac44d94b65ef00a6e71c2b2b5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_107.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_107", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK + 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_READY), 0, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_UNUSED), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask107(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask107", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_108.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_108.c
new file mode 100644
index 0000000000000000000000000000000000000000..4e5a3637ab848ee7160e6ea1bf6468cc739d43dc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_108.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_108", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_UNUSED), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask108(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask108", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_109.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_109.c
new file mode 100644
index 0000000000000000000000000000000000000000..ac2ab829c2591b71a0b2cc98c41eae5c7cde6a92
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_109.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_109", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ while (g_testCount == 0) {
+ }
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_UNUSED), 0, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask109(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask109", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_110.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_110.c
new file mode 100644
index 0000000000000000000000000000000000000000..6827e853bc67865194789923619438a1a8bf2f78
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_110.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskDelay(50); // 50, set delay time.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_110", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_DELAY), 0, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_UNUSED), 0, ret);
+
+ ret = LOS_TaskDelay(50); // 50, set delay time.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask110(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask110", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_112.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_112.c
new file mode 100644
index 0000000000000000000000000000000000000000..20a09fe38c8d6c2c08cc44cfc41b199b4d2b4fe9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_112.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_DELETE_LOCKED, ret);
+
+ LOS_TaskUnlock();
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_112", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask112(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask112", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_113.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_113.c
new file mode 100644
index 0000000000000000000000000000000000000000..eabc693c26c6d5995556d7c19650f453849b88e1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_113.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskLock();
+
+ TestBusyTaskDelay(30); // 30, set delay time
+
+ LOS_TaskUnlock();
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_113", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ while (g_testCount == 0) {
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_RUNNING), 0, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_SUSPEND_LOCKED,
+ ret); // expect RET=LOS_ERRNO_TSK_SUSPEND_LOCKED, but can't solve asynchronous problems
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_RUNNING), 0, ret);
+
+ TestBusyTaskDelay(30); // 30, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_UNUSED), 0, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask113(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask113", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_114.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_114.c
new file mode 100644
index 0000000000000000000000000000000000000000..2ccb896192a27afc0eddb84ed64b55617e774769
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_114.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 gTestIdleTaskID;
+ UINT32 gTestSwtmrTaskID;
+ UINT32 cpuid = ArchCurrCpuid();
+
+ gTestIdleTaskID = OsGetIdleTaskId();
+
+ ret = LOS_TaskDelete(gTestIdleTaskID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ gTestSwtmrTaskID = g_percpu[cpuid].swtmrTaskID;
+
+ ret = LOS_TaskDelete(gTestSwtmrTaskID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask114(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask114", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_115.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_115.c
new file mode 100644
index 0000000000000000000000000000000000000000..3b5a0a8ff11d593f4e6ce56768a15fef7e0b3e55
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_115.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ UINT32 gTestIdleTaskID;
+ UINT32 gTestSwtmrTaskID;
+ UINT32 cpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ gTestIdleTaskID = g_percpu[cpuid].idleTaskID;
+
+ ret = LOS_TaskDelete(gTestIdleTaskID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ gTestSwtmrTaskID = g_percpu[cpuid].swtmrTaskID;
+
+ ret = LOS_TaskDelete(gTestSwtmrTaskID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask115(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask115", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_117.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_117.c
new file mode 100644
index 0000000000000000000000000000000000000000..e407ea6c7bae45a20dfbc3059fe5908349691005
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_117.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, OS_TASK_STATUS_RUNNING, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_117", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ while (g_testCount == 0) {
+ } // wait task01 to start
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_RUNNING), 0, ret);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_UNUSED), 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask117(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask117", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_126.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_126.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d3cf903312ad7db21b58fa1ec6bc55c1f9df2ca
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_126.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+ UINT32 gTestIdleTaskID;
+ UINT32 gTestSwtmrTaskID;
+ UINT32 cpuid = ArchCurrCpuid();
+
+ LOS_AtomicInc(&g_testCount);
+
+ gTestIdleTaskID = OsGetIdleTaskId();
+
+ ret = LOS_TaskDelete(gTestIdleTaskID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_YIELD_IN_INT, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ gTestSwtmrTaskID = g_percpu[cpuid].swtmrTaskID;
+
+ ret = LOS_TaskDelete(gTestSwtmrTaskID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_YIELD_IN_INT, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask126(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask126", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_127.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_127.c
new file mode 100644
index 0000000000000000000000000000000000000000..bcba1ca277df101ca1d161604eac26fd04ff35e4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_127.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 "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+ UINT32 gTestIdleTaskID;
+ UINT32 gTestSwtmrTaskID;
+ UINT32 cpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ gTestIdleTaskID = g_percpu[cpuid].idleTaskID;
+
+ ret = LOS_TaskDelete(gTestIdleTaskID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_YIELD_IN_INT, ret);
+
+ gTestSwtmrTaskID = g_percpu[cpuid].swtmrTaskID;
+
+ ret = LOS_TaskDelete(gTestSwtmrTaskID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_YIELD_IN_INT, ret);
+
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask127(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask127", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_128.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_128.c
new file mode 100644
index 0000000000000000000000000000000000000000..df6c3dc54d0039765ff7b381b904b2333a7fd4f3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_128.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM + 1];
+ const CHAR *taskAll = "-a";
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_128", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+ int i;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ /* wait for task to start */
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ /* take this core back to control */
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM - 1, g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ do {
+ OsShellCmdDumpTask(1, &taskAll);
+ ret = OS_TCB_FROM_TID(testTaskIDSmp[i])->taskStatus;
+ } while (ret & OS_TASK_STATUS_READY);
+
+ ICUNIT_GOTO_EQUAL(ret, (OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED), ret, EXIT);
+ }
+
+ ret = LOS_TaskYield();
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask128(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask128", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_129.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_129.c
new file mode 100644
index 0000000000000000000000000000000000000000..eeb685fc430c51b97f191377c1fa4402254c6dea
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_129.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM + 1];
+ UINT64 timesliceCount1;
+ UINT64 timesliceCount2;
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_129", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+ int i;
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ /* creat core_num same priority tasks */
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ timesliceCount1 = TestTickCountGet();
+
+ ret = LOS_TaskYield();
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ timesliceCount2 = TestTickCountGet();
+
+ /* Check if task yield definitely successed */
+ ICUNIT_GOTO_NOT_EQUAL(timesliceCount2, timesliceCount1, timesliceCount2 - timesliceCount1, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask129(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask129", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_130.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_130.c
new file mode 100644
index 0000000000000000000000000000000000000000..e66335b0c407f8e2c3afa4bd11f1aa96c07e8d37
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_130.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskYield();
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_130", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_READY), 0, ret, EXIT);
+
+ /* Wait TaskF01 to yield, then testTask timeslice is LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT */
+ if (g_testCount != 1) {
+ LOS_TaskYield();
+ }
+
+ LOS_TaskLock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskYield();
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_YIELD_IN_LOCK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ LOS_TaskUnlock();
+
+ ret = LOS_TaskYield();
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask130(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask130", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_131.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_131.c
new file mode 100644
index 0000000000000000000000000000000000000000..b94074200dd584d8e5e935bed5c735214b0f7cc5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_131.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, (OS_TASK_STATUS_READY | OS_TASK_STATUS_DETACHED), ret);
+
+ ret = LOS_TaskYield();
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_YIELD_IN_INT, ret);
+}
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_131", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_READY), 0, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ TestBusyTaskDelay(2 * LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT); // 2, set delay time
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask131(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask131", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_132.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_132.c
new file mode 100644
index 0000000000000000000000000000000000000000..569c6470775aff96d2ccf851ac9025a31647cc59
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_132.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskYield();
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(2 * LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT); // 2, set delay time
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM + 1];
+ UINT64 timesliceCount1;
+ UINT64 timesliceCount2;
+ int i;
+ const CHAR *taskAll = "-a";
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_132", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ /* check all task is running */
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM - 1, g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ do {
+ OsShellCmdDumpTask(1, &taskAll);
+ ret = OS_TCB_FROM_TID(testTaskIDSmp[i])->taskStatus;
+ } while (ret & OS_TASK_STATUS_READY);
+ ICUNIT_GOTO_EQUAL(ret, (OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED), ret, EXIT);
+ }
+
+ task1.usCpuAffiMask = 0;
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ while (g_testCount != LOSCFG_KERNEL_CORE_NUM) {
+ }
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+
+ ret = LOS_TaskYield();
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask132(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask132", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_133.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_133.c
new file mode 100644
index 0000000000000000000000000000000000000000..264e5f5fb5f0aa4cd8768869a0196994ba4a667f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_133.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void SwtmrF01(UINT32 arg)
+{
+ UINT32 ret;
+ if (arg != 0xffff) {
+ return;
+ }
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskYield();
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ UINT16 swTmrID;
+
+ // 2, swtmr interval
+ ret = LOS_SwtmrCreate(2, LOS_SWTMR_MODE_ONCE, SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(3); // 3, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_SwtmrDelete(swTmrID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_SWTMR_ID_INVALID, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+}
+
+void ItSmpLosTask133(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask133", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_134.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_134.c
new file mode 100644
index 0000000000000000000000000000000000000000..2984cb1f4a6cca59eee89755fd61c55a409bde62
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_134.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM + 1];
+ UINT64 timesliceCount1;
+ UINT64 timesliceCount2;
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_134", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM - 1], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK;
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ timesliceCount1 = TestTickCountGet();
+
+ ret = LOS_TaskYield();
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ timesliceCount2 = TestTickCountGet();
+
+ ICUNIT_GOTO_NOT_EQUAL(timesliceCount1, timesliceCount2, timesliceCount1, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ TestBusyTaskDelay(20); // 20, set delay time
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_UNUSED, ret, EXIT);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask134(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask134", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_135.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_135.c
new file mode 100644
index 0000000000000000000000000000000000000000..4add0299331f9d33bd26a42283d1cc183aeee5f8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_135.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskYield();
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
+
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM + 1];
+ UINT64 timesliceCount1;
+ UINT64 timesliceCount2;
+ int i;
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_135", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM - 1], &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ /* wait for other task being running */
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ timesliceCount1 = TestTickCountGet();
+
+ ret = LOS_TaskYield();
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ timesliceCount2 = TestTickCountGet();
+
+ ICUNIT_GOTO_NOT_EQUAL(timesliceCount1, timesliceCount2, timesliceCount1, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_TaskDelete(testTaskIDSmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(testTaskIDSmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask135(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask135", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_136.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_136.c
new file mode 100644
index 0000000000000000000000000000000000000000..098eb888054d3808487cf29c46f404151f6adadc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_136.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTaskIdsmp[LOSCFG_KERNEL_CORE_NUM + 1];
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskIdsmp[LOSCFG_KERNEL_CORE_NUM - 1]);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT64 timesliceCount1;
+ UINT64 timesliceCount2;
+ int i;
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_136", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM - 1; i++) {
+ /* take control of every cores */
+ task1.usCpuAffiMask = 0;
+ ret = LOS_TaskCreate(&g_testTaskIdsmp[i], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskIdsmp[LOSCFG_KERNEL_CORE_NUM - 1], &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(20); // 20, set delay time
+
+ ret = LOS_TaskYield();
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ ret = LOS_TaskDelete(g_testTaskIdsmp[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(g_testTaskIdsmp[i]);
+ }
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask136(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask136", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_137.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_137.c
new file mode 100644
index 0000000000000000000000000000000000000000..c2a9c2751913a9eeffbdbd35c3430f6d9b7dc50c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_137.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ if (ArchCurrCpuid() == 0) {
+ g_testCount++;
+ break;
+ }
+ }
+}
+
+static void TaskF02(void)
+{
+ LOS_AtomicInc(&g_testCount);
+ while (1) {
+ }
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_137", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_READY), 0, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; 1, test runing count
+
+ ICUNIT_ASSERT_NOT_EQUAL(g_testCount, 0, g_testCount);
+
+ ret = LOS_TaskYield();
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ICUNIT_ASSERT_NOT_EQUAL(g_testCount, 0, g_testCount);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask137(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask137", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_138.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_138.c
new file mode 100644
index 0000000000000000000000000000000000000000..11f5106a3f96a8b9469d45759890e69acce9751b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_138.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT64 timesliceCount1;
+ UINT64 timesliceCount2;
+ int i;
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_138", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_TaskLock();
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ 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, 1, g_testCount);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask138(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask138", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_139.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_139.c
new file mode 100644
index 0000000000000000000000000000000000000000..4222b3f33ece653a9c7e385cc19571027f40304d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_139.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_139", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_YIELD_IN_INT, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask139(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask139", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_141.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_141.c
new file mode 100644
index 0000000000000000000000000000000000000000..e2db4ba18c9ce5dbb51e18a9b067257b1b453b62
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_141.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_141", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() - 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_YIELD_IN_INT, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM))); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestBusyTaskDelay(5); // 5, set delay time
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ return LOS_NOK;
+}
+
+void ItSmpLosTask141(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask141", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_142.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_142.c
new file mode 100644
index 0000000000000000000000000000000000000000..fd0086114978e93affddf73dce7f8689123f93fc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_142.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT64 timesliceCount1;
+ UINT64 timesliceCount2;
+ int i;
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_142", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+
+ LOS_TaskLock();
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ LOS_TaskUnlock();
+
+ TestBusyTaskDelay(2 * LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT); // 2, used to calculate delay time
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask142(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask142", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_143.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_143.c
new file mode 100644
index 0000000000000000000000000000000000000000..a88d61de1ec70763037f031fe5dbc61e095530c0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_143.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_143", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_YIELD_IN_INT, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_TaskUnlock();
+
+ /* wait for TaskF01 is finished */
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask143(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask143", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_144.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_144.c
new file mode 100644
index 0000000000000000000000000000000000000000..cc042f7de92bd51a7441155aca3c91f60eab428c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_144.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF02(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_144", (TSK_ENTRY_FUNC)TaskF02, TASK_PRIO_TEST_TASK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() - 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_140", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_TaskLock();
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestBusyTaskDelay(20); // 20, set delay time
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_READY), 0, ret, EXIT);
+
+ LOS_TaskUnlock();
+
+ TestBusyTaskDelay(LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT * 2); // 2, used to calculate delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask144(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask144", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_145.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_145.c
new file mode 100644
index 0000000000000000000000000000000000000000..02ab477c501a91a55d4e08db32de615dbde53832
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_145.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_145", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() - 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_TSK_YIELD_IN_INT, ret);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM))); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ /* wait for Hwi is finished */
+ while (g_testCount == 0) {
+ }
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_TaskUnlock();
+
+ TestBusyTaskDelay(2 * LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT); // 2, Used to calculate delay time.
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask145(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask145", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_146.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_146.c
new file mode 100644
index 0000000000000000000000000000000000000000..945737a3fd9e8432788df4e8b9889271b9ea65d1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_146.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ while (g_testCount == 1) {
+ }
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+
+ // 2, Used to calculate priority.
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_146", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 2);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ while (g_testCount == 0) {
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ // 2, assert that g_testCount is equal to this.
+ while (g_testCount == 2) {
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask146(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask146", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_147.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_147.c
new file mode 100644
index 0000000000000000000000000000000000000000..025b874bce920102c07a4d0fcee9eadf0255a0d9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_147.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ while (g_testCount == 1) {
+ }
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_147", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ while (g_testCount == 0) {
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ // 2, assert that g_testCount is eaual to this.
+ while (g_testCount == 2) {
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask147(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask147", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_148.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_148.c
new file mode 100644
index 0000000000000000000000000000000000000000..04b07414d9074879beb214979825828fe6959487
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_148.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_148", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_GOTO_EQUAL(ret, TASK_PRIO_TEST_TASK - 2, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ LOS_TaskDelay(11); // 11, set a delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask148(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask148", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_149.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_149.c
new file mode 100644
index 0000000000000000000000000000000000000000..e62bd377655348bc770e4a2b0cb8a02065bd4e94
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_149.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ // 50, sem timeout time.
+ ret = LOS_SemPend(g_semID, 50);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_149", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_GOTO_EQUAL(ret, TASK_PRIO_TEST_TASK - 2, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_NOK;
+}
+
+void ItSmpLosTask149(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask149", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_150.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_150.c
new file mode 100644
index 0000000000000000000000000000000000000000..e788126cb4a84c22e98b3f28112cf75e45a855d1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_150.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_150", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ TestBusyTaskDelay(5); // 5, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(20); // 20, set delay time
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask150(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask150", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_151.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_151.c
new file mode 100644
index 0000000000000000000000000000000000000000..42c66ec09f1809c933d16dd454e8b60af5f60147
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_151.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_151", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret, EXIT);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_GOTO_EQUAL(ret, TASK_PRIO_TEST_TASK - 2, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask151(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask151", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_152.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_152.c
new file mode 100644
index 0000000000000000000000000000000000000000..56f2a040d8f7c3d9f1858a4a9c763de8393f83ae
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_152.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_152", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+ int i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL((ret & OS_TASK_STATUS_SUSPEND), 0, ret);
+
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ TestBusyTaskDelay(2); // 2, set delay time
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask152(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask152", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_153.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_153.c
new file mode 100644
index 0000000000000000000000000000000000000000..c2c41ec1892b1fcdb3bd317c27e6f5f48b43a676
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_153.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, (OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED), ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_153", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 2);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+void ItSmpLosTask153(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask153", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_154.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_154.c
new file mode 100644
index 0000000000000000000000000000000000000000..9a67bdf8c639380177abefec129887826b79fa41
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_154.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, (OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_DETACHED), ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 2, ret);
+
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK - 1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_154", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 2);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ // 4, assert that g_testCount is equal to this.
+ while (g_testCount != 4) {
+ }
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, assert that g_testCount is equal to this.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_UNUSED), 0, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask154(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask154", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_155.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_155.c
new file mode 100644
index 0000000000000000000000000000000000000000..efb834a7edc2a6a0fe322d131e3a0a65275cb120
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_155.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ LOS_TaskLock();
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK + 1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK + 1, ret);
+
+ LOS_TaskUnlock();
+
+ LOS_AtomicInc(&g_testCount);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_155", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, TASK_PRIO_TEST_TASK + 1, ret, EXIT);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_NOK;
+}
+
+void ItSmpLosTask155(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask155", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_156.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_156.c
new file mode 100644
index 0000000000000000000000000000000000000000..53a79e503bcc6af2ac11cdf0f2ef64d926dfdf24
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_156.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskLock();
+
+ TestBusyTaskDelay(20); // 20, set delay time
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, TASK_PRIO_TEST_TASK + 1, ret);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF02(void)
+{
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_156", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK;
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; 1, test runing count
+
+ LOS_AtomicInc(&g_testCount);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, TASK_PRIO_TEST_TASK - 1, ret);
+
+ ret = LOS_TaskPriSet(g_testTaskID01, TASK_PRIO_TEST_TASK + 1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskPriGet(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, TASK_PRIO_TEST_TASK + 1, ret);
+
+ while (g_testCount != 4) { // 4, assert that g_testCount is equal to this.
+ }
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, assert that g_testCount is equal to this.
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask156(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask156", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_157.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_157.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d5953b35326b394d7b689db6da767f78ff7b3da
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_157.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_ASSERT_NOT_EQUAL_VOID((ret & OS_TASK_STATUS_RUNNING), 0, ret);
+
+ ret = LOS_TaskCpuAffiSet(g_testTaskID01, CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM)));
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ArchCurrCpuid(), ArchCurrCpuid() + 1, ArchCurrCpuid());
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_157", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask157(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask157", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_158.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_158.c
new file mode 100644
index 0000000000000000000000000000000000000000..5a0158ca0aaa68b0116f86efcb57dacc3acffacd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_158.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_TaskYield();
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static void TaskF02(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 testid[2];
+ int i;
+ g_testCount = 0;
+
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_158", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ for (i = 0; i < 100; i++) { // 100, Number of cycles.
+ TestBusyTaskDelay(LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT - 1);
+
+ /* if same priority task is executed£¬break loop */
+ if (g_testCount != i) {
+ break;
+ }
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ /* if same priority task is executed£¬break loop */
+ if (g_testCount != i + 1) {
+ break;
+ }
+ }
+
+ ICUNIT_GOTO_NOT_EQUAL(g_testCount, 100, g_testCount, EXIT); // 100, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask158(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask158", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_159.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_159.c
new file mode 100644
index 0000000000000000000000000000000000000000..50a91c2100adecfbf0878d507bd2dafb2dc08abd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_159.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static EVENT_CB_S g_eventCb01;
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static void TaskF02(void)
+{
+ UINT32 ret;
+ int i;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 200; i++) { // 200, Number of cycles.
+ }
+ /* It is possible that TaskF01 is finished. */
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_EventWrite(&g_eventCb01, 0x1);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ int i, j;
+ LOS_EventInit(&g_eventCb01);
+
+ for (i = 0; i < IT_TASK_SMP_LOOP; i++) {
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT_AFFI(task1, "it_smp_task_159_1", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1, 0);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(task1, "it_smp_task_159_2", (TSK_ENTRY_FUNC)TaskF02, TASK_PRIO_TEST_TASK - 1, 0);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ /* wait for task02 start */
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ for (j = 0; j < TRandom() % 200; j++) { // 200, Number of cycles.
+ }
+ /* It is possible that delete TaskF01 first. */
+ ret = LOS_TaskResume(g_testTaskID01);
+ if (ret != LOS_ERRNO_TSK_NOT_CREATED && ret != LOS_OK) {
+ goto EXIT;
+ }
+
+ /* possible value of g_testCount are 2, 3, 4 */
+ if (g_testCount != 2 && g_testCount != 3 && g_testCount != 4) {
+ goto EXIT;
+ }
+
+ ret = LOS_EventRead(&g_eventCb01, 0x11, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x1, ret, EXIT);
+
+ TestBusyTaskDelay(2); // 2, set delay time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(!(ret & OS_TASK_STATUS_UNUSED), 0, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_EQUAL(!(ret & OS_TASK_STATUS_UNUSED), 0, ret, EXIT);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask159(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask159", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_160.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_160.c
new file mode 100644
index 0000000000000000000000000000000000000000..f399a1d45744126def77b281a6167c6072002265
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_160.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(g_testCount);
+
+ while (1) {
+ }
+
+ LOS_AtomicInc(g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT_AFFI(task1, "it_smp_task_160", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 1, 0);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(LOSCFG_KERNEL_CORE_NUM);
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_UNUSED, ret, EXIT);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+
+ return LOS_OK;
+}
+
+void ItSmpLosTask160(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask160", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_161.c b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_161.c
new file mode 100644
index 0000000000000000000000000000000000000000..fd982d98d2b961179e5cbb8b8d9443779f481b0f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/core/task/smp/It_smp_los_task_161.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_task.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void TaskF01(void)
+{
+ LOS_AtomicInc(&g_testCount);
+
+ while (1) {
+ }
+}
+
+static void TaskF02(void)
+{
+ LOS_AtomicInc(&g_testCount);
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ g_testCount = 0;
+
+ // 2, It is used to calculate a priority relative to TASK_PRIO_TEST_TASK.
+ TEST_TASK_PARAM_INIT(task1, "it_smp_task_161", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST_TASK - 2);
+
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.usTaskPrio = TASK_PRIO_TEST_TASK - 1;
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM));
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; 1, test runing count
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskCpuAffiSet(g_testTaskID02, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert that g_testCount is equal to this.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_NOK;
+}
+
+void ItSmpLosTask161(void)
+{
+ TEST_ADD_CASE("ItSmpLosTask161", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/BUILD.gn b/testsuites/kernel/sample/kernel_base/ipc/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..e8844f445335d3257d7fd78762cdf0b321b4d370
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/BUILD.gn
@@ -0,0 +1,39 @@
+static_library("test_ipc") {
+
+ sources = [
+ "sem/It_los_sem.c",
+ "event/It_los_event.c",
+ "mux/It_los_mux.c",
+ "queue/It_los_queue.c",
+ ]
+
+ if (LOSCFG_TEST_SMOKE) {
+ sources += [
+ "sem/smoke/It_los_sem_001.c",
+ "sem/smoke/It_los_sem_003.c",
+ "sem/smoke/It_los_sem_006.c",
+ "event/smoke/It_los_event_031.c",
+ "event/smoke/It_los_event_035.c",
+ "event/smoke/It_los_event_036.c",
+ "event/smoke/It_los_event_041.c",
+ "mux/smoke/It_los_mutex_001.c",
+ "mux/smoke/It_los_mutex_002.c",
+ "mux/smoke/It_los_mutex_003.c",
+ "mux/smoke/It_los_mutex_004.c",
+ "queue/smoke/It_los_queue_001.c",
+ "queue/smoke/It_los_queue_097.c",
+ "queue/smoke/It_los_queue_100.c",
+ "queue/smoke/It_los_queue_105.c",
+ "queue/smoke/It_los_queue_head_002.c",
+ ]
+ }
+ include_dirs = [
+ "../../../include/",
+ "sem",
+ "event",
+ "mux",
+ "queue",
+ ]
+
+ cflags = [ "-Wno-error" ]
+}
diff --git a/testsuites/kernel/sample/kernel_base/ipc/Makefile b/testsuites/kernel/sample/kernel_base/ipc/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..2db39fc5b23e57ac8f3602325c37714e19e89924
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/Makefile
@@ -0,0 +1,51 @@
+
+include $(LITEOSTESTTOPDIR)/config.mk
+
+MODULE_NAME := ipctest
+
+LOCAL_INCLUDE := \
+ -I $(LITEOSTESTTOPDIR)/kernel/include \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/kernel_base/ipc/mux \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/kernel_base/ipc/sem \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/kernel_base/ipc/event \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/kernel_base/ipc/queue \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/kernel_base/ipc/rwlock
+
+SRC_MODULES := sem event queue mux rwlock
+
+ifeq ($(LOSCFG_KERNEL_SMP), y)
+SMP_MODULES := sem/smp event/smp queue/smp mux/smp rwlock/smp
+endif
+
+ifeq ($(LOSCFG_TEST_LLT), y)
+LLT_MODULES := sem/llt event/llt queue/llt mux/llt
+endif
+
+ifeq ($(LOSCFG_TEST_PRESSURE), y)
+PRESSURE_MODULES := sem/pressure event/pressure queue/pressure mux/pressure
+endif
+
+ifeq ($(LOSCFG_TEST_SMOKE), y)
+SMOKE_MODULES := sem/smoke event/smoke queue/smoke mux/smoke rwlock/smoke
+endif
+
+ifeq ($(LOSCFG_TEST_FULL), y)
+FULL_MODULES := sem/full event/full queue/full mux/full
+endif
+
+ifeq ($(LOSCFG_TEST_MANUAL_SHELL), y)
+MANUAL_MODULES := sem/manual event/manual queue/manual
+endif
+
+ifeq ($(LOSCFG_TEST_MANUAL_TEST), y)
+MANUAL_MODULES :=sem/manual event/manual queue/manual mux/manual
+endif
+
+LOCAL_MODULES := $(SRC_MODULES) $(LLT_MODULES) $(PRESSURE_MODULES) $(SMOKE_MODULES) $(FULL_MODULES) $(SMP_MODULES) $(MANUAL_MODULES)
+
+LOCAL_SRCS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.c))
+LOCAL_CHS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.h))
+
+LOCAL_FLAGS := $(LOCAL_INCLUDE) -Wno-error
+
+include $(MODULE)
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/It_los_event.c b/testsuites/kernel/sample/kernel_base/ipc/event/It_los_event.c
new file mode 100644
index 0000000000000000000000000000000000000000..ee305b7f2636b127a99c355e394796e39253a939
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/It_los_event.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+VOID ItSuiteLosEvent(VOID)
+{
+#if (LOSCFG_KERNEL_SMP == YES)
+ ItSmpLosEvent001();
+ ItSmpLosEvent002();
+ ItSmpLosEvent003();
+ ItSmpLosEvent004();
+ ItSmpLosEvent005();
+ ItSmpLosEvent006();
+ ItSmpLosEvent007();
+ ItSmpLosEvent008();
+ ItSmpLosEvent009();
+ ItSmpLosEvent010();
+ ItSmpLosEvent011();
+ ItSmpLosEvent012();
+ ItSmpLosEvent013();
+ ItSmpLosEvent014();
+ ItSmpLosEvent015();
+ ItSmpLosEvent016();
+ ItSmpLosEvent017();
+ ItSmpLosEvent018();
+ ItSmpLosEvent019();
+ ItSmpLosEvent020();
+ ItSmpLosEvent021();
+ ItSmpLosEvent022();
+ ItSmpLosEvent023();
+ ItSmpLosEvent024();
+ ItSmpLosEvent025();
+ ItSmpLosEvent027();
+
+ ItSmpLosEvent029();
+ ItSmpLosEvent030();
+ ItSmpLosEvent031();
+ ItSmpLosEvent032();
+ ItSmpLosEvent034();
+ ItSmpLosEvent037();
+#endif
+
+#if defined(LOSCFG_TEST_SMOKE)
+ ItLosEvent031(); // 0 destroy
+ ItLosEvent035(); // 0 init
+ ItLosEvent036(); // 0 clear destroy write read
+ ItLosEvent041(); // 0 read
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+ ItLosEvent001();
+ ItLosEvent002();
+ ItLosEvent003();
+ ItLosEvent004();
+ ItLosEvent005(); // write clear destroy
+ ItLosEvent006();
+ ItLosEvent007();
+ ItLosEvent008();
+ ItLosEvent009(); // read
+ ItLosEvent010();
+ ItLosEvent011();
+ ItLosEvent012();
+ ItLosEvent013();
+ ItLosEvent014();
+ ItLosEvent015();
+ ItLosEvent016();
+ ItLosEvent018();
+ ItLosEvent019();
+ ItLosEvent020();
+ ItLosEvent021();
+ ItLosEvent022();
+ ItLosEvent023();
+ ItLosEvent024();
+ ItLosEvent025();
+#if (LOSCFG_KERNEL_SMP != YES)
+ ItLosEvent026();
+#endif
+ ItLosEvent027();
+ ItLosEvent029();
+ ItLosEvent030();
+ ItLosEvent032();
+ ItLosEvent033(); // /
+ ItLosEvent037();
+ ItLosEvent038();
+#if (LOSCFG_KERNEL_SMP != YES)
+ ItLosEvent039();
+#endif
+ ItLosEvent040();
+ ItLosEvent042();
+ ItLosEvent043();
+#endif
+
+#if defined(LOSCFG_TEST_PRESSURE)
+ ItLosEvent028();
+#endif
+
+#if defined(LOSCFG_TEST_LLT)
+ LltLosEvent001();
+ ItLosEvent017();
+ ItLosEvent034();
+#endif
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, 1);
+#endif
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/It_los_event.h b/testsuites/kernel/sample/kernel_base/ipc/event/It_los_event.h
new file mode 100644
index 0000000000000000000000000000000000000000..61451f0c3f376c0083809049a55407471866954b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/It_los_event.h
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IT_LOS_EVENT_H
+#define IT_LOS_EVENT_H
+
+#include "osTest.h"
+#include "los_base_pri.h"
+#include "los_task_pri.h"
+#include "los_tick_pri.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define LOOP 100
+
+#define SELF_DELETED 0
+#define SYS_EXIST_SWTMR 1
+#define SWTMR_LOOP_NUM 10
+#define TEST_HWI_RUNTIME 0x100000
+#define TASK_LOOP_NUM 0x100000
+
+#define TASK_NAME_NUM 10
+#define IT_TASK_LOOP 20
+
+extern UINT32 g_testTaskID01;
+extern UINT32 g_testTaskID02;
+extern UINT32 g_testTaskID03;
+extern UINT32 g_testQueueID01;
+extern UINT32 g_TestTskHandle;
+extern UINT32 g_swTmrMaxNum;
+
+extern UINT16 usSwTmrID1;
+extern UINT16 usSwTmrID2;
+extern UINT16 usSwTmrID3;
+
+extern UINT32 SwtmrCountA;
+extern UINT32 SwtmrCountB;
+extern UINT32 SwtmrCountC;
+extern UINT64 CpuTickCountA;
+extern UINT64 CpuTickCountB;
+
+typedef struct tagHwTmrTCR {
+ UINT16 rsvd1 : 4; // 3:0 Reserved
+ UINT16 TSS : 1; // 4 Timer Start/Stop
+ UINT16 TRB : 1; // 5 Timer reload
+ UINT16 rsvd2 : 4; // 9:6 Reserved
+ UINT16 SOFT : 1; // 10 Emulation modes
+ UINT16 FREE : 1; // 11
+ UINT16 rsvd3 : 2; // 12:13 Reserved
+ UINT16 TIE : 1; // 14 Output enable
+ UINT16 TIF : 1; // 15 Interrupt flag
+} HWTMR_TCR;
+
+typedef struct tagHwTmr {
+ volatile UINT32 vuwTIM;
+ volatile UINT32 vuwPRD;
+ volatile HWTMR_TCR stTCR;
+ volatile UINT16 vusReserved;
+ volatile UINT16 vusTPR;
+ volatile UINT16 vusTPRH;
+} OS_HWTMR_S;
+
+extern OS_HWTMR_S *g_pstHwTmrMap;
+extern VOID LOS_GetCpuTick(UINT32 *puwCntHi, UINT32 *puwCntLo);
+extern VOID ItSuiteLosEvent(VOID);
+
+#if defined(LOSCFG_TEST_SMOKE)
+extern VOID ItLosEvent031(VOID);
+extern VOID ItLosEvent035(VOID);
+extern VOID ItLosEvent036(VOID);
+extern VOID ItLosEvent041(VOID);
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+extern VOID ItLosEvent001(VOID);
+extern VOID ItLosEvent002(VOID);
+extern VOID ItLosEvent003(VOID);
+extern VOID ItLosEvent004(VOID);
+extern VOID ItLosEvent005(VOID);
+extern VOID ItLosEvent006(VOID);
+extern VOID ItLosEvent007(VOID);
+extern VOID ItLosEvent008(VOID);
+extern VOID ItLosEvent009(VOID);
+extern VOID ItLosEvent010(VOID);
+extern VOID ItLosEvent011(VOID);
+extern VOID ItLosEvent012(VOID);
+extern VOID ItLosEvent013(VOID);
+extern VOID ItLosEvent014(VOID);
+extern VOID ItLosEvent015(VOID);
+extern VOID ItLosEvent016(VOID);
+extern VOID ItLosEvent018(VOID);
+extern VOID ItLosEvent019(VOID);
+extern VOID ItLosEvent020(VOID);
+extern VOID ItLosEvent021(VOID);
+extern VOID ItLosEvent022(VOID);
+extern VOID ItLosEvent023(VOID);
+extern VOID ItLosEvent024(VOID);
+extern VOID ItLosEvent025(VOID);
+extern VOID ItLosEvent026(VOID);
+extern VOID ItLosEvent027(VOID);
+extern VOID ItLosEvent029(VOID);
+extern VOID ItLosEvent030(VOID);
+extern VOID ItLosEvent032(VOID);
+extern VOID ItLosEvent033(VOID);
+extern VOID ItLosEvent037(VOID);
+extern VOID ItLosEvent038(VOID);
+extern VOID ItLosEvent039(VOID);
+extern VOID ItLosEvent040(VOID);
+extern VOID ItLosEvent042(VOID);
+extern VOID ItLosEvent043(VOID);
+#endif
+
+#if defined(LOSCFG_TEST_PRESSURE)
+extern VOID ItLosEvent028(VOID);
+#endif
+#if defined(LOSCFG_TEST_LLT)
+extern VOID LltLosEvent001(VOID);
+extern VOID ItLosEvent017(VOID);
+extern VOID ItLosEvent034(VOID);
+#endif
+
+#if (LOSCFG_KERNEL_SMP == YES)
+VOID ItSmpLosEvent001(VOID);
+VOID ItSmpLosEvent002(VOID);
+VOID ItSmpLosEvent003(VOID);
+VOID ItSmpLosEvent004(VOID);
+VOID ItSmpLosEvent005(VOID);
+VOID ItSmpLosEvent006(VOID);
+VOID ItSmpLosEvent007(VOID);
+VOID ItSmpLosEvent008(VOID);
+VOID ItSmpLosEvent009(VOID);
+VOID ItSmpLosEvent010(VOID);
+VOID ItSmpLosEvent011(VOID);
+VOID ItSmpLosEvent012(VOID);
+VOID ItSmpLosEvent013(VOID);
+VOID ItSmpLosEvent014(VOID);
+VOID ItSmpLosEvent015(VOID);
+VOID ItSmpLosEvent016(VOID);
+VOID ItSmpLosEvent017(VOID);
+VOID ItSmpLosEvent018(VOID);
+VOID ItSmpLosEvent019(VOID);
+VOID ItSmpLosEvent020(VOID);
+VOID ItSmpLosEvent021(VOID);
+VOID ItSmpLosEvent022(VOID);
+VOID ItSmpLosEvent023(VOID);
+VOID ItSmpLosEvent024(VOID);
+VOID ItSmpLosEvent025(VOID);
+VOID ItSmpLosEvent026(VOID);
+VOID ItSmpLosEvent027(VOID);
+VOID ItSmpLosEvent028(VOID);
+VOID ItSmpLosEvent029(VOID);
+VOID ItSmpLosEvent030(VOID);
+VOID ItSmpLosEvent031(VOID);
+VOID ItSmpLosEvent032(VOID);
+VOID ItSmpLosEvent033(VOID);
+VOID ItSmpLosEvent034(VOID);
+VOID ItSmpLosEvent035(VOID);
+VOID ItSmpLosEvent036(VOID);
+VOID ItSmpLosEvent037(VOID);
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+#endif /* IT_LOS_EVENT_H */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_001.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..48a40bc731afd83f8cf65312f9526aebd953ad13
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_001.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ g_testCount++;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk1";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(1);
+
+ ret = LOS_EventWrite(&g_event, 0x10);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_EventWrite(&g_event, 0x1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2.
+
+ return LOS_OK;
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_EventDestroy(&g_event);
+ return LOS_OK;
+}
+
+VOID ItLosEvent001(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent001", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_002.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..758036c4110e58e5ed397e2c19f7bac1806e2a50
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_002.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 3); // 3, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_READ_TIMEOUT, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2.
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x4, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk2";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ TestExtraTaskDelay(1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x2);
+
+ LOS_TaskDelay(3); // 3, delay enouge time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to 3.
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x11);
+
+ LOS_TaskDelay(4); // 4, delay enouge time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to 4.
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent002(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent002", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_003.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..71b5045fdd86abc6fb15773eef9ce4c6a20e7591
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_003.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 10); // 10, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_READ_TIMEOUT, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+ g_testCount++;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_EventDestroy(&g_event);
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk3";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_EventDestroy(&g_event);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent003(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent003", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_004.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..3b080e9fcbcdeef3b867c3aa1796a70850683d59
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_004.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0xFFFFFFFF, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_SETBIT_INVALID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk4";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ g_event.uwEventID = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0xFFFFFFFF);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_SETBIT_INVALID, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, Here, assert that g_testCount is equal to 3.
+
+EXIT1:
+
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+VOID ItLosEvent004(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent004", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_005.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..bdfecffaab44960dedfcd7fb3f905adfe13f5157
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_005.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_EventWrite(NULL, 0x1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_EVENT_PTR_NULL, ret);
+
+ g_event.uwEventID = 0;
+ LOS_EventInit(&g_event);
+
+ LOS_EventWrite(&g_event, 0x1);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 1, g_event.uwEventID, EXIT);
+
+ LOS_EventWrite(&g_event, 0);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 1, g_event.uwEventID, EXIT);
+
+ LOS_EventWrite(&g_event, 0x10);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11, g_event.uwEventID, EXIT);
+
+ ret = LOS_EventWrite(&g_event, 0xFFFFFFFF);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_SETBIT_INVALID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11, g_event.uwEventID, EXIT);
+EXIT:
+
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent005(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent005", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_006.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..84bd9b90ad88fb115c55fbc9d6f8857a7c3fd2d6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_006.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x00000110, LOS_WAITMODE_OR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x10, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x00000110, LOS_WAITMODE_AND, 4); // 4, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x110, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk6";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ g_event.uwEventID = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x10);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, Here, assert that g_testCount is equal to 3.
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x110);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT1); // 5, Here, assert that g_testCount is equal to 5.
+
+EXIT1:
+
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent006(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent006", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_007.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..7823fa10abe4cb5385a5e73eaeba0d64fb34cfc7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_007.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ UINT32 event;
+
+ g_testCount++;
+
+ g_event.uwEventID = 0;
+ LOS_EventInit(&g_event);
+
+ LOS_EventWrite(&g_event, 0x10);
+
+ ret = LOS_EventRead(&g_event, 0x00000110, LOS_WAITMODE_OR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x10, g_event.uwEventID, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x110);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x110, g_event.uwEventID, EXIT);
+
+ ret = LOS_EventRead(&g_event, 0x00000110, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x110, g_event.uwEventID, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x00000011, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x110, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+EXIT:
+
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk7";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+VOID ItLosEvent007(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent007", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_008.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..5f9caa63c6f126fd617b69de7b90d144fc048929
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_008.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0, LOS_WAITMODE_OR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_EVENTMASK_INVALID, ret, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x0FFFFFFF, LOS_WAITMODE_OR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_SETBIT_INVALID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk8";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ g_event.uwEventID = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x10011);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x10011, g_event.uwEventID, EXIT1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT1); // 4, Here, assert that g_testCount is equal to 4.
+
+EXIT1:
+
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent008(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent008", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_009.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..214fa11f056ea4b96d08ce739a2014fd1f837849
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_009.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 "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_EventRead(NULL, 0x11, LOS_WAITMODE_OR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_PTR_NULL, ret, EXIT);
+
+ ret = LOS_EventRead(&g_event, 0, LOS_WAITMODE_OR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_EVENTMASK_INVALID, ret, EXIT);
+
+ ret = LOS_EventRead(&g_event, 0xffffffff, LOS_WAITMODE_OR, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_SETBIT_INVALID, ret, EXIT);
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, 0xffffffff, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_FLAGS_INVALID, ret, EXIT);
+
+ ret = LOS_EventRead(&g_event, 0x11, 0, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_FLAGS_INVALID, ret, EXIT);
+
+ ret = LOS_EventRead(&g_event, 0x11, (LOS_WAITMODE_AND | LOS_WAITMODE_OR | LOS_WAITMODE_CLR), LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_FLAGS_INVALID, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk9";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ // 24, Set the priority according to the task purpose,a smaller number means a higher priority.
+ task1.usTaskPrio = 24;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to 3.
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent009(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent009", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_010.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..ff0e6d67ac8df63ce0d8a269c32587a37df89a25
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_010.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x1, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk10";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_EventRead(&g_event, 0x1, LOS_WAITMODE_AND, 1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_READ_TIMEOUT, ret, EXIT);
+
+ ret = LOS_EventRead(&g_event, 0x1, LOS_WAITMODE_AND, 1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_READ_TIMEOUT, ret, EXIT);
+
+ ret = LOS_EventRead(&g_event, 0x1, LOS_WAITMODE_AND, 2); // 2, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_READ_TIMEOUT, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0x10);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT1); // 2, Here, assert that g_testCount is equal to 2.
+
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0x1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT1); // 5, Here, assert that g_testCount is equal to 5.
+
+EXIT1:
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent010(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent010", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_011.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..5bd31ef7a1f2a29f260511036ed4f9499d343ab4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_011.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 5); // 5, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_READ_TIMEOUT, ret, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_NOT_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(ret, 0x11, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk11";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x100);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT1); // 2, Here, assert that g_testCount is equal to 2.
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x1000);
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, Here, assert that g_testCount is equal to 3.
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x10000);
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT1); // 4, Here, assert that g_testCount is equal to 4.
+
+ g_testCount++;
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT1); // 7, Here, assert that g_testCount is equal to 7.
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 8, g_testCount, EXIT1); // 8, Here, assert that g_testCount is equal to 8.
+
+EXIT1:
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent011(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent011", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_012.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..1ff137c7299c27bcca9577043ee24f1d52f313c7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_012.c
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x110, LOS_WAITMODE_OR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x10, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11010, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x1001, LOS_WAITMODE_OR, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0x1000, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11010, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 2); // 2, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, 0x11, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11011, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x1100, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk12";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0x11010);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ TestExtraTaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT1); // 4, Here, assert that g_testCount is equal to 4.
+
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0x1001);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ LOS_TaskDelay(3); // 3, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT1); // 7, Here, assert that g_testCount is equal to 7.
+
+EXIT1:
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent012(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent012", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_013.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..e5138c2be0397bc2fa005a340ef62a109af02e75
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_013.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_OR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_NOT_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(ret, 0x11, ret, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x1100, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_NOT_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(ret, 0x1100, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11111111, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x110000, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x110000, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11001111, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11000000, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x11000000, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x00001111, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk13";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x11111111);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT1); // 6, Here, assert that g_testCount is equal to 3.
+
+EXIT1:
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent013(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent013", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_014.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_014.c
new file mode 100644
index 0000000000000000000000000000000000000000..efa807927e76f597a21afed099cf26d4841e5c00
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_014.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x01, LOS_WAITMODE_OR, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0x01, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x01, LOS_WAITMODE_OR, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0x01, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk14";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT1); // 5, Here, assert that g_testCount is equal to 5.
+
+EXIT1:
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent014(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent014", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_015.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..9f137bd87903ec11f31bcf681eb837fdb0391952
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_015.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0x11, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x1111, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+ ret = LOS_EventRead(&g_event, 0x1100, LOS_WAITMODE_AND, 2); // 2, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, 0x1100, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x1111, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk15";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount < 1);
+
+ LOS_EventWrite(&g_event, 0x1111);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestAssertBusyTaskDelay(100, 4); // 100, Set the timeout of runtime; 4, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT1); // 4, Here, assert that g_testCount is equal to 4.
+
+EXIT1:
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_EventDestroy(&g_event);
+ return LOS_OK;
+}
+
+VOID ItLosEvent015(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent015", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_016.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_016.c
new file mode 100644
index 0000000000000000000000000000000000000000..6bc9a0bb6eb83d0ee1d3b126dbd0eee8080c9683
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_016.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk16";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT1); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT1:
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent016(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent016", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_018.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..cb6b34b0cce40f7d1028d656bff86ccf3b50e591
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_018.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0x10);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP != YES)
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
+#endif
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x10, LOS_WAITMODE_AND, 10); // 10, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, 0x10, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EvtTsk18A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "EvtTs18B";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ TestExtraTaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, Here, assert that g_testCount is equal to 5.
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent018(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent018", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_019.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..641b7d58f053fe45c1bfad4cb2eb8e0f3def61c0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_019.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ UINT32 index = 10000 - 1; // 10000 - 1, init
+ UINT32 value;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0x10);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ g_testCount++;
+ HAL_READ_UINT32(&index, value);
+
+ while (value < 10000) { // 10000, loop num
+ HAL_READ_UINT32(&index, value);
+ index--;
+ }
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EvtTsk19A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "EvTsk19B";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT1); // 5, Here, assert that g_testCount is equal to 5.
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_EventDestroy(&g_event);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent019(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent019", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_020.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..118fb0b86325f5223c982855db5cfd913857e0e8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_020.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ UINT32 index = 10000 - 1; // 10000 - 1, init
+ UINT32 value;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+ g_testCount++;
+
+ HAL_READ_UINT32(&index, value);
+
+ while (value < 10000) { // 10000, loop num
+ HAL_READ_UINT32(&index, value);
+ index--;
+ }
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_OR, 20); // 20, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(ret, 0x11, ret, EXIT);
+
+ g_testCount++;
+
+ LOS_TaskDelay(30); // 30, delay enouge time
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EvtTsk20A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "EvtTsk20B";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT1); // 5, Here, assert that g_testCount is equal to 5.
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_EventDestroy(&g_event);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent020(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent020", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_021.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..27b1c7745da29205e6a352465c52a8879720ae4f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_021.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x11);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "EvtTsk21B";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EvtTsk21A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(5); // 5, delay enouge time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, Here, assert that g_testCount is equal to 5.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent021(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent021", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_022.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..794af7dad704cce765a90b25f74dd43172a70bdc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_022.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EvtTsk22A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "EvtTsk22B";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT1); // 4, Here, assert that g_testCount is equal to 4.
+ g_testCount++;
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT1); // 6, Here, assert that g_testCount is equal to 3.
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+ return LOS_OK;
+}
+
+VOID ItLosEvent022(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent022", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_023.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..f08a1c6f09f72c3c7d238cc7ae6d5aac7abc1e0f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_023.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0x11, ret);
+
+#if (LOSCFG_KERNEL_SMP != YES)
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+#endif
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0x11, ret);
+
+#if (LOSCFG_KERNEL_SMP != YES)
+ ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT); // 6, Here, assert that g_testCount is equal to 6.
+#endif
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EvtTsk23A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "EvtTsk23B";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 1;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT1); // 2, Here, assert that g_testCount is equal to 2.
+ g_testCount++;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 0, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 7, g_testCount); // 7, Here, assert that g_testCount is equal to 7.
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent023(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent023", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_024.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_024.c
new file mode 100644
index 0000000000000000000000000000000000000000..988a6d1b57b8567b27f6f6b61fce349d461fc88e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_024.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x1, LOS_WAITMODE_AND, 10); // 10, The timeout period for reading events.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_EVENT_READ_IN_INTERRUPT, ret);
+
+ g_testCount++;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent024(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent024", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_025.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_025.c
new file mode 100644
index 0000000000000000000000000000000000000000..e582f5df6685f314db43ad4a92f5dde6960f7d88
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_025.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+extern VOID LOS_GetCpuCycle(UINT32 *puwCntHi, UINT32 *puwCntLo);
+
+static UINT64 TestGetCurCycle(VOID)
+{
+ UINT32 cntHi;
+ UINT32 cntLo;
+ UINT64 curCycle;
+
+ LOS_GetCpuCycle(&cntHi, &cntLo);
+ curCycle = ((UINT64)cntHi << 32) | cntLo; // 32, High byte
+
+ return curCycle;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT64 osEndTime;
+ UINT64 osStartTime;
+ UINT32 tickNum;
+ LOS_EventInit(&g_event);
+
+ osStartTime = TestGetCurCycle();
+
+ ret = LOS_EventRead(&g_event, 0x1, LOS_WAITMODE_AND, 10); // 10, The timeout period for reading events.
+
+ osEndTime = TestGetCurCycle();
+
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_EVENT_READ_TIMEOUT, ret);
+
+ tickNum = (osEndTime - osStartTime) * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_CLOCK;
+
+ if (tickNum < (10 - 2) && tickNum > (10 + 2)) { // when tick num in 10 - 2 or 10 + 2 interval
+ ICUNIT_ASSERT_EQUAL(tickNum, 0, tickNum);
+ }
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent025(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent025", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_026.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..73069046a3cc26a2199a5e39db159e762cd2b776
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_026.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_TaskLock();
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(ret, 0x11, ret, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(ret, 0x11, ret, EXIT);
+
+ g_testCount++;
+
+ LOS_TaskUnlock();
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk26";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT1);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, Here, assert that g_testCount is equal to 3.
+
+EXIT1:
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent026(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent026", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_027.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..bcd10b3368c6b09666bc39ce1e712d11ebd1101e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_027.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testeventCount1;
+static UINT32 g_eventMask;
+
+static VOID SwtmrF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ g_eventMask = g_eventMask | (1 << g_testCount);
+
+ if (g_testCount > 17) // g_testCount > 17, do noting return
+ return;
+
+ ret = LOS_EventWrite(&g_event, g_eventMask);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ int value;
+ HAL_READ_UINT32(&g_testCount, value);
+
+ while (value < 16) { // if value < 16, read
+ HAL_READ_UINT32(&g_testCount, value);
+ }
+
+ ret = LOS_EventRead(&g_event, 0x1FFFF, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x1FFFF, g_event.uwEventID, EXIT);
+
+ g_testCount1++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ UINT16 swTmrID;
+
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk27";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ g_testeventCount1 = 0;
+ g_eventMask = 1;
+ g_testCount1 = 0;
+
+ LOS_EventInit(&g_event);
+
+ ret = LOS_SwtmrCreate(2, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID, 0xffff); // 2, Timeout interval of a periodic software timer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ LOS_TaskDelay(32 + TEST_TASKDELAY_2TICK); // 32 + TEST_TASKDELAY_2TICK, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount1, 1, g_testCount1, EXIT1);
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ return LOS_OK;
+}
+
+VOID ItLosEvent027(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent027", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_029.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..3ade02c9dbd79c87944cd1512506f8dd0b23378f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_029.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+
+ for (index = 0; index < 0xFF00; index++) {
+ ret = LOS_EventWrite(&g_event, 0xFF);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 event;
+ TSK_INIT_PARAM_S task1;
+ LOS_EventInit(&g_event);
+
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk29";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ret = LOS_EventRead(&g_event, 0xFF, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0xFF, g_event.uwEventID, EXIT1);
+
+EXIT1:
+
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent029(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent029", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_030.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_030.c
new file mode 100644
index 0000000000000000000000000000000000000000..b38249298d2b4a20a90651d7a692cab41925ec11
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_030.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 3); // 3, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_READ_TIMEOUT, ret, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk30";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ g_event.uwEventID = 1;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_TaskDelay(35); // 35, delay enouge time
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent030(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent030", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_032.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_032.c
new file mode 100644
index 0000000000000000000000000000000000000000..ec039583f519fb76bce5187c32512ddbfdf52cde
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_032.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_EventRead(&g_event, 0xF, LOS_WAITMODE_AND, 30); // 30, The timeout period for reading events.
+ ICUNIT_GOTO_NOT_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_EventRead(&g_event, 0xF, LOS_WAITMODE_AND, 31); // 31, The timeout period for reading events.
+ ICUNIT_GOTO_NOT_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static VOID TaskF03(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_EventRead(&g_event, 0xF, LOS_WAITMODE_AND, 32); // 32, The timeout period for reading events.
+ ICUNIT_GOTO_NOT_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID03);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk32A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 3; // 3, Set the priority according to the task purpose,a smaller number means a higher priority.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "EventTsk32B";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF03;
+ task1.pcName = "EventTsk32C";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ LOS_TaskDelay(50); // 50, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT2); // 3, Here, assert that g_testCount is equal to 3.
+
+EXIT2:
+ LOS_TaskDelete(g_testTaskID03);
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent032(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent032", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_033.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_033.c
new file mode 100644
index 0000000000000000000000000000000000000000..28a33c499f9ee316935c5d69ae8c2feccb5b2c39
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_033.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_EventRead(&g_event, 0xF, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0xF, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0, g_event.uwEventID, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0xF);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ret = LOS_EventRead(&g_event, 0xF, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0xF, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0, g_event.uwEventID, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0xF);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static VOID TaskF03(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ TestExtraTaskDelay(4); // 4, set delay time
+
+ ret = LOS_EventRead(&g_event, 0xF, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0xF, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0, g_event.uwEventID, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID03);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+
+ g_testCount = 0;
+ LOS_EventInit(&g_event);
+
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk33A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ // 3, Set the priority according to the task purpose,a smaller number means a higher priority.
+ task1.usTaskPrio = TASK_PRIO_TEST - 3;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "EventTsk33B";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF03;
+ task1.pcName = "EventTsk33C";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ TestExtraTaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT2); // 3, Here, assert that g_testCount is equal to 3.
+
+ ret = LOS_EventWrite(&g_event, 0xF);
+
+ TestBusyTaskDelay(10); // 10, set delay time
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT3); // 6, Here, assert that g_testCount is equal to 3.
+
+EXIT3:
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT2:
+ LOS_TaskDelete(g_testTaskID03);
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent033(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent033", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_037.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_037.c
new file mode 100644
index 0000000000000000000000000000000000000000..4a5db7d20de03eb2a2cc9fd5cb2ad2f9878496cd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_037.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_TaskSuspend(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ LOS_EventInit(&g_event);
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk37";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x11);
+
+ LOS_EventClear(&g_event, (~(0x11)));
+
+ ret = LOS_TaskResume(g_testTaskID01);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT1); // 4, Here, assert that g_testCount is equal to 4.
+
+EXIT1:
+
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent037(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent037", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_038.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_038.c
new file mode 100644
index 0000000000000000000000000000000000000000..6a523f9f18d8d8c2db0ada3ff488e45e962a17f7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_038.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static EVENT_CB_S g_pevent2 = { 0 };
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ g_testCount++;
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_EventWrite(&g_pevent2, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_EventClear(&g_pevent2, 0);
+
+ g_testCount++;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_pevent2, 0x11, LOS_WAITMODE_AND, 10); // 10, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ LOS_EventClear(&g_pevent2, 0x11);
+
+ ret = LOS_EventRead(&g_pevent2, 0x11, LOS_WAITMODE_AND, 10); // 10, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_READ_TIMEOUT, ret, EXIT);
+
+ ret = LOS_EventWrite(&g_pevent2, 0x11);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_EventClear(&g_pevent2, 0x11);
+ ret = LOS_EventRead(&g_pevent2, 0x11, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0x11, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT); // 6, Here, assert that g_testCount is equal to 6.
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x1, LOS_WAITMODE_OR, 10); // 10, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, 0x1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ LOS_EventInit(&g_event);
+ LOS_EventInit(&g_pevent2);
+
+ g_testCount = 0;
+
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk38A";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "EventTsk38B";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 1;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT1); // 2, Here, assert that g_testCount is equal to 2.
+ g_testCount++;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 0, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(11); // 11, delay enouge time
+ ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT1); // 7, Here, assert that g_testCount is equal to 7.
+
+EXIT1:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent038(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent038", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_039.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_039.c
new file mode 100644
index 0000000000000000000000000000000000000000..886dd7ed6acf7ac5e206d6fd8c77c3daedf77e8b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_039.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 2); // 2, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ LOS_EventInit(&g_event);
+
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk39";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskUnlock();
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_TaskLock();
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent039(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent039", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_040.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_040.c
new file mode 100644
index 0000000000000000000000000000000000000000..0d8d3c8df342d5dd80055250e5671f326c17ed24
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_040.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 10); // 10, The timeout period for reading events.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0x11, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x111, g_event.uwEventID);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk40";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_EventWrite(&g_event, 0x100);
+
+ LOS_EventWrite(&g_event, 0x1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_EventWrite(&g_event, 0x10);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ return LOS_OK;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+VOID ItLosEvent040(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent040", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_042.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_042.c
new file mode 100644
index 0000000000000000000000000000000000000000..40439fda9b6e6fb0742722f15c62b9507fb53e7e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_042.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ EVENT_CB_S pevent = { 0 };
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk42";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ g_event.uwEventID = 0;
+ LOS_EventInit(&g_event);
+ LOS_EventInit(&pevent);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_EventWrite(&pevent, 0x11);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ LOS_EventWrite(&g_event, 0x11);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ return LOS_OK;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+VOID ItLosEvent042(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent042", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_043.c b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_043.c
new file mode 100644
index 0000000000000000000000000000000000000000..4a5abb7f36a2e97b1661af998da843e1f7d9047b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/full/It_los_event_043.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ g_event.uwEventID = 0;
+ LOS_EventInit(&g_event);
+
+ LOS_EventWrite(&g_event, 0x1);
+
+ ret = LOS_EventRead(&g_event, 0x1, LOS_WAITMODE_OR, 0);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x1, g_event.uwEventID, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x10);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11, g_event.uwEventID, EXIT);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 0);
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11, g_event.uwEventID, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ g_testCount++;
+
+ LOS_EventWrite(&g_event, 0x100);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x111, g_event.uwEventID, EXIT);
+
+ ret = LOS_EventRead(&g_event, 0x10, LOS_WAITMODE_OR, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0x10, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x111, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk43";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent043(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent043", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_031.c b/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_031.c
new file mode 100644
index 0000000000000000000000000000000000000000..5548d1dfba8c03dbc7c34ced741c5752238778e9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_031.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_EventDestroy(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_EVENT_PTR_NULL, ret);
+ return LOS_OK;
+}
+
+VOID ItLosEvent031(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent031", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL0, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_035.c b/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_035.c
new file mode 100644
index 0000000000000000000000000000000000000000..60f3b27b502054f30e93ef3d6d84f9230c0deba5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_035.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventInit(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_EVENT_PTR_NULL, ret);
+ return LOS_OK;
+}
+
+VOID ItLosEvent035(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent035", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL0, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_036.c b/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_036.c
new file mode 100644
index 0000000000000000000000000000000000000000..a5edd54abd9db4db6e7faa6c7d6b6feb15f7ca7d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_036.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+
+ LOS_EventInit(&g_event);
+
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk36";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT1);
+
+ LOS_EventClear(&g_event, (~(0x11)));
+
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT1); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT1:
+
+ ret = LOS_EventClear(&g_event, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent036(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent036", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL0, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_041.c b/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_041.c
new file mode 100644
index 0000000000000000000000000000000000000000..2afd1b0ac30c41e3ed3e3b9cc23c5ad9b46c9d45
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smoke/It_los_event_041.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, 3); // 3, The timeout period for reading events.
+ ICUNIT_GOTO_EQUAL(ret, g_event.uwEventID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_event.uwEventID, 0x11, g_event.uwEventID, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ memset(&task1, 0, sizeof(TSK_INIT_PARAM_S));
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "EventTsk41";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, set new task priority, it is higher than the current task.
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+ LOS_EventInit(&g_event);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ while (g_testCount < 1) {
+ }
+
+ LOS_EventWrite(&g_event, 0x11);
+ TestExtraTaskDelay(2); // 2, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_EventDestroy(&g_event);
+
+ return LOS_OK;
+}
+
+VOID ItLosEvent041(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosEvent041", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL0, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_001.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..c9c35c3726d9d3b36f1381ae81ea9e788cd4810e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_001.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 "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_EventDestroy(&g_event);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent001(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent001", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_002.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..cd8464afebab7503233a7c9b77e52e37e8ff2044
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_002.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 "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_EventDestroy(&g_event);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent002(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent002", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_003.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..7c8ba93f3f01644ce1bad11f10f11f7878cd5881
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_003.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_EventDestroy(&g_event);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent003(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent003", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_004.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..d13a1a14418d443449224fe01ef9398ac57f4007
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_004.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_EVENT_SHOULD_NOT_DESTORY, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent004(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent004", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_005.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..78bb4b1d902308ea409727a2044d92ad4677e00b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_005.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_EVENT_SHOULD_NOT_DESTORY, ret);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent005(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent005", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_006.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..15f0e96666b1c2dd7a942a500f259fd20c95cf82
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_006.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 "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_006_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ TestBusyTaskDelay(2); // 2, delay enouge time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_SHOULD_NOT_DESTORY, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent006(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent006", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_007.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..4ebc57e5b816c5d2273453ff46fee73e63eabcf9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_007.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_EVENT_SHOULD_NOT_DESTORY, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ // 2, Set the priority according to the task purpose,a smaller number means a higher priority.
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_007_task1", TaskF01, TASK_PRIO_TEST - 2,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_007_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent007(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent007", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_008.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..5e29b5771839af1c9042d13a9f3560561587b0ec
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_008.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_EVENT_READ_IN_INTERRUPT, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_EventDestroy(&g_event);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent008(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent008", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_009.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..be44e69a1d7305cd5b1c7c084e34e633b50e728b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_009.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_EVENT_SHOULD_NOT_DESTORY, ret);
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ TestBusyTaskDelay(2); // 2, delay enouge time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 2); // 2, wait until g_testCount is 2 ,or do noting
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent009(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent009", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_010.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..d9409125bd5b7484061b320d124b676fb6ca7e1a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_010.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_010_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_010_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent010(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent010", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_011.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..395620431bcd1f1d2ef2ba2dfea696ea8f017a86
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_011.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_011_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_011_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent011(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent011", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_012.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..f8c7d13e3dff3537af164312d8095ce61dc7e1fd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_012.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent012(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent012", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_013.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..58e7eb5739cc98dc412af4d1892591b5dc16e20f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_013.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_013_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_013_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent013(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent013", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_014.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_014.c
new file mode 100644
index 0000000000000000000000000000000000000000..5c85cba6653069986654ec78ac43e670c527a4a5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_014.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent014(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent014", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_015.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..c4a6237c53458b01d9fcabc68a1d49df52ca5f6b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_015.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 2); // 2, wait until g_testCount is 2 ,or do noting
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent015(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent015", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_016.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_016.c
new file mode 100644
index 0000000000000000000000000000000000000000..e24feed056134527a55e7d0879a92c33843af6cf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_016.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 "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_016_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent016(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent016", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_017.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_017.c
new file mode 100644
index 0000000000000000000000000000000000000000..1d8e58213ac54b7d0a34857a5a89e28b0431c627
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_017.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_017_task2", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent017(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent017", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_018.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..e915da88b85d742ef418b90daada1645f86df2cc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_018.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 "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task2", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent018(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent018", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_019.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..de8efd3b73a2761a01948860947154b934fd30c2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_019.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 "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent019(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent019", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_020.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..5c71584c994a7cb35e8bca282b1cffbbb96dacf1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_020.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_020_task2", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, g_event.uwEventID, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent020(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent020", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_021.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..315ccf0a67b7e545c691cc9d144403f352e01dcb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_021.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_021_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent021(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent021", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_022.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..7b9623f3e323928c1f7b98268f27097f66377c10
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_022.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_EVENT_READ_IN_INTERRUPT, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent022(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent022", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_023.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..d93367d38a10f903b695628a9fcbee23fa62cf62
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_023.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_023_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_023_task", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // othercpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent023(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent023", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_024.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_024.c
new file mode 100644
index 0000000000000000000000000000000000000000..59c29cbc9febbc05e61140d37881d0afefc0e60f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_024.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, g_event.uwEventID, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent024(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent024", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_025.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_025.c
new file mode 100644
index 0000000000000000000000000000000000000000..48f9e3b478c266a6f850818763b438ed092511e1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_025.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_EVENT_READ_IN_INTERRUPT, ret);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent025(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent025", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_026.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..f88e14c12da2d7728f1874eca33ca85e383b044b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_026.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_ret1;
+static UINT32 g_ret2 = 0;
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER); // read and clear
+ g_ret1 = ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0, g_event.uwEventID);
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER); // read and clear
+ g_ret2 = ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0, g_event.uwEventID);
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_026_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_026_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
+
+ PRINT_DEBUG("g_ret1=0x%x,g_ret2=0x%x\n", g_ret1, g_ret2);
+ ICUNIT_GOTO_EQUAL(g_ret1, 0x11, g_ret1, EXIT);
+ ICUNIT_GOTO_EQUAL(g_ret2, 0x11, g_ret2, EXIT);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent026(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent026", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_027.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..280ca0d71d9e7655f144741f76ec2b4b0feae5cf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_027.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); // just read not clear
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0x11, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); // just read not clear
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0x11, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_event.uwEventID, 0x11, g_event.uwEventID);
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_026_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_026_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ while (g_testCount != 2) { // 2, wait until g_testCount is 2 ,or do noting
+ }
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent027(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent027", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_028.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_028.c
new file mode 100644
index 0000000000000000000000000000000000000000..c4c74b57f5e8c2ccf1b2183be2ecbe1dececf986
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_028.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_ret = 0;
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, i;
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_EventWrite(&g_event, 0x10); // write 1 event
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_OR, LOS_WAIT_FOREVER); // wait 2 event with OR mode
+
+ g_ret |= ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+ LosTaskCB *cb = NULL;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_028_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_028_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 1); // wait for task f02
+
+ for (j = 0; j < TRandom() % 500; j++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_EventWrite(&g_event, 0x01); // write another event
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
+ if ((g_ret != 0x10) && (g_ret != 0x01)) {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret, EXIT);
+ }
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ }
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_EventDestroy(&g_event);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent028(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent028", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_029.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..18f2894761860dff2e8cfcd0991fb8b3f6cfffd8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_029.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_ret = 0;
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_EventWrite(&g_event, 0x01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ g_ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, i;
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_EventWrite(&g_event, 0x10); // write another event
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+ LosTaskCB *cb = NULL;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // curret cpu
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_029_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_029_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 1); // wait for task f02
+
+ for (j = 0; j < TRandom() % 500; j++) { // Random values of 0 to 500
+ }
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+
+ ICUNIT_GOTO_EQUAL(g_ret, 0x11, g_ret, EXIT);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ }
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent029(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent029", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_030.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_030.c
new file mode 100644
index 0000000000000000000000000000000000000000..2df01bb6c31f4658ddb282daa56a8e35f6eea615
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_030.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret, i;
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_030_task2", TaskF01, TASK_PRIO_TEST + 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 0); // wait for task f01
+
+ for (j = 0; j < TRandom() % 500; j++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ }
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent030(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent030", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_031.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_031.c
new file mode 100644
index 0000000000000000000000000000000000000000..4998ccea6c8431307ae5338837db0c82cba42369
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_031.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_ret = 0;
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ /*
+ * write event ---> read event ---> destory event [pass]
+ * write event ---> destroy event ---> read event [fail]
+ */
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, i;
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++) { // Random values of 0 to 500
+ }
+
+ g_ret = LOS_EventDestroy(&g_event); // delete event in other cpu
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+ LosTaskCB *cb = NULL;
+
+ g_testCount = 0;
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ g_event.uwEventID = 0;
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_031_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_031_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 1); // wait for task f02
+
+ for (j = 0; j < TRandom() % 500; j++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_EventWrite(&g_event, 0x11); // write event in other cpu
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
+
+ if ((g_ret != LOS_OK) && (g_ret != LOS_ERRNO_EVENT_SHOULD_NOT_DESTORY)) {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret, EXIT);
+ }
+
+ /* clear enviorment */
+ g_testCount = 0;
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ LOS_EventDestroy(&g_event);
+ }
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent031(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent031", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_032.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_032.c
new file mode 100644
index 0000000000000000000000000000000000000000..5f6feb3070f163d1995130454c0ad7a3960eb75e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_032.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#if (LOSCFG_KERNEL_SMP == YES)
+
+static UINT32 g_ret1, g_ret2, g_ret3;
+static UINT32 g_szId[3] = {0};
+
+static VOID TaskF01(UINT32 index)
+{
+ UINT32 ret, i;
+ PRINT_DEBUG("index = %d,cpuid=%d\n", index, ArchCurrCpuid());
+ switch (index) {
+ case 0:
+ PRINT_DEBUG("---000---\n");
+ for (i = 0; i < TRandom() % 500; i++) { // Random values of 0 to 500
+ }
+ LOS_AtomicInc(&g_testCount);
+ g_ret1 = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ break;
+ case 1:
+ PRINT_DEBUG("---111---\n");
+ for (i = 0; i < TRandom() % 500; i++) { // Random values of 0 to 500
+ }
+ LOS_AtomicInc(&g_testCount);
+ g_ret2 = LOS_EventWrite(&g_event, 0x11);
+ break;
+ case 2: // 2,index
+ PRINT_DEBUG("---222---\n");
+ for (i = 0; i < TRandom() % 500; i++) { // Random values of 0 to 500
+ }
+ LOS_AtomicInc(&g_testCount);
+ g_ret3 = LOS_EventDestroy(&g_event);
+ break;
+ default:
+ break;
+ }
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 i, j;
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+ g_ret1 = 0xff;
+ g_ret2 = 0xff;
+ g_ret3 = 0xff;
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (j = 0; j < 3; j++) { // 3, max index
+ TEST_TASK_PARAM_INIT(testTask, "it_event_032_task", TaskF01, TASK_PRIO_TEST - 1);
+ testTask.auwArgs[0] = j;
+ ret = LOS_TaskCreate(&g_szId[j], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+ while (g_testCount < 3) { // 3, wait if g_testCount < 3 ,or do noting
+ }
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+ PRINT_DEBUG("ret1= 0x%x,ret2 = 0x%x,ret3=0x%x\n", g_ret1, g_ret2, g_ret3);
+
+ if ((g_ret1 == 0x11) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_OK)) { // pend-post-del ///post-pend-del
+ } else if ((g_ret1 == 0x11) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_OK)) { // del-pend-post//del-post-pend
+ } else if ((g_ret1 == 0x11) && (g_ret2 == LOS_OK) &&
+ (g_ret3 == LOS_ERRNO_EVENT_SHOULD_NOT_DESTORY)) { // pend-delete-post
+ } else if ((g_ret1 == 0xff) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_OK)) { // post-del-pend
+ LOS_TaskDelete(g_szId[0]); // delete the pend task
+ } else if ((g_ret1 == 0x00) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_OK)) {
+ /*
+ * (g_ret1 == 0) && (g_ret2 == 0) && (uwRet3 == 0)
+ * try read -->write event ---resume read---> destory event ---> read event [fail]
+ */
+ } else {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret1, EXIT);
+ }
+
+ for (j = 0; j < 3; j++) { // 3, max index
+ ret = OS_TCB_FROM_TID(g_szId[j])->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ }
+
+ LOS_EventDestroy(&g_event);
+ }
+
+EXIT:
+ for (i = 0; i < 3; i++) { // 3, max index
+ LOS_TaskDelete(g_szId[i]);
+ }
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent032(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosEvent032", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_033.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_033.c
new file mode 100644
index 0000000000000000000000000000000000000000..32345aca1f078ad379a4bfb7949eb459e7b9c607
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_033.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_ret = 0xff;
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, i;
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_EventWrite(&g_event, 0x11); // write event
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); // wait event
+
+ g_ret = ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+ LosTaskCB *cb = NULL;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_028_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_028_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 1); // wait for task f02
+
+ for (j = 0; j < TRandom() % 500; j++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_EventClear(&g_event, (~(0x11))); // clear event
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
+
+ if ((g_ret != 0xff) && (g_ret != 0x11)) {
+ PRINT_DEBUG("g_ret = 0x%x\n", g_ret);
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret, EXIT);
+ }
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent033(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent033", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_034.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_034.c
new file mode 100644
index 0000000000000000000000000000000000000000..e8d4d36938678b14ccdf9e04ec3d2523e3ce4de9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_034.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0x11, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to 4.
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0x11, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2. // other core get the sem first
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, uvIntSave;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_033_task2", TaskF02, TASK_PRIO_TEST - 1, CPUID_TO_AFFI_MASK(currCpuid));
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1); // let the task f02 read event first
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_033_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ LOS_TaskLock();
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 3); // 3, wait until g_testCount is 3 ,or do noting
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+
+EXIT1:
+ LOS_TaskUnlock();
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent034(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent034", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_035.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_035.c
new file mode 100644
index 0000000000000000000000000000000000000000..78097ceea8afcd2bcc3ec5c797d7e9964f17d042
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_035.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile UINT32 g_runFlag = 1;
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0x11, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to 3.
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, uvIntSave;
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskLock(); // task lock on other cpu
+ do {
+ __asm__ volatile("nop");
+ } while (g_runFlag == 1);
+
+ LOS_TaskUnlock(); // schedule occur ---switch to task f01
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to 4.
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_runFlag = 1;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_034_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_034_task2", TaskF02, TASK_PRIO_TEST,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ while (g_testCount < 2) { // g_testCount < 2,do nothing
+ }
+
+ ret = LOS_EventWrite(&g_event, 0x11); // try to wake task f01
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ // 100, Set the timeout of runtime; 2, test runing count
+ TestAssertBusyTaskDelay(100, 2); // cause tasklock on other cpu ,so task f01 wake failed
+
+ LOS_AtomicInc(&g_testCount);
+
+ g_runFlag = 0; // unlock the other cpu
+ // 100, Set the timeout of runtime; 4, test runing count
+ TestAssertBusyTaskDelay(100, 4); // not schedule in current cpu cause tasklock
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent035(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent035", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_036.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_036.c
new file mode 100644
index 0000000000000000000000000000000000000000..c1e7a6abef92f2bbed85cf1955c393161f2b392d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_036.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret, i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0x11, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ do {
+ __asm__ volatile("nop");
+ } while (1);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_035_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 0); // wait for task f01 run
+
+ for (j = 0; j < TRandom() % 500; j++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_TaskDelete(g_testTaskID01); // cross delete always return ok
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(100); // 100, delay enouge time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_UNUSED, ret, EXIT);
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_UNUSED, ret, EXIT);
+
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_EventDestroy(&g_event);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent036(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent036", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_037.c b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_037.c
new file mode 100644
index 0000000000000000000000000000000000000000..09b5227826617548ca89698590c5e2400c875f83
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/event/smp/It_smp_los_event_037.c
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_ret = 0xff;
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_EventRead(&g_event, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); // pend on current cpu
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0x11, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 2); // 2, wait for test task
+
+ for (i = 0; i < TRandom() % 500; i++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_EventWrite(&g_event, 0x11);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_event.uwEventID = 0;
+
+ ret = LOS_EventInit(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_event_037_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_event_037_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 1); // wait for task f02
+
+ LOS_AtomicInc(&g_testCount);
+
+ for (j = 0; j < TRandom() % 500; j++) { // Random values of 0 to 500
+ }
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ g_ret = ret;
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ if (g_testCount == 4) { // 4,case
+ ICUNIT_GOTO_EQUAL(g_ret, LOS_OK, g_ret, EXIT);
+ } else if (g_testCount == 5) { // 5,case
+ ICUNIT_GOTO_EQUAL(g_ret, LOS_ERRNO_TSK_NOT_CREATED, g_ret, EXIT);
+ } else {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret, EXIT);
+ }
+ LOS_TaskDelete(g_testTaskID02);
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ LOS_EventClear(&g_event, (~(0x11)));
+ }
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_EventDestroy(&g_event);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosEvent037(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosEvent037", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/It_los_mux.c b/testsuites/kernel/sample/kernel_base/ipc/mux/It_los_mux.c
new file mode 100644
index 0000000000000000000000000000000000000000..c68b18f35700d1bf9da326bc7b6fb8b4f438b271
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/It_los_mux.c
@@ -0,0 +1,157 @@
+/*
+ * 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 "los_task_pri.h"
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+LosMux g_mutexTest1;
+LosMux g_mutexTest2;
+LosMux g_mutexTest3;
+
+
+u_long TRand()
+{
+ return TRandom();
+}
+void ShowMuxId(UINT32 *p, int len)
+{
+ int i;
+ for (i = 0; i < len; i++) {
+ dprintf("%d , ", p[i]);
+ }
+ dprintf("\n");
+}
+void RandSZ(UINT32 *sz, int len)
+{
+ int idx;
+ for (idx = len - 1; idx > 1; idx--) { /* get the random index */
+ int randIdx = TRand() % idx;
+ UINT32 tempMuxID = sz[randIdx];
+ sz[randIdx] = sz[idx];
+ sz[idx] = tempMuxID;
+ }
+ return;
+}
+VOID ItSuiteLosMux(void)
+{
+#if defined(LOSCFG_TEST_SMOKE)
+ ItLosMux001();
+ ItLosMux002();
+ ItLosMux003();
+ ItLosMux004();
+#endif
+#if defined(LOSCFG_TEST_FULL)
+ ItLosMux006();
+ ItLosMux007();
+ ItLosMux008();
+ ItLosMux009();
+ ItLosMux010();
+ ItLosMux011();
+ ItLosMux012();
+ ItLosMux013();
+ ItLosMux015();
+ ItLosMux016();
+ ItLosMux017();
+ ItLosMux018();
+ ItLosMux020();
+ ItLosMux021();
+ ItLosMux025();
+ ItLosMux026();
+ ItLosMux027();
+ ItLosMux028();
+ ItLosMux029();
+ ItLosMux031();
+ ItLosMux035();
+ ItLosMux036();
+ ItLosMux037();
+ ItLosMux038();
+ ItLosMux039();
+ ItLosMux040();
+ ItLosMux041();
+ ItLosMux042();
+ ItLosMux043();
+#endif
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ ItSmpLosMux001();
+ ItSmpLosMux002();
+ ItSmpLosMux003();
+ ItSmpLosMux004();
+ ItSmpLosMux005();
+ ItSmpLosMux006();
+ ItSmpLosMux007();
+ ItSmpLosMux2001();
+ ItSmpLosMux2002();
+ ItSmpLosMux2003();
+ ItSmpLosMux2004();
+ ItSmpLosMux2005();
+ ItSmpLosMux2006();
+ ItSmpLosMux2007();
+ ItSmpLosMux2008();
+ ItSmpLosMux2009();
+ ItSmpLosMux2010();
+ ItSmpLosMux2011();
+ ItSmpLosMux2012();
+ ItSmpLosMux2013();
+ ItSmpLosMux2014();
+ ItSmpLosMux2015();
+ ItSmpLosMux2016();
+ ItSmpLosMux2017();
+ ItSmpLosMux2018();
+ ItSmpLosMux2021();
+ ItSmpLosMux2022();
+ ItSmpLosMux2024();
+ ItSmpLosMux2025();
+ ItSmpLosMux2026();
+ ItSmpLosMux2027();
+ ItSmpLosMux2028();
+ ItSmpLosMux2029();
+#endif
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, 1);
+ HalIrqSetAffinity(HWI_NUM_TEST1, 1);
+#endif
+}
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/It_los_mux.h b/testsuites/kernel/sample/kernel_base/ipc/mux/It_los_mux.h
new file mode 100644
index 0000000000000000000000000000000000000000..6172afffce3d843d38918c50e671074b67a60b5b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/It_los_mux.h
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _IT_LOS_MUX_H
+#define _IT_LOS_MUX_H
+
+#include "osTest.h"
+#include "los_mux_pri.h"
+#include "los_config.h"
+#include "los_bitmap.h"
+#include "los_sem_pri.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+extern LosMux g_mutexTest1;
+extern LosMux g_mutexTest2;
+extern LosMux g_mutexTest3;
+extern VOID ItSuiteLosMux(void);
+
+#define LOOP 100
+
+#define LOS_ERRNO_MUX_INVALID EINVAL
+#define LOS_ERRNO_MUX_PTR_NULL EINVAL
+#define LOS_ERRNO_MUX_PENDED EBUSY
+#define LOS_ERRNO_MUX_UNAVAILABLE EBUSY
+#define LOS_ERRNO_MUX_TIMEOUT ETIMEDOUT
+#define LOS_ERRNO_MUX_ALL_BUSY EAGAIN
+#define LOS_ERRNO_MUX_PEND_IN_LOCK EDEADLK
+#define LOS_ERRNO_MUX_PEND_INTERR EINTR
+u_long TRand(void);
+void ShowMuxId(UINT32 *p, int len);
+void RandSZ(UINT32 *sz, int len);
+void WaitAllTasksFinish(UINT32 *szTaskID, int len);
+bool CheckAllTasksStatus(UINT32 *szTaskID, int len, const char *supposedStatus);
+UINT8 *T_osShellConvertTskStatus(UINT16 taskStatus);
+#if defined(LOSCFG_TEST_SMOKE)
+VOID ItLosMux001(void);
+VOID ItLosMux002(void);
+VOID ItLosMux003(void);
+VOID ItLosMux004(void);
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+VOID ItLosMux006(void);
+VOID ItLosMux007(void);
+VOID ItLosMux008(void);
+VOID ItLosMux009(void);
+VOID ItLosMux010(void);
+VOID ItLosMux011(void);
+VOID ItLosMux012(void);
+VOID ItLosMux013(void);
+VOID ItLosMux015(void);
+VOID ItLosMux016(void);
+VOID ItLosMux017(void);
+VOID ItLosMux018(void);
+VOID ItLosMux020(void);
+VOID ItLosMux021(void);
+VOID ItLosMux025(void);
+VOID ItLosMux026(void);
+VOID ItLosMux027(void);
+VOID ItLosMux028(void);
+VOID ItLosMux029(void);
+VOID ItLosMux031(void);
+VOID ItLosMux035(void);
+VOID ItLosMux036(void);
+VOID ItLosMux037(void);
+VOID ItLosMux038(void);
+VOID ItLosMux039(void);
+VOID ItLosMux040(void);
+VOID ItLosMux041(void);
+VOID ItLosMux042(void);
+VOID ItLosMux043(void);
+#endif
+
+#if defined(LOSCFG_TEST_SMP)
+VOID ItSmpLosMux001(void);
+VOID ItSmpLosMux002(void);
+VOID ItSmpLosMux003(void);
+VOID ItSmpLosMux004(void);
+VOID ItSmpLosMux005(void);
+VOID ItSmpLosMux006(void);
+VOID ItSmpLosMux007(void);
+VOID ItSmpLosMux2001(void);
+VOID ItSmpLosMux2002(void);
+VOID ItSmpLosMux2003(void);
+VOID ItSmpLosMux2004(void);
+VOID ItSmpLosMux2005(void);
+VOID ItSmpLosMux2006(void);
+VOID ItSmpLosMux2007(void);
+VOID ItSmpLosMux2008(void);
+VOID ItSmpLosMux2009(void);
+VOID ItSmpLosMux2010(void);
+VOID ItSmpLosMux2011(void);
+VOID ItSmpLosMux2012(void);
+VOID ItSmpLosMux2013(void);
+VOID ItSmpLosMux2014(void);
+VOID ItSmpLosMux2015(void);
+VOID ItSmpLosMux2016(void);
+VOID ItSmpLosMux2017(void);
+VOID ItSmpLosMux2018(void);
+VOID ItSmpLosMux2019(void);
+VOID ItSmpLosMux2020(void);
+VOID ItSmpLosMux2021(void);
+VOID ItSmpLosMux2022(void);
+VOID ItSmpLosMux2023(void);
+VOID ItSmpLosMux2024(void);
+VOID ItSmpLosMux2025(void);
+VOID ItSmpLosMux2026(void);
+VOID ItSmpLosMux2027(void);
+VOID ItSmpLosMux2028(void);
+VOID ItSmpLosMux2029(void);
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif /* _IT_LOS_MUX_H */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_006.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..c3618642f630884d2f71f1c02e5e3904765f4687
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_006.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ LosMux muxHandle, muxHandle2;
+
+ ret = LosMuxCreate(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LosMuxCreate(&muxHandle2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, EBADF, ret);
+
+ ret = LOS_MuxDestroy(&muxHandle2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&muxHandle2);
+ ICUNIT_ASSERT_EQUAL(ret, EBADF, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux006(void)
+{
+ TEST_ADD_CASE("ItLosMux006", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_007.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..5f68d13ae4d3ecd8604c8e5af44fada39849f2af
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_007.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ LOS_TaskDelay(100); // 100, set delay time.
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ TestExtraTaskDelay(2); // 2, delay for Timing control.
+
+ g_testCount++;
+
+ LOS_TaskDelay(200); // 200, set delay time.
+}
+
+static VOID TaskF02(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+ TSK_INIT_PARAM_S task2 = { 0 };
+
+ g_testCount = 0;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.usTaskPrio = (TASK_PRIO_TEST - 1);
+ task.pcName = "VMuteB2_1";
+ task.uwStackSize = 0x900;
+ task.uwResved = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ TestExtraTaskDelay(2); // 2, delay for Timing control.
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task2.usTaskPrio = (TASK_PRIO_TEST - 2); // 2, set reasonable priority.
+ task2.pcName = "VMuteB2_2";
+ task2.uwStackSize = 0x900;
+ task2.uwResved = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(200); // 200, set delay time.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+
+VOID ItLosMux007(void)
+{
+ TEST_ADD_CASE("ItLosMux007", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_008.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..a4ef237c0bc06c1ce8e5e92ae1a40f518a5c46eb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_008.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, EPERM, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux008(void)
+{
+ TEST_ADD_CASE("ItLosMux008", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_009.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..41f045b21ba386e28e774017dee61660c0321859
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_009.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TestHook091(void)
+{
+ UINT32 ret;
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, EPERM, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ g_testCount = 0;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TestHook091;
+ task.usTaskPrio = (TASK_PRIO_TEST - 1);
+ task.pcName = "VMutexB4";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.uwResved = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ TestExtraTaskDelay(2); // 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux009(void)
+{
+ TEST_ADD_CASE("ItLosMux009", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_010.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..d6a305f276e4d1fb031a9e9a37a20c0f60f5648d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_010.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_PENDED, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux010(void)
+{
+ TEST_ADD_CASE("ItLosMux010", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_011.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..0ad77c4d16615b8e4aaf6c35f6a9392f402290fd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_011.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 "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ g_testCount = 0;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.usTaskPrio = (TASK_PRIO_TEST - 1);
+ task.pcName = "VMutexB6";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.uwResved = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ TestExtraTaskDelay(2); // 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_PENDED, ret);
+ LOS_TaskDelay(15); // 15, delay for Timing control.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+
+VOID ItLosMux011(void)
+{
+ TEST_ADD_CASE("ItLosMux011", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_012.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..fc154cdcfb2fe125b1c683fb18ef65c8d98bc7af
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_012.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ g_testCount = 0;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.usTaskPrio = (TASK_PRIO_TEST - 1);
+ task.pcName = "VMutexB7";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.uwResved = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ TestExtraTaskDelay(2); // 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_PENDED, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux012(void)
+{
+ TEST_ADD_CASE("ItLosMux012", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_013.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..76e1167e3b8830ef2f2ee4167ac177f4abeca5ee
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_013.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID HwiF01(void)
+{
+ UINT32 ret;
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, 0);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 0, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+ TestHwiTrigger(HWI_NUM_TEST);
+#if (LOSCFG_KERNEL_SMP == YES)
+ TestBusyTaskDelay(5); // 5, delay for Timing control.
+#endif
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux013(void)
+{
+ TEST_ADD_CASE("ItLosMux013", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_015.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..093377290bb153a5d00c1d29df639dd4d2247fb0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_015.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ g_testCount = 0;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.usTaskPrio = (TASK_PRIO_TEST - 1);
+ task.pcName = "VMuteB010";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.uwResved = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, EPERM, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+ TestExtraTaskDelay(5); // 5, delay for Timing control.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, EPERM, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, EPERM, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux015(void)
+{
+ TEST_ADD_CASE("ItLosMux015", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_016.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_016.c
new file mode 100644
index 0000000000000000000000000000000000000000..3db8a39271852b75ff4c7b4c71dc7ef491932777
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_016.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 0, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+ TestHwiTrigger(HWI_NUM_TEST);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ TestBusyTaskDelay(10); // 10, delay for Timing control.
+#endif
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux016(void)
+{
+ TEST_ADD_CASE("ItLosMux016", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_017.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_017.c
new file mode 100644
index 0000000000000000000000000000000000000000..27ad83613f950344d34ca8dfc4d1c3ea7a427bfb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_017.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 0, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestExtraTaskDelay(5); // 5, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux017(void)
+{
+ TEST_ADD_CASE("ItLosMux017", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_018.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..f5bc131d646eac2be41dcb58f34225dae0a218ea
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_018.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 semHandle;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemCreate(1, &semHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, EBADF, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, EBADF, ret);
+
+ ret = LOS_SemDelete(semHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux018(void)
+{
+ TEST_ADD_CASE("ItLosMux018", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_020.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..97230ac620f24b2cdffac244a53fa8666f4b113c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_020.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID HwiF02(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST0);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+}
+
+static VOID HwiF01(void)
+{
+ UINT32 ret;
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 0, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_HwiCreate(HWI_NUM_TEST0, 0, 0, (HWI_PROC_FUNC)HwiF02, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ HalIrqSetAffinity(HWI_NUM_TEST0, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestExtraTaskDelay(5); // 5, delay for Timing control.
+ TestHwiTrigger(HWI_NUM_TEST0);
+ TestExtraTaskDelay(5); // 5, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+ TEST_HwiDelete(HWI_NUM_TEST0);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux020(void)
+{
+ TEST_ADD_CASE("ItLosMux020", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_021.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..0c7873c14a192c1f5c0333f0ada61bd317536cc2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_021.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+ g_testCount++;
+
+ LOS_TaskDelay(200); // 200, set delay time.
+}
+
+VOID TaskF02(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+
+ g_testCount++;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "LosMB2_2";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = TASK_PRIO_TEST - 3; // 3, set reasonable priority.
+ task1.uwResved = 0;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.usTaskPrio = (TASK_PRIO_TEST - 1);
+ task.pcName = "LosMB2_1";
+ task.uwStackSize = 0x900;
+ task.uwResved = 0;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+ TestExtraTaskDelay(10); // 10, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+
+VOID ItLosMux021(void)
+{
+ TEST_ADD_CASE("ItLosMux021", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_025.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_025.c
new file mode 100644
index 0000000000000000000000000000000000000000..18dafb45aae2f11ffd975b4a9abc1611ae7b9e71
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_025.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 loop = 30; // 30, init.
+ UINT32 loop2 = 100; // 100, init.
+ UINT32 loop3 = 100; // 100, init.
+
+ while (loop--) {
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ while (loop2) {
+ loop2--;
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, loop2);
+ }
+
+ LOS_TaskDelay(1);
+ while (loop3) {
+ loop3--;
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, loop3);
+ }
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux025(void)
+{
+ TEST_ADD_CASE("ItLosMux025", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_026.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..5220c6fc63a4905f349ccea59614418527f39193
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_026.c
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+static VOID TaskDFunc(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, here assert the result.
+
+ g_testCount++;
+ ret = LOS_MuxLock(&g_mutexTest3, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest3);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 2, OsCurrTaskGet()->priority); // 2, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 9, g_testCount); // 9, here assert the result.
+
+ g_testCount++;
+}
+
+static VOID TaskCFunc(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ g_testCount++;
+ ret = LOS_MuxLock(&g_mutexTest2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 3, OsCurrTaskGet()->priority); // 3, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 11, g_testCount); // 11, here assert the result.
+
+ g_testCount++;
+}
+
+static VOID TaskBFunc(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ g_testCount++;
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 5, OsCurrTaskGet()->priority); // 5, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 13, g_testCount); // 13, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskAFunc(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ret = LOS_MuxLock(&g_mutexTest1, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskBFunc;
+ task1.usTaskPrio = 5; // 5, set reasonable priority.
+ task1.pcName = "TaskB";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = LosMuxCreate(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ret = LOS_MuxLock(&g_mutexTest2, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskCFunc;
+ task2.usTaskPrio = 3; // 3, set reasonable priority.
+ task2.pcName = "TaskC";
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task2.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID03, &task2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LosMuxCreate(&g_mutexTest3);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ret = LOS_MuxLock(&g_mutexTest3, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+ task3.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskDFunc;
+ task3.usTaskPrio = 2; // 2, set reasonable priority.
+ task3.pcName = "TaskD";
+ task3.uwStackSize = TASK_STACK_SIZE_TEST;
+ task3.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task3.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID04, &task3);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 8, g_testCount); // 8, here assert the result.
+
+#if 1 // post mutex 3 -> mutex2 -> mutex1
+ ret = LOS_MuxUnlock(&g_mutexTest3);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 10, g_testCount); // 10, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 12, g_testCount); // 12, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 14, g_testCount); // 14, here assert the result.
+#endif
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest3);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 14, g_testCount); // 14, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority); // 10, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(LOS_HighBitGet(OsCurrTaskGet()->priBitMap), LOS_INVALID_BIT_INDEX,
+ LOS_HighBitGet(OsCurrTaskGet()->priBitMap));
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task;
+
+ g_testCount = 0;
+
+ ICUNIT_ASSERT_EQUAL(OsCurrTaskGet()->priority, 25, OsCurrTaskGet()->priority); // 25, here assert the result.
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskAFunc;
+ task.usTaskPrio = 10; // 10, set reasonable priority.
+ task.pcName = "TaskA";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 14, g_testCount); // 14, here assert the result.
+ ICUNIT_ASSERT_EQUAL(OsCurrTaskGet()->priority, 25, OsCurrTaskGet()->priority); // 25, here assert the result.
+ return LOS_OK;
+}
+
+VOID ItLosMux026(void)
+{
+ TEST_ADD_CASE("ItLosMux026", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_027.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..bf957e9a602697ade8fc0fbf8c241cce969cd18f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_027.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+static VOID TaskD1Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 2, OsCurrTaskGet()->priority); // 2, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskC1Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, here assert the result.
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 3, OsCurrTaskGet()->priority); // 3, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskB1Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 7, g_testCount); // 7, here assert the result.
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 5, OsCurrTaskGet()->priority); // 5, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskA1Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexTest1, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskB1Func;
+ task1.usTaskPrio = 5; // 5, set reasonable priority.
+ task1.pcName = "TaskB";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskC1Func;
+ task2.usTaskPrio = 3; // 3, set reasonable priority.
+ task2.pcName = "TaskC";
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task2.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID03, &task2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task3.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskD1Func;
+ task3.usTaskPrio = 2; // 2, set reasonable priority.
+ task3.pcName = "TaskD";
+ task3.uwStackSize = TASK_STACK_SIZE_TEST;
+ task3.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task3.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID04, &task3);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority); // 10, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(LOS_HighBitGet(OsCurrTaskGet()->priBitMap), LOS_INVALID_BIT_INDEX,
+ LOS_HighBitGet(OsCurrTaskGet()->priBitMap));
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 8, g_testCount); // 8, here assert the result.
+}
+
+static UINT32 Testcase(void)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task;
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskA1Func;
+ task.usTaskPrio = 10; // 10, set reasonable priority.
+ task.pcName = "TaskA";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 8, g_testCount); // 8, here assert the result.
+ ICUNIT_ASSERT_EQUAL(OsCurrTaskGet()->priority, 25, OsCurrTaskGet()->priority); // 25, here assert the result.
+ return LOS_OK;
+}
+
+VOID ItLosMux027(void)
+{
+ TEST_ADD_CASE("ItLosMux027", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_028.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_028.c
new file mode 100644
index 0000000000000000000000000000000000000000..de9234b430790fa201abc726c9941312adff8dc2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_028.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+static VOID TaskD2Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority); // 10, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskC2Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority); // 10, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskB2Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority); // 10, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskA2Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ret = LOS_MuxLock(&g_mutexTest1, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskB2Func;
+ task1.usTaskPrio = 10; // 10, set reasonable priority.
+ task1.pcName = "TaskB";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_TaskYield();
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskC2Func;
+ task2.usTaskPrio = 10; // 10, set reasonable priority.
+ task2.pcName = "TaskC";
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task2.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID03, &task2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_TaskYield();
+
+ task3.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskD2Func;
+ task3.usTaskPrio = 10; // 10, set reasonable priority.
+ task3.pcName = "TaskD";
+ task3.uwStackSize = TASK_STACK_SIZE_TEST;
+ task3.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task3.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID04, &task3);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_TaskYield();
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority); // 10, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(LOS_HighBitGet(OsCurrTaskGet()->priBitMap), LOS_INVALID_BIT_INDEX,
+ LOS_HighBitGet(OsCurrTaskGet()->priBitMap));
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 8, g_testCount); // 8, here assert the result.
+ g_testCount++;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task;
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskA2Func;
+ task.usTaskPrio = 10; // 10, set reasonable priority.
+ task.pcName = "TaskA";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 7, g_testCount); // 7, here assert the result.
+ g_testCount++;
+ LOS_TaskDelay(20); // 20, delay for Timing control.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 9, g_testCount); // 9, here assert the result.
+ return LOS_OK;
+}
+
+VOID ItLosMux028(void)
+{
+ TEST_ADD_CASE("ItLosMux028", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_029.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..cdb90189634a9dba5c077dd747b6cd94b5e3d091
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_029.c
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+static VOID TaskD3Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+ ret = LOS_MuxLock(&g_mutexTest2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+ ret = LOS_MuxUnlock(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, here assert the result.
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 2, OsCurrTaskGet()->priority); // 2, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskC3Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+ ret = LosMuxCreate(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexTest2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskD3Func;
+ task1.usTaskPrio = 2; // 2, set reasonable priority.
+ task1.pcName = "TaskD";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID04, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 7, g_testCount); // 7, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 3, OsCurrTaskGet()->priority); // 3, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskB3Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 8, g_testCount); // 8, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 5, OsCurrTaskGet()->priority); // 5, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskA3Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ret = LOS_MuxLock(&g_mutexTest1, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskB3Func;
+ task1.usTaskPrio = 5; // 5, set reasonable priority.
+ task1.pcName = "TaskB";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskC3Func;
+ task2.usTaskPrio = 3; // 3, set reasonable priority.
+ task2.pcName = "TaskC";
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task2.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID03, &task2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 9, g_testCount); // 9, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority); // 10, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(LOS_HighBitGet(OsCurrTaskGet()->priBitMap), LOS_INVALID_BIT_INDEX,
+ LOS_HighBitGet(OsCurrTaskGet()->priBitMap));
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task;
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskA3Func;
+ task.usTaskPrio = 10; // 10, set reasonable priority.
+ task.pcName = "TaskA";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 10, g_testCount); // 10, here assert the result.
+ ICUNIT_ASSERT_EQUAL(OsCurrTaskGet()->priority, 25, OsCurrTaskGet()->priority); // 25, here assert the result.
+ return LOS_OK;
+}
+
+VOID ItLosMux029(void)
+{
+ TEST_ADD_CASE("ItLosMux029", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_031.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_031.c
new file mode 100644
index 0000000000000000000000000000000000000000..f0afad92d0cf6ab48ee74223f49cdfb981d90580
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_031.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+static VOID TaskD5Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ ret = LOS_MuxLock(&g_mutexTest2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 2, OsCurrTaskGet()->priority); // 2, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskC5Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = LOS_MuxLock(&g_mutexTest2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 3, OsCurrTaskGet()->priority); // 3, here assert the result.
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, here assert the result.
+ g_testCount++;
+}
+
+static VOID TaskB5Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 7, g_testCount); // 7, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 5, OsCurrTaskGet()->priority); // 5, here assert the result.
+
+ g_testCount++;
+}
+
+static VOID TaskA5Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ TSK_INIT_PARAM_S task2 = { 0 };
+ TSK_INIT_PARAM_S task3 = { 0 };
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexTest1, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexTest2, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskB5Func;
+ task1.usTaskPrio = 5; // 5, set reasonable priority.
+ task1.pcName = "TaskB";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskC5Func;
+ task2.usTaskPrio = 3; // 3, set reasonable priority.
+ task2.pcName = "TaskC";
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task2.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID03, &task2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task3.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskD5Func;
+ task3.usTaskPrio = 2; // 2, set reasonable priority.
+ task3.pcName = "TaskD";
+ task3.uwStackSize = TASK_STACK_SIZE_TEST;
+ task3.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task3.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID04, &task3);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority); // 10, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(LOS_HighBitGet(OsCurrTaskGet()->priBitMap), LOS_INVALID_BIT_INDEX,
+ LOS_HighBitGet(OsCurrTaskGet()->priBitMap));
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 8, g_testCount); // 8, here assert the result.
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task;
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LosMuxCreate(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskA5Func;
+ task.usTaskPrio = 10; // 10, set reasonable priority.
+ task.pcName = "TaskA";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 9, g_testCount); // 9, here assert the result.
+
+ ICUNIT_ASSERT_EQUAL(OsCurrTaskGet()->priority, 25, OsCurrTaskGet()->priority); // 25, here assert the result.
+ return LOS_OK;
+}
+
+VOID ItLosMux031(void)
+{
+ TEST_ADD_CASE("ItLosMux031", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_035.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_035.c
new file mode 100644
index 0000000000000000000000000000000000000000..b9c75822105bbeea5ebb97d676ff1c8da3e536f4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_035.c
@@ -0,0 +1,192 @@
+/*
+ * 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 "los_config.h"
+#include "los_bitmap.h"
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+static VOID TaskFe2Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ ret = LOS_MuxLock(&g_mutexTest2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 7, g_testCount); // 7, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static VOID TaskService3Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = LOS_MuxLock(&g_mutexTest2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static VOID TaskMisc10Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexTest1, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskService3Func;
+ task1.usTaskPrio = 3; // 3, set reasonable priority.
+ task1.pcName = "TaskService_3";
+ task1.uwStackSize = LOS_TASK_MIN_STACK_SIZE;
+ task1.uwResved = 0;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ LOS_TaskDelay(5); // 5, delay for Timing control.
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task;
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LosMuxCreate(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskMisc10Func;
+ task.usTaskPrio = 10; // 10, set reasonable priority.
+ task.pcName = "TaskMisc_10";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = 0;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskFe2Func;
+ task.usTaskPrio = 2; // 2, set reasonable priority.
+ task.pcName = "TaskFe_2";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = 0;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1000); // 1000, delay for Timing control.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 7, g_testCount); // 7, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ // 10, here assert the result.
+ ICUNIT_GOTO_EQUAL(LOS_TaskPriGet(g_testTaskID01), 10, LOS_TaskPriGet(g_testTaskID01), EXIT);
+ // 3, here assert the result.
+ ICUNIT_GOTO_EQUAL(LOS_TaskPriGet(g_testTaskID02), 3, LOS_TaskPriGet(g_testTaskID02), EXIT);
+ // 2, here assert the result.
+ ICUNIT_GOTO_EQUAL(LOS_TaskPriGet(g_testTaskID03), 2, LOS_TaskPriGet(g_testTaskID03), EXIT);
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_TaskDelete(g_testTaskID03);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosMux035(void)
+{
+ TEST_ADD_CASE("ItLosMux035", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_036.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_036.c
new file mode 100644
index 0000000000000000000000000000000000000000..dd41f227d85e7e6e8cc9b661ffbd7408f53a423c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_036.c
@@ -0,0 +1,174 @@
+/*
+ * 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 "los_config.h"
+#include "los_bitmap.h"
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+static VOID TaskFe4Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static VOID TaskService5Func(VOID)
+{
+ UINT32 ret;
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+static VOID TaskMisc10Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexTest1, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskService5Func;
+ task1.usTaskPrio = 5; // 5, set reasonable priority.
+ task1.pcName = "TaskService_5";
+ task1.uwStackSize = LOS_TASK_MIN_STACK_SIZE;
+ task1.uwResved = 0;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ LOS_TaskDelay(5); // 5, delay for Timing control.
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task;
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskMisc10Func;
+ task.usTaskPrio = 10; // 10, set reasonable priority.
+ task.pcName = "TaskMisc_10";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = 0;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskFe4Func;
+ task.usTaskPrio = 4; // 4, set reasonable priority.
+ task.pcName = "TaskFe_4";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = 0;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(200); // 200, set delay time.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ // 10, here assert the result.
+ ICUNIT_GOTO_EQUAL(LOS_TaskPriGet(g_testTaskID01), 10, LOS_TaskPriGet(g_testTaskID01), EXIT);
+ // 5, here assert the result.
+ ICUNIT_GOTO_EQUAL(LOS_TaskPriGet(g_testTaskID02), 5, LOS_TaskPriGet(g_testTaskID02), EXIT);
+ // 4, here assert the result.
+ ICUNIT_GOTO_EQUAL(LOS_TaskPriGet(g_testTaskID03), 4, LOS_TaskPriGet(g_testTaskID03), EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_TaskDelete(g_testTaskID03);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosMux036(void)
+{
+ TEST_ADD_CASE("ItLosMux036", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_037.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_037.c
new file mode 100644
index 0000000000000000000000000000000000000000..046a06fc25d3d804ba538af5110285c27205f57b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_037.c
@@ -0,0 +1,146 @@
+/*
+ * 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 "los_config.h"
+#include "los_bitmap.h"
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#define OS_MUX_NUM 1000
+LosMux *g_testMux = NULL;
+
+static VOID TaskFe4Func(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ for (INT32 i = 0; i < OS_MUX_NUM; i++) {
+ ret = LOS_MuxLock(&g_testMux[i], LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ }
+
+ g_testCount++;
+ return;
+}
+
+static VOID TaskMisc10Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+
+ g_testCount++;
+ for (INT32 i = 0; i < OS_MUX_NUM; i++) {
+ ret = LOS_MuxLock(&g_testMux[i], LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ }
+
+ g_testCount++;
+ PRINTK("taskMisc_10_func LOCK : 0x%x\n", &g_testMux[0]);
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task;
+ g_testCount = 0;
+
+ g_testMux = LOS_MemAlloc(m_aucSysMem0, OS_MUX_NUM * sizeof(LosMux));
+ ICUNIT_ASSERT_NOT_EQUAL(g_testMux, NULL, g_testMux);
+
+ for (INT32 i = 0; i < OS_MUX_NUM; i++) {
+ ret = LosMuxCreate(&g_testMux[i]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ g_testCount = 0;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskMisc10Func;
+ task.usTaskPrio = 10; // 10, set reasonable priority.
+ task.pcName = "TaskMisc_10";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskFe4Func;
+ task.usTaskPrio = 4; // 4, set reasonable priority.
+ task.pcName = "TaskFe_4";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ for (INT32 i = 0; i < OS_MUX_NUM; i++) {
+ ret = LOS_MuxLock(&g_testMux[i], LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+
+EXIT:
+ for (UINT32 i = 0; i < OS_MUX_NUM; i++) {
+ LOS_MuxUnlock(&g_testMux[i]);
+ LOS_MuxDestroy(&g_testMux[i]);
+ }
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID03);
+ LOS_MemFree(m_aucSysMem0, g_testMux);
+
+ return LOS_OK;
+}
+
+VOID ItLosMux037(void)
+{
+ TEST_ADD_CASE("ItLosMux037", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_038.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_038.c
new file mode 100644
index 0000000000000000000000000000000000000000..8ca4c57158a66574f615cb3689a343a71a1ef286
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_038.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "osTest.h"
+#include "los_config.h"
+#include "los_bitmap.h"
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#define OS_MUX_NUM 100
+static LosMux g_testMux1;
+
+static VOID TaskFe4Func(VOID)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ for (INT32 i = 0; i < OS_MUX_NUM; i++) {
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ }
+
+ g_testCount++;
+ return;
+}
+
+static VOID TaskMisc10Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+
+ g_testCount++;
+ for (INT32 i = 0; i < OS_MUX_NUM; i++) {
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ }
+
+ g_testCount++;
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task;
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_testMux1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount = 0;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskMisc10Func;
+ task.usTaskPrio = 10; // 10, set reasonable priority.
+ task.pcName = "TaskMisc_10";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskFe4Func;
+ task.usTaskPrio = 4; // 4, set reasonable priority.
+ task.pcName = "TaskFe_4";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+
+EXIT:
+ LOS_MuxUnlock(&g_testMux1);
+ LOS_MuxDestroy(&g_testMux1);
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID03);
+
+ return LOS_OK;
+}
+
+VOID ItLosMux038(void)
+{
+ TEST_ADD_CASE("ItLosMux038", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_039.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_039.c
new file mode 100644
index 0000000000000000000000000000000000000000..854dc3ffa29ecddfa74781a6f74bf8ea5e3e87e6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_039.c
@@ -0,0 +1,181 @@
+/*
+ * 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 "los_config.h"
+#include "los_bitmap.h"
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#define OS_MUX_NUM 1000
+static LosMux g_testMux1;
+static LosMux g_testMux2;
+static VOID TaskFe4Func(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ return;
+}
+
+static VOID TaskMisc10Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task;
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_testMux1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LosMuxCreate(&g_testMux2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskMisc10Func;
+ task.usTaskPrio = 10; // 10, set reasonable priority.
+ task.pcName = "TaskMisc_10";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+ g_testCount++;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskFe4Func;
+ task.usTaskPrio = 4; // 4, set reasonable priority.
+ task.pcName = "TaskFe_4";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result.
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT); // 7, here assert the result.
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID03);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux2, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 8, g_testCount, EXIT); // 8, here assert the result.
+
+EXIT:
+ ret = LOS_MuxUnlock(&g_testMux1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_testMux1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_testMux2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(OsCurrTaskGet()->priority, TASK_PRIO_TEST, OsCurrTaskGet()->priority);
+
+ ret = LOS_MuxDestroy(&g_testMux1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_testMux2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosMux039(void)
+{
+ TEST_ADD_CASE("ItLosMux039", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_040.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_040.c
new file mode 100644
index 0000000000000000000000000000000000000000..1a0523bd9d96eb8ef59bdab3658bc217eeafe425
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_040.c
@@ -0,0 +1,315 @@
+/*
+ * 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 "los_config.h"
+#include "los_bitmap.h"
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#define OS_MUX_NUM 1000
+static LosMux g_testMux1;
+static LosMux g_testMux2;
+static LosMux g_testMux3;
+static LosMux g_testMux4;
+static LosMux g_testMux5;
+
+static VOID TaskFe7Func(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 15, g_testCount); // 15, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux4, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 17, g_testCount); // 17, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 19, g_testCount); // 19, here assert the result.
+ g_testCount++;
+ return;
+}
+
+
+static VOID TaskFe8Func(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 13, g_testCount); // 13, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux3, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 20, g_testCount); // 20, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 21, g_testCount); // 21, here assert the result.
+ g_testCount++;
+ return;
+}
+
+static VOID TaskFe9Func(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 11, g_testCount); // 11, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 22, g_testCount); // 22, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 23, g_testCount); // 23, here assert the result.
+ g_testCount++;
+ return;
+}
+
+static VOID TaskMisc10Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux3, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux4, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+ g_testCount++;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 5, g_testCount); // 5, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux3, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 7, g_testCount); // 7, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux3, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 8, g_testCount); // 8, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux3, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 9, g_testCount); // 9, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task;
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_testMux1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LosMuxCreate(&g_testMux2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LosMuxCreate(&g_testMux3);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LosMuxCreate(&g_testMux4);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskMisc10Func;
+ task.usTaskPrio = 10; // 10, set reasonable priority.
+ task.pcName = "TaskMisc_10";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 10, g_testCount, EXIT); // 10, here assert the result.
+ g_testCount++;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskFe9Func;
+ task.usTaskPrio = 9; // 9, set reasonable priority.
+ task.pcName = "TaskFe_9";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 12, g_testCount, EXIT); // 12, here assert the result.
+ g_testCount++;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskFe8Func;
+ task.usTaskPrio = 8; // 8, set reasonable priority.
+ task.pcName = "TaskFe_8";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 14, g_testCount, EXIT); // 14, here assert the result.
+ g_testCount++;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskFe7Func;
+ task.usTaskPrio = 7; // 7, set reasonable priority.
+ task.pcName = "TaskFe_7";
+ task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID04, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 16, g_testCount, EXIT); // 16, here assert the result.
+ g_testCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 18, g_testCount, EXIT); // 18, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxUnlock(&g_testMux1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 24, g_testCount); // 24, here assert the result.
+
+ ret = LOS_MuxLock(&g_testMux2, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux3, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux4, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 24, g_testCount, EXIT); // 24, here assert the result.
+
+EXIT:
+ ret = LOS_MuxUnlock(&g_testMux2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_testMux3);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_testMux4);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(OsCurrTaskGet()->priority, TASK_PRIO_TEST, OsCurrTaskGet()->priority);
+
+ ret = LOS_MuxDestroy(&g_testMux1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_testMux2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_testMux3);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_testMux4);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosMux040(void)
+{
+ TEST_ADD_CASE("ItLosMux040", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_041.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_041.c
new file mode 100644
index 0000000000000000000000000000000000000000..a0b9fdf84c800f67c41a867471ada1358cd83630
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_041.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "osTest.h"
+#include "los_config.h"
+#include "los_bitmap.h"
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+static LosMux g_testMux1;
+static UINT32 g_mainTaskID;
+static VOID TaskMisc10Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+ LosTaskCB *taskCB = OS_TCB_FROM_TID(g_mainTaskID);
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux1, 10); // 10, init mutex.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ETIMEDOUT, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+ g_testCount++;
+
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S taskParam;
+ g_testCount = 0;
+ LosTaskCB *task = NULL;
+ UINT16 prio = OsCurrTaskGet()->priority;
+ g_mainTaskID = OsCurrTaskGet()->taskID;
+
+ ret = LosMuxCreate(&g_testMux1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ taskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskMisc10Func;
+ taskParam.usTaskPrio = 10; // 10, set reasonable priority.
+ taskParam.pcName = "TaskMisc_10";
+ taskParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskParam.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &taskParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority, EXIT); // 10, here assert the result.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+ g_testCount++;
+
+ LOS_TaskDelay(11); // 11, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxUnlock(&g_testMux1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(OsCurrTaskGet()->priority, prio, OsCurrTaskGet()->priority, EXIT);
+
+EXIT:
+ LOS_MuxUnlock(&g_testMux1);
+ ret = LOS_MuxDestroy(&g_testMux1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosMux041(void)
+{
+ TEST_ADD_CASE("ItLosMux041", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_042.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_042.c
new file mode 100644
index 0000000000000000000000000000000000000000..59ecf212104893b31cfd064a6b29ce9bf929ddbc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_042.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "osTest.h"
+#include "los_config.h"
+#include "los_bitmap.h"
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+static LosMux g_testMux1;
+static UINT32 g_mainTaskID;
+static VOID TaskFe4Func(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 8, g_testCount); // 8, here assert the result.
+ g_testCount++;
+
+ return;
+}
+
+static VOID TaskMisc10Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+ LosTaskCB *taskCB = OS_TCB_FROM_TID(g_mainTaskID);
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux1, 10); // 10, init mutex.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ETIMEDOUT, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(taskCB->priority, 4, taskCB->priority); // 4, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, here assert the result.
+ g_testCount++;
+
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S taskParam;
+ g_testCount = 0;
+ LosTaskCB *task = NULL;
+ UINT16 prio = OsCurrTaskGet()->priority;
+ g_mainTaskID = OsCurrTaskGet()->taskID;
+
+ ret = LosMuxCreate(&g_testMux1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+ g_testCount++;
+
+ taskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskMisc10Func;
+ taskParam.usTaskPrio = 10; // 10, set reasonable priority.
+ taskParam.pcName = "TaskMisc_10";
+ taskParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskParam.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &taskParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority, EXIT); // 10, here assert the result.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+ g_testCount++;
+
+ taskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskFe4Func;
+ taskParam.usTaskPrio = 4; // 4, set reasonable priority.
+ taskParam.pcName = "TaskFe_4";
+ taskParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskParam.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &taskParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(OsCurrTaskGet()->priority, 4, OsCurrTaskGet()->priority, EXIT); // 4, here assert the result.
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result.
+ g_testCount++;
+
+ LOS_TaskDelay(11); // 11, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT); // 7, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxUnlock(&g_testMux1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(OsCurrTaskGet()->priority, prio, OsCurrTaskGet()->priority, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 9, g_testCount, EXIT); // 9, here assert the result.
+
+EXIT:
+ ret = LOS_MuxUnlock(&g_testMux1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_testMux1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosMux042(void)
+{
+ TEST_ADD_CASE("ItLosMux042", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_043.c b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_043.c
new file mode 100644
index 0000000000000000000000000000000000000000..0aa758fb939a31d0fa4b1177269fef7ee2971412
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/full/It_los_mutex_043.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "osTest.h"
+#include "los_config.h"
+#include "los_bitmap.h"
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+static LosMux g_testMux1;
+static LosMux g_testMux2;
+static UINT32 g_mainTaskID;
+static VOID TaskFe4Func(VOID)
+{
+ UINT32 ret;
+ LosTaskCB *taskCB = OS_TCB_FROM_TID(g_mainTaskID);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(taskCB->priority, 10, taskCB->priority); // 10, here assert the result.
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 6, g_testCount); // 6, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxUnlock(&g_testMux2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static VOID TaskMisc10Func(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1, task2, task3;
+ LosTaskCB *taskCB = OS_TCB_FROM_TID(g_mainTaskID);
+ g_testCount++;
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 8, g_testCount); // 8, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxUnlock(&g_testMux1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S taskParam;
+ g_testCount = 0;
+ LosTaskCB *task = NULL;
+ LosMuxAttr attr = { 0 };
+
+ UINT16 prio = OsCurrTaskGet()->priority;
+ g_mainTaskID = OsCurrTaskGet()->taskID;
+
+ ret = LosMuxCreate(&g_testMux1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxAttrInit(&attr);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxAttrSetProtocol(&attr, LOS_MUX_PRIO_NONE);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxInit(&g_testMux2, &attr);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux1, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxLock(&g_testMux2, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+ g_testCount++;
+
+ taskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskMisc10Func;
+ taskParam.usTaskPrio = 10; // 10, set reasonable priority.
+ taskParam.pcName = "TaskMisc_10";
+ taskParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskParam.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &taskParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority, EXIT); // 10, here assert the result.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+ g_testCount++;
+
+ taskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskFe4Func;
+ taskParam.usTaskPrio = 4; // 4, set reasonable priority.
+ taskParam.pcName = "TaskFe_4";
+ taskParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskParam.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+
+ ret = LOS_TaskCreate(&g_testTaskID03, &taskParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(OsCurrTaskGet()->priority, 10, OsCurrTaskGet()->priority, EXIT); // 10, here assert the result.
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxUnlock(&g_testMux2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT); // 7, here assert the result.
+ g_testCount++;
+
+ ret = LOS_MuxUnlock(&g_testMux1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(OsCurrTaskGet()->priority, prio, OsCurrTaskGet()->priority, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 9, g_testCount, EXIT); // 9, here assert the result.
+
+EXIT:
+ ret = LOS_MuxDestroy(&g_testMux1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_testMux2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosMux043(void)
+{
+ TEST_ADD_CASE("ItLosMux043", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_001.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..3d90cafdf7ca3b5f27d704170f3f304a47e01b32
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_001.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 *mutex = NULL;
+ LosMux mutex1;
+
+ ret = LosMuxCreate(mutex);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_PTR_NULL, ret);
+
+ ret = LosMuxCreate(&mutex1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&mutex1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux001(void)
+{
+ TEST_ADD_CASE("ItLosMux001", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_002.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..1fe42276ae6ee10a56869dbf30c084e309bec7fe
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_002.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ LosMux maxSem;
+ LosMux semTemp;
+ UINT32 ret;
+
+ UINT32 *mutex = NULL;
+ LosMux mutex1;
+
+ ret = LosMuxCreate(&mutex1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&mutex1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&mutex1);
+ ICUNIT_ASSERT_EQUAL(ret, EBADF, ret);
+
+ ret = LOS_MuxDestroy(&maxSem);
+ ICUNIT_ASSERT_EQUAL(ret, EBADF, ret);
+
+ ret = LOS_MuxDestroy(&semTemp);
+ ICUNIT_ASSERT_EQUAL(ret, EBADF, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux002(void)
+{
+ TEST_ADD_CASE("ItLosMux002", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_003.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..70a19cbe9fd3fa1351b8b46858f7297916a3dedc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_003.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ LosMux muxHandle;
+
+ ret = LosMuxCreate(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&muxHandle, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_PENDED, ret);
+
+ ret = LOS_MuxUnlock(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&muxHandle, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, EBADF, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux003(void)
+{
+ TEST_ADD_CASE("ItLosMux003", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_004.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..cbe0333fd734e97d184544fcc709ba5e83a63d3d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smoke/It_los_mutex_004.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ LosMux muxHandle;
+
+ ret = LosMuxCreate(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&muxHandle, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&muxHandle, 1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_PENDED, ret);
+
+ ret = LOS_MuxUnlock(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_PENDED, ret);
+
+ ret = LOS_MuxUnlock(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&muxHandle);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&muxHandle, 0);
+ ICUNIT_ASSERT_EQUAL(ret, EBADF, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosMux004(void)
+{
+ TEST_ADD_CASE("ItLosMux004", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_001.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..679c594f6eebdd5b3e1bd00440086cb29b02cd88
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_001.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void Task01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 currCpuid;
+ g_testCount = 0;
+ TSK_INIT_PARAM_S task = { 0 };
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ task.pcName = "Test Case 1";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux001(void)
+{
+ TEST_ADD_CASE("ItSmpLosMux001", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_002.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..a862d1daa85fb3239aa7bbe3ac5258d5ccc442f9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_002.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void Task01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 currCpuid;
+ g_testCount = 0;
+ TSK_INIT_PARAM_S task = { 0 };
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ task.pcName = "Test Case 1";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux002(void)
+{
+ TEST_ADD_CASE("ItSmpLosMux002", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_003.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..9c5304ae156004b08047528a832546ce2b9e4c4f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_003.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static void Hwi01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ g_testCount++;
+}
+
+static void Task01(VOID)
+{
+ UINT32 ret;
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 currCpuid;
+ g_testCount = 0;
+ TSK_INIT_PARAM_S task = { 0 };
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 0, 0, (HWI_PROC_FUNC)Hwi01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid));
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ task.pcName = "Test Case 1";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_MuxUnlock(&g_mutexTest1);
+ LOS_MuxDestroy(&g_mutexTest1);
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux003(void)
+{
+ TEST_ADD_CASE("ItSmpLosMux003", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_004.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..c953130b642ada64c4345d9c69ca6cb675c63408
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_004.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void Task01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 currCpuid;
+ g_testCount = 0;
+ TSK_INIT_PARAM_S task = { 0 };
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ task.pcName = "Test Case 1";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux004(void)
+{
+ TEST_ADD_CASE("ItSmpLosMux004", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_005.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..5af5b2c966279effb19a1735599988abbd99482b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_005.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static void Task01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PENDED, ret);
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 currCpuid;
+ g_testCount = 0;
+ TSK_INIT_PARAM_S task = { 0 };
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ task.pcName = "Test Case 1";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux005(void)
+{
+ TEST_ADD_CASE("ItSmpLosMux005", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_006.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..fbc514a44b40777db1f98ae6c623864573dd3b96
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_006.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void Task01(VOID)
+{
+ UINT32 ret;
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ g_testCount++;
+}
+
+static void Task02(VOID)
+{
+ UINT32 ret;
+
+ ret = LosMuxCreate(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexTest2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexTest2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, currCpuid2;
+ g_testCount = 0;
+ TSK_INIT_PARAM_S task = { 0 };
+ TSK_INIT_PARAM_S task2 = { 0 };
+ currCpuid = ArchCurrCpuid() % (LOSCFG_KERNEL_CORE_NUM - 1) + 1;
+ currCpuid2 = currCpuid % (LOSCFG_KERNEL_CORE_NUM - 1) + 1;
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ task.pcName = "Test Case 1";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ task2.pcName = "Test Case 2";
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.uwResved = LOS_TASK_STATUS_DETACHED;
+ task2.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid2);
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux006(void)
+{
+ TEST_ADD_CASE("ItSmpLosMux006", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_007.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..13ca805df6aa992022a1f79efbfda0327a5f6c87
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_007.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static void Task01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(5); // 5, delay for Timing control.
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static void Task02(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_MuxLock(&g_mutexTest1, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestBusyTaskDelay(5); // 5, delay for Timing control.
+
+ ret = LOS_MuxUnlock(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, currCpuid2;
+ g_testCount = 0;
+ TSK_INIT_PARAM_S task = { 0 };
+ TSK_INIT_PARAM_S task2 = { 0 };
+ currCpuid = ArchCurrCpuid() % (LOSCFG_KERNEL_CORE_NUM - 1) + 1;
+ currCpuid2 = currCpuid % (LOSCFG_KERNEL_CORE_NUM - 1) + 1;
+
+ ret = LosMuxCreate(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ task.pcName = "Test Case 1";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ task2.pcName = "Test Case 2";
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.uwResved = LOS_TASK_STATUS_DETACHED;
+ task2.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid2);
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux007(void)
+{
+ TEST_ADD_CASE("ItSmpLosMux007", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2001.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2001.c
new file mode 100644
index 0000000000000000000000000000000000000000..c867725dcfbf1da2efd93b285901af928413fa2a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2001.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 "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2001(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2001", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2002.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2002.c
new file mode 100644
index 0000000000000000000000000000000000000000..63f06ba0b1724dd47627d2bde1920ac4c17c4683
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2002.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 "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2002(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2002", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2003.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2003.c
new file mode 100644
index 0000000000000000000000000000000000000000..7b374af5646afcd0ed631e845acce3064b3c4552
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2003.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 "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2003(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2003", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2004.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2004.c
new file mode 100644
index 0000000000000000000000000000000000000000..63b3368982e522ab4e87d43fc512c80ce46e9683
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2004.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2004(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2004", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2005.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2005.c
new file mode 100644
index 0000000000000000000000000000000000000000..60dd66940425e94a465a2ad1468433a910596a5d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2005.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, 3, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+EXIT:
+ LOS_MuxUnlock(&g_mutexkernelTest);
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PENDED, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 4); // 100, 4, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2005(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2005", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2006.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2006.c
new file mode 100644
index 0000000000000000000000000000000000000000..dc871546507ac12f62b478c6037a8c6979eb2771
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2006.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 volatile g_runFlag = 0;
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_runFlag);
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_runFlag = 1;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_006_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_PENDED, ret);
+
+ g_runFlag = 0;
+ TestAssertBusyTaskDelay(100, 3); // 100, 3, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2006(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2006", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2007.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2007.c
new file mode 100644
index 0000000000000000000000000000000000000000..d5a33896fec06fcd993a94e322f5a9a478a61dd3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2007.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PENDED, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ // 2, set reasonable priority.
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_007_task1", TaskF01, TASK_PRIO_TEST - 2,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_007_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 4); // 100, 4, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2007(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2007", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2008.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2008.c
new file mode 100644
index 0000000000000000000000000000000000000000..069edf338df537e302fc2bc8d01e10c34a2f3f82
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2008.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux2008(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2008", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2009.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2009.c
new file mode 100644
index 0000000000000000000000000000000000000000..195de2333534206b8dfca1abd3b73f2ea6d9281a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2009.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, 3, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+EXIT:
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PENDED, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 4); // 100, 4, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+
+EXIT:
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2009(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2009", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2010.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2010.c
new file mode 100644
index 0000000000000000000000000000000000000000..cbc9a0745359123db06fdefdc7bfe8fb783e1e8a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2010.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+EXIT:
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_010_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2010(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2010", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2011.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2011.c
new file mode 100644
index 0000000000000000000000000000000000000000..bd21a827a6a618c7fc9bae4c4b86c9e4e9fd9c08
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2011.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result. // task f01 pend
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_011_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_011_task1", TaskF01, TASK_PRIO_TEST + 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control. // TaskF01 run
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result.
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2011(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2011", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2012.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2012.c
new file mode 100644
index 0000000000000000000000000000000000000000..7eeff1b0e33c347c5644378ecab5bcb4e62fbdaf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2012.c
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, 5); // 5, init mutex.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_TIMEOUT, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+
+ LOS_TaskDelay(100); // 100, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result.
+EXIT:
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_MUX_2012_task1", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_MUX_2012_task2", TaskF01, TASK_PRIO_TEST + 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1); // task f01 run
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(200); // 200, set delay time.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT); // 6, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2012(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2012", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2013.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2013.c
new file mode 100644
index 0000000000000000000000000000000000000000..7a3b457582f27b273c5b262e2bce36b5ef7655ab
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2013.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 3); // 3, wait until g_testCount == 3.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_013_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_013_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 4); // 100, 4, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux2013(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2013", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2014.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2014.c
new file mode 100644
index 0000000000000000000000000000000000000000..8ccdcd6dd6ab58989d34b31ce87559a3d02a10b8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2014.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskDelay(5); // 5, delay for Timing control.
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 3); // 3, wait until g_testCount == 3.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task1", TaskF01, TASK_PRIO_TEST + 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.// task f01 run
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2014(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2014", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2015.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2015.c
new file mode 100644
index 0000000000000000000000000000000000000000..f57e6eac8fbfd3ba565c517b0e90a0c0c13b71b0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2015.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, 5); // 5, init mutex.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_TIMEOUT, ret);
+ PRINT_DEBUG("TaskF01 pend timeout\n");
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ PRINT_DEBUG("delay in task f02\n");
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ PRINT_DEBUG("post mux in task f02\n");
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+ PRINT_DEBUG("after post in hwi \n");
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static VOID HwiF02(VOID)
+{
+ UINT32 ret;
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST1, 1, 0, (HWI_PROC_FUNC)HwiF02, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ HalIrqSetAffinity(HWI_NUM_TEST1, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_MUX_2015_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 2); // 2, wait until g_testCount == 2.
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_MUX_2015_task1", TaskF01, TASK_PRIO_TEST + 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1); // task f01 run
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+
+ PRINT_DEBUG("delay in testtask begin\n");
+ LOS_TaskDelay(20); // 20, delay for Timing control.
+ PRINT_DEBUG("delay in testtask end\n");
+ TestHwiTrigger(HWI_NUM_TEST1);
+
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT); // 7, here assert the result.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_HwiDelete(HWI_NUM_TEST1, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2015(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2015", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2016.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2016.c
new file mode 100644
index 0000000000000000000000000000000000000000..f57bf84e216a1a466f90786e524b6019c67de7c5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2016.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2016(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2016", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2017.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2017.c
new file mode 100644
index 0000000000000000000000000000000000000000..728f25cebadf8e7fc329951f074f422f6250a965
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2017.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, 1, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ /* wait for task01 to pend sem */
+ TestBusyTaskDelay(2); // 2, delay for Timing control.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, taskdelete other cpu's task need time
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ LOS_TaskPriSet(g_testTskHandle, TASK_PRIO_TEST); // recovery test task's prio
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux2017(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2017", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2018.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2018.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d0a3287cdcbfaf5c86d0f369b89cd0c3b22c264
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2018.c
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile UINT32 g_flag1 = 1;
+static volatile UINT32 g_flag2 = 1;
+static VOID TaskF01(VOID)
+{
+ UINT32 ret, i;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ dprintf("task f01 get mux\n");
+ LOS_AtomicInc(&g_testCount);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_flag1);
+
+ dprintf("task f01 post mux\n");
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ TestDumpCpuid();
+ return;
+}
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ dprintf("task f02 get mux\n");
+ LOS_AtomicInc(&g_testCount);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_flag2);
+ dprintf("task f02 post mux\n");
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_flag1 = 1;
+ g_flag2 = 1;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_MUX_2018_task1", TaskF01, TASK_PRIO_TEST + 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_MUX_2018_task2", TaskF02, TASK_PRIO_TEST + 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu, low prio
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(2); // let task f02 run
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, wait for task f01 run
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+ /* wait for task01 to pend sem */
+ TestBusyTaskDelay(2); // 2, delay for Timing control.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+
+ do {
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+
+ __asm__ volatile("nop");
+ } while (!(ret & (OS_TASK_STATUS_RUNNING | OS_TASK_STATUS_PEND)));
+
+ if (ret & OS_TASK_STATUS_RUNNING) { // task f01 get the mux
+ dprintf("running task f01\n");
+ ret = LOS_TaskDelete(g_testTaskID02); // so delete the task f02
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ g_flag1 = 0; // mux post in task f01
+ g_flag2 = 1;
+ } else if (ret & OS_TASK_STATUS_PEND) { // task f02 get the mux
+ dprintf("pend task f01\n");
+ ret = LOS_TaskDelete(g_testTaskID01); // so delete the task f01
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelay(2); // 2, cross core to delete task
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ g_flag2 = 0; // mux post in task f02
+ g_flag1 = 1;
+ } else {
+ dprintf("ret = 0x%x\n", ret);
+ }
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2018(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2018", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2021.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2021.c
new file mode 100644
index 0000000000000000000000000000000000000000..20fb6c501f88d4188c48a94b511604529f86ab94
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2021.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_021_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, 1, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ /* 2, wait for task01 to pend sem */
+ TestBusyTaskDelay(2);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux2021(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2021", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2022.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2022.c
new file mode 100644
index 0000000000000000000000000000000000000000..7c6f7460290a711316459f029c75d9b9e1b0af35
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2022.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, 1, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux2022(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2022", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2024.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2024.c
new file mode 100644
index 0000000000000000000000000000000000000000..31f903d5105f74729bb9540e783cc13adef59a0c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2024.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(1);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2024(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2024", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2025.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2025.c
new file mode 100644
index 0000000000000000000000000000000000000000..eb0077810acbec57fe60e414e55aede1e553e17b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2025.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PEND_INTERR, ret);
+
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, 1, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2025(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2025", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2026.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2026.c
new file mode 100644
index 0000000000000000000000000000000000000000..2645395355ec59ba107983393826c8d6d43074b9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2026.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, other core get the sem first
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, uvIntSave;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ // 3, set reasonable priority.
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_MUX_2026_task2", TaskF02, TASK_PRIO_TEST - 3,
+ CPUID_TO_AFFI_MASK(currCpuid)); // let the task f02 pend mux first
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_MUX_2026_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(2); // test task's prio be seted 22
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT);
+
+ LOS_TaskLock();
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); // task schedule in other cpu
+
+ TestAssertBusyTaskDelay(100, 3); // 100, 3, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, not schedule in current cpu cause tasklock
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result.
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+EXIT1:
+ LOS_TaskUnlock();
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux2026(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2026", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2027.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2027.c
new file mode 100644
index 0000000000000000000000000000000000000000..9fa9a020c11caac41ffc9e4433976a5fff8f8c59
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2027.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile UINT32 g_runFlag = 1;
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, here assert the result.
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, uvIntSave;
+
+ LOS_TaskLock(); // task lock on other cpu
+ LOS_AtomicInc(&g_testCount);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_runFlag == 1);
+
+ LOS_TaskUnlock(); // schedule occur ---switch to task f01
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ TestDumpCpuid();
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_runFlag = 1;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_034_task1", TaskF01, TASK_PRIO_TEST - 2, // 2, set reasonable priority.
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_034_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+ /* 2, wait for task01 to pend mutex */
+ TestBusyTaskDelay(2);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest); // try to wake task f01
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay enough time for other cpu
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, cause tasklock on other cpu ,so task f01 wake failed
+
+ LOS_AtomicInc(&g_testCount);
+
+ g_runFlag = 0; // unlock the other cpu
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, not schedule in current cpu cause tasklock
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_MuxDestroy(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux2027(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2027", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2028.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2028.c
new file mode 100644
index 0000000000000000000000000000000000000000..b513a57c46fa2a6b7dc1a2c805489be804d654be
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2028.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret, i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++) { // 500, get rand number in 500.
+ }
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (1);
+ TestDumpCpuid();
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_028_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 0); // wait for task f01 run
+
+ for (j = 0; j < TRandom() % 500; j++) { // 500, get rand number in 500.
+ }
+ ret = LOS_TaskDelete(g_testTaskID01);
+ if (ret != LOS_OK && ret != LOS_ERRNO_TSK_MP_SYNC_FAILED) {
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ }
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_UNUSED, ret, EXIT);
+
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ }
+
+EXIT:
+ LOS_TaskPriSet(g_testTskHandle, TASK_PRIO_TEST); // recovery test task's prio
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosMux2028(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2028", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2029.c b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2029.c
new file mode 100644
index 0000000000000000000000000000000000000000..e66a65f02fdb4d225d067a1b0ad8196d675b6e90
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/mux/smp/It_smp_los_mux_2029.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_mux.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_ret = 0xff;
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER); // pend on current cpu
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++) { // 500, get rand number in 500.
+ }
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ g_ret = ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ PRINT_DEBUG("i = %d\n", i);
+ ret = LosMuxCreate(&g_mutexkernelTest);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_MuxLock(&g_mutexkernelTest, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_event_037_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_event_037_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 1); // wait for task f02
+
+ for (j = 0; j < TRandom() % 500; j++) { // 500, get rand number in 500.
+ }
+
+ ret = LOS_MuxUnlock(&g_mutexkernelTest); // try to wake task f01
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ if ((g_ret != LOS_OK) && (g_ret != LOS_ERRNO_TSK_NOT_CREATED)) {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret, EXIT);
+ }
+
+ PRINT_DEBUG("g_testCount = %d ,g_ret = 0x%x\n", g_testCount, g_ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ }
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_MuxDestroy(&g_mutexkernelTest);
+ return LOS_OK;
+}
+
+VOID ItSmpLosMux2029(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosMux2029", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/It_los_queue.c b/testsuites/kernel/sample/kernel_base/ipc/queue/It_los_queue.c
new file mode 100644
index 0000000000000000000000000000000000000000..2a7816a1c15986a01fe02b8fe1ac6bfe4b66d705
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/It_los_queue.c
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_queue.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+VOID ItSuiteLosQueue(VOID)
+{
+#if (LOSCFG_KERNEL_SMP == YES)
+ ItSmpLosQueue001();
+ ItSmpLosQueue002();
+ ItSmpLosQueue003();
+ ItSmpLosQueue004();
+ ItSmpLosQueue005();
+ ItSmpLosQueue006();
+ ItSmpLosQueue007();
+ ItSmpLosQueue008();
+ ItSmpLosQueue009();
+ ItSmpLosQueue010();
+ ItSmpLosQueue011();
+ ItSmpLosQueue012();
+ ItSmpLosQueue013();
+ ItSmpLosQueue014();
+ ItSmpLosQueue015();
+ ItSmpLosQueue016();
+ ItSmpLosQueue017();
+ ItSmpLosQueue018();
+ ItSmpLosQueue019();
+ ItSmpLosQueue020();
+ ItSmpLosQueue021();
+ ItSmpLosQueue022();
+ ItSmpLosQueue023();
+ ItSmpLosQueue024();
+ ItSmpLosQueue025();
+ ItSmpLosQueue026();
+ ItSmpLosQueue027();
+ ItSmpLosQueue029();
+ ItSmpLosQueue031();
+ ItSmpLosQueue032();
+#endif
+#if defined(LOSCFG_TEST_SMOKE)
+ ItLosQueue001();
+ ItLosQueue097();
+#if (LOS_MEM_TLSF == YES)
+#else
+ ItLosQueue100();
+ ItLosQueue105();
+#endif
+ ItLosQueueHead002();
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+ ItLosQueue002();
+ ItLosQueue003();
+ ItLosQueue005();
+ ItLosQueue006();
+ ItLosQueue007();
+ ItLosQueue008();
+ ItLosQueue009();
+ ItLosQueue010();
+ ItLosQueue011();
+ ItLosQueue012();
+ ItLosQueue013();
+ ItLosQueue014();
+ ItLosQueue015();
+ ItLosQueue017();
+ ItLosQueue018();
+ ItLosQueue019();
+ ItLosQueue020();
+#if (LOSCFG_KERNEL_SMP != YES)
+ ItLosQueue021();
+#endif
+ ItLosQueue022();
+ ItLosQueue023();
+ ItLosQueue024();
+ ItLosQueue025();
+ ItLosQueue026();
+ ItLosQueue027();
+ ItLosQueue028();
+ ItLosQueue029();
+ ItLosQueue032();
+ ItLosQueue033();
+ ItLosQueue037();
+ ItLosQueue038();
+ ItLosQueue040();
+ ItLosQueue041();
+ ItLosQueue042();
+ ItLosQueue043();
+ ItLosQueue044();
+ ItLosQueue045();
+ ItLosQueue046();
+ ItLosQueue047();
+ ItLosQueue048();
+ ItLosQueue049();
+ ItLosQueue050();
+ ItLosQueue051();
+ ItLosQueue052();
+ ItLosQueue053();
+ ItLosQueue054();
+ ItLosQueue055();
+ ItLosQueue056();
+ ItLosQueue057();
+ ItLosQueue058();
+ ItLosQueue059();
+ ItLosQueue061();
+ ItLosQueue062();
+ ItLosQueue064();
+ ItLosQueue065();
+ ItLosQueue066();
+ ItLosQueue067();
+ ItLosQueue068();
+ ItLosQueue069();
+ ItLosQueue070();
+ ItLosQueue071();
+ ItLosQueue072();
+ ItLosQueue073();
+ ItLosQueue074();
+ ItLosQueue075();
+ ItLosQueue076();
+ ItLosQueue077();
+ ItLosQueue078();
+ ItLosQueue079();
+ ItLosQueue080();
+ ItLosQueue081();
+ ItLosQueue082();
+ ItLosQueue083();
+ ItLosQueue084();
+ ItLosQueue085();
+ ItLosQueue086();
+ ItLosQueue087();
+ ItLosQueue088();
+ ItLosQueue089();
+ ItLosQueue091();
+ ItLosQueue092();
+ ItLosQueue093();
+ ItLosQueue094();
+ ItLosQueue095();
+ ItLosQueue096();
+ ItLosQueue098();
+
+#if (LOS_MEM_TLSF == YES)
+#else
+ ItLosQueue099();
+ ItLosQueue101();
+ ItLosQueue102();
+ ItLosQueue103();
+ ItLosQueue104();
+ ItLosQueue106();
+ ItLosQueue107();
+ ItLosQueue108();
+ ItLosQueue109();
+ ItLosQueue110();
+ ItLosQueue111();
+ ItLosQueue112();
+ ItLosQueue113();
+ ItLosQueue114();
+ ItLosQueue116();
+#endif
+
+ ItLosQueueHead003();
+ ItLosQueueHead004();
+ ItLosQueueHead005();
+ ItLosQueueHead006();
+ ItLosQueueHead007();
+ ItLosQueueHead008();
+ ItLosQueueHead009();
+ ItLosQueueHead010();
+ ItLosQueueHead011();
+ ItLosQueueHead012();
+ ItLosQueueHead013();
+ ItLosQueueHead014();
+ ItLosQueueHead015();
+ ItLosQueueHead016();
+ ItLosQueueHead017();
+ ItLosQueueHead018();
+ ItLosQueueHead019();
+ ItLosQueueHead020();
+ ItLosQueueHead021();
+ ItLosQueueHead022();
+ ItLosQueueHead023();
+ ItLosQueueHead024();
+ ItLosQueueHead025();
+ ItLosQueueHead026();
+ ItLosQueueHead027();
+ ItLosQueueHead028();
+ ItLosQueueHead029();
+ ItLosQueueHead030();
+ ItLosQueueHead031();
+ ItLosQueueHead032();
+ ItLosQueueHead038();
+ ItLosQueueHead039();
+ ItLosQueueHead040();
+ ItLosQueueHead041();
+ ItLosQueueHead042();
+#endif
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, 1);
+#endif
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/It_los_queue.h b/testsuites/kernel/sample/kernel_base/ipc/queue/It_los_queue.h
new file mode 100644
index 0000000000000000000000000000000000000000..089ac9f0032100e292cee462326fe559462b5646
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/It_los_queue.h
@@ -0,0 +1,299 @@
+/*
+ * 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 "los_base.h"
+#include "los_task.h"
+#include "los_membox.h"
+#include "osTest.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define QUEUE_SHORT_BUFFER_LENTH 12
+#define QUEUE_STANDARD_BUFFER_LENTH 50
+#define QUEUE_BASE_NUM 3
+#define QUEUE_BASE_MSGSIZE 8
+
+#define LOOP 100
+
+#ifdef __LP64__
+#define PER_ADDED_VALUE 8
+#else
+#define PER_ADDED_VALUE 4
+#endif
+
+extern UINT32 g_testTaskID01;
+extern UINT32 g_testTaskID02;
+extern UINT32 g_testQueueID01;
+extern UINT32 g_testQueueID02;
+extern UINT32 g_TestQueueID03;
+
+extern VOID ItSuiteLosQueue(VOID);
+
+#if defined(LOSCFG_TEST_SMOKE)
+VOID ItLosQueue001(VOID);
+VOID ItLosQueue097(VOID);
+#if (LOS_MEM_TLSF == YES)
+#else
+VOID ItLosQueue100(VOID);
+VOID ItLosQueue105(VOID);
+#endif
+VOID ItLosQueueHead002(VOID);
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+VOID ItLosQueue002(VOID);
+VOID ItLosQueue003(VOID);
+VOID ItLosQueue004(VOID);
+VOID ItLosQueue005(VOID);
+VOID ItLosQueue006(VOID);
+VOID ItLosQueue007(VOID);
+VOID ItLosQueue008(VOID);
+VOID ItLosQueue009(VOID);
+VOID ItLosQueue010(VOID);
+VOID ItLosQueue011(VOID);
+VOID ItLosQueue012(VOID);
+VOID ItLosQueue013(VOID);
+VOID ItLosQueue014(VOID);
+VOID ItLosQueue015(VOID);
+VOID ItLosQueue017(VOID);
+VOID ItLosQueue018(VOID);
+VOID ItLosQueue019(VOID);
+VOID ItLosQueue020(VOID);
+VOID ItLosQueue021(VOID);
+VOID ItLosQueue022(VOID);
+VOID ItLosQueue023(VOID);
+VOID ItLosQueue024(VOID);
+VOID ItLosQueue025(VOID);
+VOID ItLosQueue026(VOID);
+VOID ItLosQueue027(VOID);
+VOID ItLosQueue028(VOID);
+VOID ItLosQueue029(VOID);
+VOID ItLosQueue032(VOID);
+VOID ItLosQueue033(VOID);
+VOID ItLosQueue037(VOID);
+VOID ItLosQueue038(VOID);
+VOID ItLosQueue040(VOID);
+VOID ItLosQueue041(VOID);
+VOID ItLosQueue042(VOID);
+VOID ItLosQueue043(VOID);
+VOID ItLosQueue044(VOID);
+VOID ItLosQueue045(VOID);
+VOID ItLosQueue046(VOID);
+VOID ItLosQueue047(VOID);
+VOID ItLosQueue048(VOID);
+VOID ItLosQueue049(VOID);
+VOID ItLosQueue050(VOID);
+VOID ItLosQueue051(VOID);
+VOID ItLosQueue052(VOID);
+VOID ItLosQueue053(VOID);
+VOID ItLosQueue054(VOID);
+VOID ItLosQueue055(VOID);
+VOID ItLosQueue056(VOID);
+VOID ItLosQueue057(VOID);
+VOID ItLosQueue058(VOID);
+VOID ItLosQueue059(VOID);
+VOID ItLosQueue061(VOID);
+VOID ItLosQueue062(VOID);
+VOID ItLosQueue064(VOID);
+VOID ItLosQueue065(VOID);
+VOID ItLosQueue066(VOID);
+VOID ItLosQueue067(VOID);
+VOID ItLosQueue068(VOID);
+VOID ItLosQueue069(VOID);
+VOID ItLosQueue070(VOID);
+VOID ItLosQueue071(VOID);
+VOID ItLosQueue072(VOID);
+VOID ItLosQueue073(VOID);
+VOID ItLosQueue074(VOID);
+VOID ItLosQueue075(VOID);
+VOID ItLosQueue076(VOID);
+VOID ItLosQueue077(VOID);
+VOID ItLosQueue078(VOID);
+VOID ItLosQueue079(VOID);
+VOID ItLosQueue080(VOID);
+VOID ItLosQueue081(VOID);
+VOID ItLosQueue082(VOID);
+VOID ItLosQueue083(VOID);
+VOID ItLosQueue084(VOID);
+VOID ItLosQueue085(VOID);
+VOID ItLosQueue086(VOID);
+VOID ItLosQueue087(VOID);
+VOID ItLosQueue088(VOID);
+VOID ItLosQueue089(VOID);
+VOID ItLosQueue090(VOID);
+VOID ItLosQueue091(VOID);
+VOID ItLosQueue092(VOID);
+VOID ItLosQueue093(VOID);
+VOID ItLosQueue094(VOID);
+VOID ItLosQueue095(VOID);
+VOID ItLosQueue096(VOID);
+VOID ItLosQueue098(VOID);
+VOID ItLosQueue099(VOID);
+VOID ItLosQueue101(VOID);
+VOID ItLosQueue102(VOID);
+VOID ItLosQueue103(VOID);
+VOID ItLosQueue104(VOID);
+VOID ItLosQueue106(VOID);
+VOID ItLosQueue107(VOID);
+VOID ItLosQueue108(VOID);
+VOID ItLosQueue109(VOID);
+VOID ItLosQueue110(VOID);
+VOID ItLosQueue111(VOID);
+VOID ItLosQueue112(VOID);
+VOID ItLosQueue113(VOID);
+VOID ItLosQueue114(VOID);
+VOID ItLosQueue116(VOID);
+
+VOID ItLosQueueHead003(VOID);
+VOID ItLosQueueHead004(VOID);
+VOID ItLosQueueHead005(VOID);
+VOID ItLosQueueHead006(VOID);
+VOID ItLosQueueHead007(VOID);
+VOID ItLosQueueHead008(VOID);
+VOID ItLosQueueHead009(VOID);
+VOID ItLosQueueHead010(VOID);
+VOID ItLosQueueHead011(VOID);
+VOID ItLosQueueHead012(VOID);
+VOID ItLosQueueHead013(VOID);
+VOID ItLosQueueHead014(VOID);
+VOID ItLosQueueHead015(VOID);
+VOID ItLosQueueHead016(VOID);
+VOID ItLosQueueHead017(VOID);
+VOID ItLosQueueHead018(VOID);
+VOID ItLosQueueHead019(VOID);
+VOID ItLosQueueHead020(VOID);
+VOID ItLosQueueHead021(VOID);
+VOID ItLosQueueHead022(VOID);
+VOID ItLosQueueHead023(VOID);
+VOID ItLosQueueHead024(VOID);
+VOID ItLosQueueHead025(VOID);
+VOID ItLosQueueHead026(VOID);
+VOID ItLosQueueHead027(VOID);
+VOID ItLosQueueHead028(VOID);
+VOID ItLosQueueHead029(VOID);
+VOID ItLosQueueHead030(VOID);
+VOID ItLosQueueHead031(VOID);
+VOID ItLosQueueHead032(VOID);
+VOID ItLosQueueHead036(VOID);
+VOID ItLosQueueHead038(VOID);
+VOID ItLosQueueHead039(VOID);
+VOID ItLosQueueHead040(VOID);
+VOID ItLosQueueHead041(VOID);
+VOID ItLosQueueHead042(VOID);
+#endif
+
+#if defined(LOSCFG_TEST_MANUAL_SHELL) && defined(LOSCFG_DEBUG_QUEUE)
+VOID ItLosQueueManual001(VOID);
+VOID ItLosQueueManual002(VOID);
+VOID ItLosQueueManual003(VOID);
+VOID ItLosQueueManual004(VOID);
+VOID ItLosQueueManual005(VOID);
+VOID ItLosQueueManual006(VOID);
+VOID ItLosQueueManual007(VOID);
+VOID ItLosQueueManual008(VOID);
+VOID ItLosQueueManual009(VOID);
+VOID ItLosQueueManual010(VOID);
+#endif
+#if defined(LOSCFG_TEST_PRESSURE)
+VOID ItLosQueue016(VOID);
+VOID ItLosQueue030(VOID);
+VOID ItLosQueue031(VOID);
+VOID ItLosQueue034(VOID);
+VOID ItLosQueue035(VOID);
+VOID ItLosQueue036(VOID);
+VOID ItLosQueue039(VOID);
+VOID ItLosQueue060(VOID);
+VOID ItLosQueue063(VOID);
+VOID ItLosQueue123(VOID);
+
+
+#endif
+
+#if defined(LOSCFG_TEST_LLT)
+VOID ItLosQueueHead001(VOID);
+VOID ItLosQueue115(VOID);
+VOID ItLosQueue117(VOID);
+VOID ItLosQueue118(VOID);
+VOID ItLosQueue119(VOID);
+VOID ItLosQueue120(VOID);
+VOID ItLosQueue121(VOID);
+VOID ItLosQueue122(VOID);
+#if defined(LOSCFG_SHELL) && defined(LOSCFG_DEBUG_QUEUE)
+VOID ItLosQueueDebug001(void);
+#endif
+#endif
+
+#if (LOSCFG_KERNEL_SMP == YES)
+VOID ItSmpLosQueue001(VOID);
+VOID ItSmpLosQueue002(VOID);
+VOID ItSmpLosQueue003(VOID);
+VOID ItSmpLosQueue004(VOID);
+VOID ItSmpLosQueue005(VOID);
+VOID ItSmpLosQueue006(VOID);
+VOID ItSmpLosQueue007(VOID);
+VOID ItSmpLosQueue008(VOID);
+VOID ItSmpLosQueue009(VOID);
+VOID ItSmpLosQueue010(VOID);
+VOID ItSmpLosQueue011(VOID);
+VOID ItSmpLosQueue012(VOID);
+VOID ItSmpLosQueue013(VOID);
+VOID ItSmpLosQueue014(VOID);
+VOID ItSmpLosQueue015(VOID);
+VOID ItSmpLosQueue016(VOID);
+VOID ItSmpLosQueue017(VOID);
+VOID ItSmpLosQueue018(VOID);
+VOID ItSmpLosQueue019(VOID);
+VOID ItSmpLosQueue020(VOID);
+VOID ItSmpLosQueue021(VOID);
+VOID ItSmpLosQueue022(VOID);
+VOID ItSmpLosQueue023(VOID);
+VOID ItSmpLosQueue024(VOID);
+VOID ItSmpLosQueue025(VOID);
+VOID ItSmpLosQueue026(VOID);
+VOID ItSmpLosQueue027(VOID);
+VOID ItSmpLosQueue028(VOID);
+VOID ItSmpLosQueue029(VOID);
+VOID ItSmpLosQueue030(VOID);
+VOID ItSmpLosQueue031(VOID);
+VOID ItSmpLosQueue032(VOID);
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_002.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..23fa5cf372818f407075f1fefc392f3657483ae5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_002.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testQueueID01 = 1025; // 1025, ID of successfully created queue control structure.
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 0); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_PARA_ISZERO, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue002(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue002", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_003.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..737e2f198bbcdb3ae7824a2fe98c81766d531cb9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_003.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 1); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 16, 0); // 16, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 16, 0); // 16, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue003(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue003", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_005.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..22d43a500aabc7f749f2ce44b36473e20ea6f02d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_005.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testQueueID01 = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+
+ ret = LOS_QueueCreate("Q1", 30, &g_testQueueID01, 0, 0xFFFF); // 30, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_SIZE_TOO_BIG, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+
+VOID ItLosQueue005(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue005", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_006.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..5c2b56b7b55a14c85dbd4b2cbaa5772f07b31390
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_006.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testQueueID01 = 1025; // 1025, ID of successfully created queue control structure.
+
+ ret = LOS_QueueCreate("Q1", 3, NULL, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_CREAT_PTR_NULL, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the settig size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+
+VOID ItLosQueue006(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue006", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_007.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..df11eaa9712b73ed71ba4dcebceabcf6f9a43542
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_007.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testQueueID01 = 1025; // 1025, ID of successfully created queue control structure.
+
+ ret = LOS_QueueCreate("Q1", 0, &g_testQueueID01, 0, 8); // 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_PARA_ISZERO, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue007(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue007", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_008.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..496da0e8a8e8890e5c0d26f43fb88b296e1cbff4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_008.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue008(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue008", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_009.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..84b8407669b1de646f3670c9739a7653d2c4d464
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_009.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testQueueID01 = 1025; // 1025, ID of successfully created queue control structure.
+
+ ret = LOS_QueueCreate("Q1", 0xFFFE, &g_testQueueID01, 0, 0xFFF0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_CREATE_NO_MEMORY, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue009(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue009", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_010.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..f2d1c72d12df9d0be852df9cb89a2805202b5d2d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_010.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSPtest";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testQueueID01 = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+
+#if defined(TEST3559A_M7) || defined(TESTHI1980IMU) || defined(TEST1980)
+ ret = LOS_QueueCreate("Q1", 0xFF, &g_testQueueID01, 0, sizeof(UINTPTR));
+#else
+ ret = LOS_QueueCreate("Q1", 0xFFFF, &g_testQueueID01, 0, sizeof(UINTPTR));
+#endif
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 12, 0); // 12, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 12, 0); // 12, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue010(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue010", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_011.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..c3b701f2a16f8800bb27455ee7fb0217b1ce2e07
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_011.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSPtest";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue011(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue011", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_012.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..46e1999de7c8bd983083dce67461a84c26dc7ab7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_012.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[] = "UniDSPOS";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, sizeof(UINTPTR) * 2, 0); // 2, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, (sizeof(UINTPTR) * 2 - 1), 0); // 2, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + 6), buff1[6], *((char *)buff2 + 6), EXIT); // 6, The offset of queue buffer.
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + 7), 'S', *((char *)buff2 + 7), EXIT); // 7, The offset of queue buffer.
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue012(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue012", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_013.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..c18beaf0ca70f1f12cd8f2321333954cfb083df4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_013.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[] = "UniDSPOS";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 9, 0); // 9, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + 7), buff1[7], *((char *)buff2 + 7), EXIT); // 7, The offset of queue buffer.
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + 8), '\0', *((char *)buff2 + 8), EXIT); // 8, The offset of queue buffer.
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue013(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue013", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_014.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_014.c
new file mode 100644
index 0000000000000000000000000000000000000000..62704fe9f309f71bbc38d88a5b0edc333b10c58a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_014.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSPOS";
+ CHAR buff2[9] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READSIZE_IS_INVALID, ret, EXIT);
+ for (index = 0; index < 9; index++) { // 9, The offset of queue buffer.
+ ICUNIT_GOTO_EQUAL(buff2[index], '\0', buff2[index], EXIT);
+ }
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue014(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue014", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_015.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..57cbb757c3004909cc9122cda87b9bacfd5de217
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_015.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[9] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 9, 0); // 9, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 9, 0); // 9, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue015(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue015", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_017.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_017.c
new file mode 100644
index 0000000000000000000000000000000000000000..cc1df50bc842ddf1d31fa2a6f09bf8592bda7b92
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_017.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, NULL, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READ_PTR_NULL, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue017(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue017", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_018.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..b042c8fb78546d42d935f7231ae84fc2fbe73c32
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_018.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead((UINT32)-1, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue018(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue018", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_019.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..37592115a853bdabb674fc3e17f393209bb66674
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_019.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue019(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue019", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_020.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..f4ee453c56f4f42502a9cf55c58cb9a4ce7b11e1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_020.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueCreate("Q2", 3, &g_testQueueID02, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID02, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID02, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueDelete(g_testQueueID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue020(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue020", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_021.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..b1e7930958ce7d0ffbbc1903edb4a5aadbe3acaa
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_021.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ UINT32 queueID[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ UINT32 exsitedQueue = QUEUE_EXISTED_NUM;
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueCreate(NULL, 3, &queueID[index], 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_QueueWrite(queueID[index - 1], &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(queueID[index - 1], &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); // 3, Set the queue length.
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID[index], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID[index], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueDelete(queueID[index]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue021(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue021", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_022.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..ff070eefc70dea3b0f286338c41d35895e661696
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_022.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ UINT32 queueID[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ UINT32 exsitedQueue = QUEUE_EXISTED_NUM;
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueCreate(NULL, 3, &queueID[index], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID[LOSCFG_BASE_IPC_QUEUE_CONFIG], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_CB_UNAVAILABLE, ret, EXIT);
+
+ ret = LOS_QueueWrite(LOSCFG_BASE_IPC_QUEUE_CONFIG + 1, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_CONFIG + 1, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+EXIT:
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueDelete(queueID[index]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue022(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue022", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_023.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..61e5010790caccd12de775dd7fb64b3592b243f3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_023.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue023(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue023", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_024.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_024.c
new file mode 100644
index 0000000000000000000000000000000000000000..39e928b2b7132ff1a1709fafd2275474dc04c23f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_024.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 13, 0); // 13, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue024(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue024", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_025.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_025.c
new file mode 100644
index 0000000000000000000000000000000000000000..e06dc74b9141f03441fc2b7efc7aace3f960f05e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_025.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 7, 0); // 7, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ for (index = 0; index < 7; index++) { // 7, The offset of queue buffer.
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + index), buff1[index], *((char *)buff2 + index), EXIT);
+ }
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue025(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue025", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_026.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..cc4f781e3b3146e873ba386173d65aa0af3f5586
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_026.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "gjl";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, NULL, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_WRITE_PTR_NULL, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue026(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue026", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_027.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..264fd606491fa33a4689a66c9d07f4e0e1183b97
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_027.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite((UINT32)-1, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue027(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue027", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_028.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_028.c
new file mode 100644
index 0000000000000000000000000000000000000000..335bc7ff230c6597c59dec03a418dbfed7b5572f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_028.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueWrite(QUEUE_EXISTED_NUM + 1, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret);
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue028(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue028", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_029.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..05a3cf4c013591ed978863496080fbfd430c88ea
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_029.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueCreate("Q2", 3, &g_testQueueID02, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueDelete(g_testQueueID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue029(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue029", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_032.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_032.c
new file mode 100644
index 0000000000000000000000000000000000000000..59d50dfe5810bf8019fcc26a0a4501d23968310e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_032.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "DOPRA";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueCreate("Q2", 3, &g_testQueueID02, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID02, &buff2, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueDelete(g_testQueueID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueue032(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue032", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_033.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_033.c
new file mode 100644
index 0000000000000000000000000000000000000000..86522f32ccf0d2a9f473eb569cd4c292bff52715
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_033.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH];
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff1, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue033(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue033", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_037.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_037.c
new file mode 100644
index 0000000000000000000000000000000000000000..9c847ab559e6f59ff7fc59fd4707dce0c2f226a3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_037.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "DOPRA";
+ CHAR buff3[8] = "TEST";
+ UINTPTR buff4;
+ UINTPTR buff5;
+ UINTPTR buff6;
+
+ // 3, Set the queue length
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff2, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff3, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff4, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff5, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff6, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ for (index = 0; index < 8; index++) { // 8, The offset of queue buffer.
+ ICUNIT_GOTO_EQUAL(*((char *)buff4 + index), buff1[index], *((char *)buff4 + index), EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff5 + index), buff2[index], *((char *)buff5 + index), EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff6 + index), buff3[index], *((char *)buff6 + index), EXIT);
+ }
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue037(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue037", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_038.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_038.c
new file mode 100644
index 0000000000000000000000000000000000000000..e8f870264579cb94a823ebce7b917b628c698322
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_038.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ for (index = 0; index < 3; index++) { // 3, The offset of queue buffer.
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ for (index = 0; index < 3; index++) { // 3, The offset of queue buffer.
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue038(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue038", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_040.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_040.c
new file mode 100644
index 0000000000000000000000000000000000000000..f164a9394d1e8ab7ab6c869d077b7b0febae52db
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_040.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testCount++;
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "TskName40";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 23; // 23, Set the priority according to the task purpose,a smaller number means a higher priority.
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue040(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue040", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_041.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_041.c
new file mode 100644
index 0000000000000000000000000000000000000000..d851eeceaf8f74794f964d6b40808f1f293ca8f6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_041.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testCount++;
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "TskName";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 23; // 23, Set the priority according to the task purpose,a smaller number means a higher priority.
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ return LOS_OK;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue041(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue041", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_042.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_042.c
new file mode 100644
index 0000000000000000000000000000000000000000..5e9fb8774e600c0733a65d1e5b856a8fdf5a67cb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_042.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ TSK_INIT_PARAM_S task2 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.pcName = "TskName1";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 22; // 22, Set the priority according to the task purpose,a smaller number means a higher priority.
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+ LOS_AtomicInc(&g_testCount);
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task2.pcName = "TskName2";
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.usTaskPrio = 23; // 23, Set the priority according to the task purpose,a smaller number means a higher priority.
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue042(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue042", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_043.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_043.c
new file mode 100644
index 0000000000000000000000000000000000000000..f37001adaf9fe86c82d28ba3b041eace577d8016
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_043.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 100); // 8, Write the setting size of queue buffer. 100, timeout of queue write event.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ TSK_INIT_PARAM_S task2 = { 0 };
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "TskName1";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 22; // 22, Set the priority according to the task purpose,a smaller number means a higher priority.
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task2.pcName = "TskName2";
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.usTaskPrio = 21; // 21, Set the priority according to the task purpose,a smaller number means a higher priority.
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 100); // 8, Write the setting size of queue buffer. 100, timeout of queue write event.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID02);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue043(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue043", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_044.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_044.c
new file mode 100644
index 0000000000000000000000000000000000000000..334216651da8f4098acaa59afb7488577f186a0d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_044.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ g_testCount++;
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = TEST_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue044(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue044", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_045.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_045.c
new file mode 100644
index 0000000000000000000000000000000000000000..ccfa07d41d206e02cbdb9b061265a07d971613c8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_045.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ g_testCount++;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ g_testCount = 0;
+
+ ret = TEST_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue045(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue045", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_046.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_046.c
new file mode 100644
index 0000000000000000000000000000000000000000..004453ac37fc8e9ef34bb226a974ffe3931fa009
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_046.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID HwiF02(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ TEST_HwiClear(HWI_NUM_TEST3);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ g_testCount = 0;
+
+ ret = TEST_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = TEST_HwiCreate(HWI_NUM_TEST3, 1, 0, HwiF02, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+ LOS_AtomicInc(&g_testCount);
+
+ TestHwiTrigger(HWI_NUM_TEST3);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+
+ TEST_HwiDelete(HWI_NUM_TEST3);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_QueueDelete(g_testQueueID01);
+
+ return LOS_OK;
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue046(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue046", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_047.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_047.c
new file mode 100644
index 0000000000000000000000000000000000000000..8a56f3cbfae0defef0491e03b135b28f06275230
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_047.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "TskName";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 23; // 23, Set the priority according to the task purpose,a smaller number means a higher priority.
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+ LOS_AtomicInc(&g_testCount);
+
+ ret = TEST_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItLosQueue047(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue047", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_048.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_048.c
new file mode 100644
index 0000000000000000000000000000000000000000..e2caf4849d4cd2f3ffff5256cc0f3a114dff2693
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_048.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+EXIT:
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "TskName";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 23; // 23, Set the priority according to the task purpose,a smaller number means a higher priority.
+
+ g_testCount = 0;
+
+ ret = TEST_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue048(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue048", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_049.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_049.c
new file mode 100644
index 0000000000000000000000000000000000000000..3ef217156a4e462c5bd4bba74323378025e30ee2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_049.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(VOID)
+{
+ UINT32 ret;
+ CHAR buffer2[] = "UniDSP";
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buffer2, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+ UINT16 swTmrID;
+ INT32 value;
+ UINT64 tickstart;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(20, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID, 0xffff); // 20, Timing duration of the software timer to be created.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueCreate("Q1", 10, &g_testQueueID01, 0, 8); // 10, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_SwtmrStart(swTmrID);
+ HAL_READ_UINT32(&g_testCount, value);
+ tickstart = LOS_TickCountGet();
+ while (value < 10) { // 10, Here, assert that g_testCount is equal to 10.
+ HAL_READ_UINT32(&g_testCount, value);
+ if (LOS_TickCountGet() - tickstart > 1000) { // 1000, Test execution time tick count upper limit.
+ ICUNIT_GOTO_EQUAL(1, 0, g_testCount, EXIT);
+ break;
+ }
+ }
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buffer1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISFULL, ret, EXIT);
+
+ LOS_SwtmrDelete(swTmrID);
+ LOS_QueueDelete(g_testQueueID01);
+
+ return LOS_OK;
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue049(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue049", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_050.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_050.c
new file mode 100644
index 0000000000000000000000000000000000000000..c7e633746cd19d7e2611c5d95be781d4f12abb91
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_050.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ g_testCount++;
+
+ ret = LOS_QueueRead(g_testQueueID01, buff2, 8, 0xff); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READ_IN_INTERRUPT, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff2, 8, 0xff); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT, ret, EXIT);
+ g_testCount++;
+EXIT:
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = TEST_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+VOID ItLosQueue050(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue050", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_051.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_051.c
new file mode 100644
index 0000000000000000000000000000000000000000..0851cb7c841d04d5a8f96a992b892aada737aef4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_051.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, sizeof(UINTPTR));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskLock();
+
+ ret = LOS_QueueRead(g_testQueueID01, buff1, 8, 0xff); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_PEND_IN_LOCK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0xff); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0xff); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_PEND_IN_LOCK, ret, EXIT);
+ LOS_TaskUnlock();
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue051(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue051", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_052.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_052.c
new file mode 100644
index 0000000000000000000000000000000000000000..781e9e6a1bcead98daea9bea7129380179b629b7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_052.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, sizeof(UINTPTR));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, buff1, 8, 0xf); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_TIMEOUT, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0xf); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0xf); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_TIMEOUT, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue052(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue052", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_053.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_053.c
new file mode 100644
index 0000000000000000000000000000000000000000..a87ae0d71e90770ad068df83422e18760eff13d6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_053.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testCount++;
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0xf); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ g_testCount++;
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff2, 8, 0xf); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff2, 8, 0xf); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "TskName53";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 23; // 23, Set the priority according to the task purpose,a smaller number means a higher priority.
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, sizeof(UINTPTR));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(LOSCFG_BASE_IPC_QUEUE_CONFIG + 1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_FOUND, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret, EXIT1);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0xf); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT1); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret, EXIT1);
+
+ ret = LOS_QueueRead(g_testQueueID01, buff1, 8, 0xf); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, Here, assert that g_testCount is equal to 3.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT1);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue053(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue053", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_054.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_054.c
new file mode 100644
index 0000000000000000000000000000000000000000..85f05fdb057a41b014538686c60a187559b1bdbf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_054.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testQueueID01 = 0;
+
+ ret = LOS_QueueCreate(0, 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue054(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue054", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_055.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_055.c
new file mode 100644
index 0000000000000000000000000000000000000000..5a3147ebd5881caba7be082cae7cbc5b60b61865
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_055.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testQueueID01 = 0;
+
+ ret = LOS_QueueCreate("a", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue055(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue055", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_056.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_056.c
new file mode 100644
index 0000000000000000000000000000000000000000..8960eda56eaa00741e47995516f51b56410e6098
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_056.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testQueueID01 = 0;
+
+ ret = LOS_QueueCreate("", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue056(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue056", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_057.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_057.c
new file mode 100644
index 0000000000000000000000000000000000000000..07bf9e49c3390e01eb120572da68cdb8f2d4f3e1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_057.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ char bufname[5002] = {0};
+
+ g_testQueueID01 = 0;
+
+ memset(bufname, 'a', 5001); // 5001, buffer size.
+ bufname[5001] = '\0'; // 5001, buffer size.
+ ret = LOS_QueueCreate(bufname, 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue057(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue057", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_058.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_058.c
new file mode 100644
index 0000000000000000000000000000000000000000..d57d2b427842a8546eea269fc07c7666a392a667
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_058.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ UINT32 maxMsgSize;
+
+ g_testQueueID01 = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+ maxMsgSize = 0xFFFF + 1;
+
+ ret = LOS_QueueCreate("Q1", 30, &g_testQueueID01, 0, maxMsgSize); // 30, Set the queue length.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue058(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue058", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_059.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_059.c
new file mode 100644
index 0000000000000000000000000000000000000000..58c54de0a5526d47186481bb1316d17869afb767
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_059.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testQueueID01 = 0;
+
+ ret = LOS_QueueCreate("Q1", 30, &g_testQueueID01, 0, sizeof(UINTPTR)); // 30, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue059(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue059", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_061.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_061.c
new file mode 100644
index 0000000000000000000000000000000000000000..584cfb2e9c2fcb2d699e744fa985d785a327e55b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_061.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+ CHAR buffer2[] = "UniDSP";
+
+ UINT16 swTmrID1, swTmrID2;
+ INT32 value;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 10, &g_testQueueID01, 0, sizeof(UINTPTR)); // 10, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buffer1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buffer2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue061(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue061", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_062.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_062.c
new file mode 100644
index 0000000000000000000000000000000000000000..7b8ae4eb056ae8eb130cf910cec19d515ddac6cd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_062.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+ CHAR buffer2[] = "UniDSP";
+
+ UINT16 swTmrID1, swTmrID2;
+ INT32 value;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 10, &g_testQueueID01, 0, 0); // 10, Set the queue length
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buffer1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buffer2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue062(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue062", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_064.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_064.c
new file mode 100644
index 0000000000000000000000000000000000000000..87e79c14aaffdaccef5b097bc0024aebaee547db
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_064.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, len1;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ g_testQueueID01 = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+ len1 = 0xFFFF + 1;
+
+ ret = LOS_QueueCreate("Q1", len1, &g_testQueueID01, 0, 30); // 30, Set the node size of the queue.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue064(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue064", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_065.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_065.c
new file mode 100644
index 0000000000000000000000000000000000000000..8563256c1066db609cce8a2de46d3e334bb08481
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_065.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[] = "UniDSPOS";
+ UINTPTR buff2 = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 0xffffffff, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READSIZE_IS_INVALID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(buff2, 0, buff2, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + 7), buff1[7], *((char *)buff2 + 7), EXIT); // 7, The offset of queue buffer.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue065(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue065", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_066.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_066.c
new file mode 100644
index 0000000000000000000000000000000000000000..680d4b637847b08939638e54084d7efcdd509397
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_066.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[] = "UniDSPOS";
+ UINTPTR buff2 = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, (0xffffffff - 1), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READSIZE_IS_INVALID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(buff2, 0, buff2, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + 7), buff1[7], *((char *)buff2 + 7), EXIT); // 7, The offset of queue buffer.
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue066(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue066", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_067.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_067.c
new file mode 100644
index 0000000000000000000000000000000000000000..911b1627fd6ebd7f5a3e08842baac0f92454d338
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_067.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[] = "UniDSPOS";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, (0xffffffff + 1), 0);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue067(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue067", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_068.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_068.c
new file mode 100644
index 0000000000000000000000000000000000000000..ca2d0b0ea0249eb3fee08a070544e852f256aa2e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_068.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[7];
+
+ g_testQueueID01 = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+
+ ret = LOS_QueueCreate("Q1", 30, &g_testQueueID01, 0, sizeof(UINTPTR)); // 30, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue068(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue068", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_069.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_069.c
new file mode 100644
index 0000000000000000000000000000000000000000..9fad9f7d9afd7ca79e6a41a2c916305e163ba916
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_069.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[10];
+
+ g_testQueueID01 = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+
+ ret = LOS_QueueCreate("Q1", 30, &g_testQueueID01, 0, sizeof(UINTPTR)); // 30, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue069(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue069", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_070.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_070.c
new file mode 100644
index 0000000000000000000000000000000000000000..0ecda00328b175549463dcfb72167238e3198c9f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_070.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[10];
+
+ g_testQueueID01 = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+
+ ret = LOS_QueueCreate("Q1", 30, &g_testQueueID01, 0, 8); // 30, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead((LOSCFG_BASE_IPC_QUEUE_CONFIG + 1), &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue070(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue070", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_071.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_071.c
new file mode 100644
index 0000000000000000000000000000000000000000..ec1411b1ce82c87beeb3103a5c8df3f8fe5978bf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_071.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[10];
+
+ g_testQueueID01 = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+
+ ret = LOS_QueueCreate("Q1", 30, &g_testQueueID01, 0, sizeof(UINTPTR)); // 30, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue071(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue071", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_072.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_072.c
new file mode 100644
index 0000000000000000000000000000000000000000..c1f585bbb6c602f08acf8318f17b076707675848
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_072.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[10];
+
+ g_testQueueID01 = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+
+ ret = LOS_QueueCreate("Q1", 30, &g_testQueueID01, 0, sizeof(UINTPTR)); // 30, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue072(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue072", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_073.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_073.c
new file mode 100644
index 0000000000000000000000000000000000000000..d10500e91fd8edca7848d59d627c21a934121948
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_073.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buffer1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+
+static VOID SwtmrF02(VOID)
+{
+ UINT32 ret;
+ CHAR buffer2[] = "UniDSP";
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buffer2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+ CHAR buffer2[] = "UniDSP";
+
+ UINT16 swTmrID1, swTmrID2;
+ INT32 value;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID1, 0xffff); // 4, Timing duration of the software timer to be created.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = LOS_SwtmrCreate(8, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF02, &swTmrID2, 0xffff); // 8, Timing duration of the software timer to be created.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, sizeof(UINTPTR));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ LOS_SwtmrStart(swTmrID1);
+ LOS_SwtmrStart(swTmrID2);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buffer2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT1);
+
+ LOS_SwtmrDelete(swTmrID1);
+ LOS_SwtmrDelete(swTmrID2);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+
+EXIT1:
+ LOS_SwtmrDelete(swTmrID1);
+ LOS_SwtmrDelete(swTmrID2);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+EXIT2:
+ LOS_SwtmrDelete(swTmrID1);
+ return LOS_OK;
+EXIT3:
+ LOS_SwtmrDelete(swTmrID2);
+ return LOS_OK;
+}
+
+VOID ItLosQueue073(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue073", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_074.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_074.c
new file mode 100644
index 0000000000000000000000000000000000000000..8c19001d8f79123877442d056bb70a8e2115a178
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_074.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[10];
+
+ g_testQueueID01 = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+
+ ret = LOS_QueueCreate("Q1", 30, &g_testQueueID01, 0, sizeof(UINTPTR)); // 30, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, (LOS_WAIT_FOREVER - 1)); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue074(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue074", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_075.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_075.c
new file mode 100644
index 0000000000000000000000000000000000000000..bfc9a12b52265d1f404482b3925175ce04cf412c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_075.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 2); // 3, Set the queue length; 2, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 0xFFFFFFFF, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue075(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue075", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_076.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_076.c
new file mode 100644
index 0000000000000000000000000000000000000000..aa543f037e33b2eee34635167199e86d5b3b8d3d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_076.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, (0xFFFFFFFF + 1), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue076(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue076", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_077.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_077.c
new file mode 100644
index 0000000000000000000000000000000000000000..e2c58a6bd7c36130c12c7da4518befa9be3bef1c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_077.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, (0xFFFFFFFF - 1), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue077(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue077", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_078.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_078.c
new file mode 100644
index 0000000000000000000000000000000000000000..6acb8b255f3e861963398e5549b993fc6f1446f4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_078.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(LOSCFG_BASE_IPC_QUEUE_CONFIG, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue078(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue078", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_079.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_079.c
new file mode 100644
index 0000000000000000000000000000000000000000..dee8408a7e5d47c3bd0f55acd5074e2f25cd3aba
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_079.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite((LOSCFG_BASE_IPC_QUEUE_CONFIG + 1), buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue079(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue079", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_080.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_080.c
new file mode 100644
index 0000000000000000000000000000000000000000..07ad8e23db6476cc3712ee64f8357049ddfa737d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_080.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue080(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue080", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_081.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_081.c
new file mode 100644
index 0000000000000000000000000000000000000000..ad079a68601e489b62f8100cb6ea6fdf69ffffe1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_081.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(0xFFFFFFFF);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue081(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue081", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_082.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_082.c
new file mode 100644
index 0000000000000000000000000000000000000000..5d8754d731d1dc84a8cdbe782b63d777d37636d5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_082.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(LOSCFG_BASE_IPC_QUEUE_CONFIG);
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue082(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue082", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_083.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_083.c
new file mode 100644
index 0000000000000000000000000000000000000000..3409870cd4cb728b3a5b10787f0f9e071b85e46b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_083.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete((LOSCFG_BASE_IPC_QUEUE_CONFIG + 1));
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue083(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue083", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_084.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_084.c
new file mode 100644
index 0000000000000000000000000000000000000000..2603e7ca5ad8ae339a7e1487e835bfe4ab9bff6f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_084.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue084(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue084", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_085.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_085.c
new file mode 100644
index 0000000000000000000000000000000000000000..59226ffcbb337779c9d2fade3ac43293d0e2cd83
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_085.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(100); // 100, Queue ID.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue085(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue085", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_086.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_086.c
new file mode 100644
index 0000000000000000000000000000000000000000..53081a6103bdafc9dc79f02fe23269df262d1300
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_086.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(100); // 100, Queue ID.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue086(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue086", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_087.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_087.c
new file mode 100644
index 0000000000000000000000000000000000000000..ff7d2ef4ab45e3fba891e3959be123519a7f9d3e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_087.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, i;
+ UINT32 index;
+ const UINT32 count = 256;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR readbuf[260] = "";
+ QUEUE_INFO_S queueInfo;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, count); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ for (i = 0; i < 100; i++) { // 100, The loop frequency.
+ ret = LOS_QueueWrite(g_testQueueID01, filebuf, count, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(readbuf, 0, 260); // 260, Read buf size.
+ ret = LOS_QueueRead(g_testQueueID01, readbuf, count, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+ }
+ ret = LOS_QueueRead(g_testQueueID01, readbuf, count, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue087(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue087", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_088.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_088.c
new file mode 100644
index 0000000000000000000000000000000000000000..54a2114c75269a8ba07604e90dd48022e92093fd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_088.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, i;
+ UINT32 index;
+ const UINT32 len = 1000; // 1000, Queue buffer length.
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+
+ // 1000, Set the queue length.
+ ret = LOS_QueueCreate("Q1", 1000, &g_testQueueID01, 0, QUEUE_SHORT_BUFFER_LENTH);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, len, queueInfo.usQueueLen, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ for (i = 0; i < 1000; i++) { // 1000, Set the queue length.
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISFULL, ret, EXIT);
+
+ for (i = 0; i < 1000; i++) { // 1000, Set the queue length.
+ ret = LOS_QueueRead(g_testQueueID01, buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+ ret = LOS_QueueRead(g_testQueueID01, buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, len, queueInfo.usQueueLen, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue088(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue088", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_089.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_089.c
new file mode 100644
index 0000000000000000000000000000000000000000..897ba9824a2bfc162c09d047cca4e14847262346
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_089.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, i, j;
+ UINT32 index;
+ const UINT32 len = 1000;
+ const UINT32 count = sizeof(UINTPTR);
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR readbuf[260] = "";
+ QUEUE_INFO_S queueInfo;
+
+ ret = LOS_QueueCreate("Q1", 1000, &g_testQueueID01, 0, count); // 1000, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, len, queueInfo.usQueueLen, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ for (j = 0; j < 100; j++) { // 100, The loop frequency.
+ for (i = 0; i < 1000; i++) { // 1000, The loop frequency.
+ ret = LOS_QueueWrite(g_testQueueID01, filebuf, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+ ret = LOS_QueueWrite(g_testQueueID01, filebuf, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISFULL, ret, EXIT);
+
+ for (i = 0; i < 1000; i++) { // 1000, The loop frequency.
+ memset(readbuf, 0, 260); // 260, Read buf size.
+ ret = LOS_QueueRead(g_testQueueID01, readbuf, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+ ret = LOS_QueueRead(g_testQueueID01, readbuf, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+ }
+ ret = LOS_QueueWrite(g_testQueueID01, filebuf, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, readbuf, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, len, queueInfo.usQueueLen, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, readbuf, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue089(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue089", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_091.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_091.c
new file mode 100644
index 0000000000000000000000000000000000000000..42f552a0e9a2c45499c6b2b87c4cb5bf73c11017
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_091.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(VOID)
+{
+ UINT32 ret;
+ CHAR buffer2[] = "UniDSP";
+
+ ret = LOS_QueueRead(g_testQueueID01, &buffer2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+ CHAR buffer2[] = "UniDSP";
+
+ UINT16 swTmrID;
+ INT32 value;
+
+ g_testCount = 0;
+
+ ret = LOS_SwtmrCreate(20, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID, 0xffff); // 20, Timing duration of the software timer to be created.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_QueueCreate("Q1", 10, &g_testQueueID01, 0, 8); // 10, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buffer1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ LOS_SwtmrStart(swTmrID);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ LOS_SwtmrDelete(swTmrID);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+
+EXIT1:
+ LOS_SwtmrDelete(swTmrID);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue091(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue091", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_092.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_092.c
new file mode 100644
index 0000000000000000000000000000000000000000..c6f6aa59e6654d12ab70e47667fc5d210e1e5457
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_092.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_QueueCreate("Q1", 2, &g_testQueueID01, 0, sizeof(UINTPTR)); // 2, Set the queue length.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+ CHAR buffer2[] = "UniDSP";
+
+ UINT16 swTmrID;
+ INT32 value;
+
+ g_testCount = 0;
+
+ // 4, Timing duration of the software timer to be created.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ LOS_SwtmrStart(swTmrID);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buffer1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buffer2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ LOS_SwtmrDelete(swTmrID);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT1:
+ LOS_SwtmrDelete(swTmrID);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue092(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue092", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_093.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_093.c
new file mode 100644
index 0000000000000000000000000000000000000000..817d32b60f3413e19aa7c2d771d4ab0c31da0862
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_093.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+
+ ret = LOS_QueueCreate("Q1", 2, &g_testQueueID01, 0, sizeof(UINTPTR)); // 2, Set the queue length.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buffer1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buffer2[] = "UniDSP";
+
+ UINT16 swTmrID;
+ INT32 value;
+
+ g_testCount = 0;
+
+ // 4, Timing duration of the software timer to be created.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ LOS_SwtmrStart(swTmrID);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buffer2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ LOS_SwtmrDelete(swTmrID);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT1:
+ LOS_SwtmrDelete(swTmrID);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue093(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue093", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_094.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_094.c
new file mode 100644
index 0000000000000000000000000000000000000000..c0277ad2345389477db3fd2829fe0f9aa684f2ce
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_094.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID SwtmrF01(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+ CHAR buffer2[] = "UniDSP";
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buffer1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buffer2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+ CHAR buffer2[] = "UniDSP";
+
+ UINT16 swTmrID;
+ INT32 value;
+
+ g_testCount = 0;
+
+ // 4, Timing duration of the software timer to be created.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueCreate("Q1", 10, &g_testQueueID01, 0, sizeof(UINTPTR)); // 10, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_SwtmrStart(swTmrID);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buffer2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT1);
+
+ LOS_SwtmrDelete(swTmrID);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+
+EXIT1:
+ LOS_SwtmrDelete(swTmrID);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue094(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue094", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_095.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_095.c
new file mode 100644
index 0000000000000000000000000000000000000000..57bea3afc71d7b3aabb5e5c788b11e8d163ac8cf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_095.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+ CHAR buffer2[] = "UniDSP";
+
+ ret = LOS_QueueCreate("Q1", 10, &g_testQueueID01, 0, sizeof(UINTPTR)); // 10, Set the queue length.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buffer1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buffer2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buffer1[] = "MiniOS";
+ CHAR buffer2[] = "UniDSP";
+ UINT16 swTmrID;
+
+ g_testCount = 0;
+
+ // 4, Timing duration of the software timer to be created.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_SwtmrStart(swTmrID);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buffer2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT1);
+
+ LOS_SwtmrDelete(swTmrID);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+EXIT1:
+ LOS_SwtmrDelete(swTmrID);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue095(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue095", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_096.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_096.c
new file mode 100644
index 0000000000000000000000000000000000000000..35ca66086e0d1845fa01a06e733bbee2fa04484b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_096.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+
+ queueID = LOSCFG_BASE_IPC_QUEUE_CONFIG + 1;
+ ret = LOS_QueueInfoGet(queueID, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ queueID = LOSCFG_BASE_IPC_QUEUE_CONFIG;
+ ret = LOS_QueueInfoGet(queueID, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ queueID = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+ ret = LOS_QueueInfoGet(queueID, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue096(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue096", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_098.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_098.c
new file mode 100644
index 0000000000000000000000000000000000000000..498862f56120ac4428cd0241a33440e478c10d49
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_098.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+ UINT32 readSize;
+
+ queueID = LOSCFG_BASE_IPC_QUEUE_CONFIG + 1;
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = 8; // 8, Read the setting size of queue buffer.
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(readSize, 8, readSize, EXIT); // 8, Here, assert that g_testCount is equal to 8.
+
+ queueID = LOSCFG_BASE_IPC_QUEUE_CONFIG;
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+
+ readSize = 8; // 8, Read the setting size of queue buffer.
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(readSize, 8, readSize, EXIT); // 8, Here, assert that g_testCount is equal to 8.
+
+ queueID = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = 8; // 8, Read the setting size of queue buffer.
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(readSize, 8, readSize, EXIT); // 8, Here, assert that g_testCount is equal to 8.
+
+ queueID = 0;
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = 8; // 8, Read the setting size of queue buffer.
+ ret = LOS_QueueReadCopy(queueID - 1, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(readSize, 8, readSize, EXIT); // 8, Here, assert that g_testCount is equal to 8.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue098(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue098", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_099.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_099.c
new file mode 100644
index 0000000000000000000000000000000000000000..863057745393b0725fa0f8057c118bb1f0b0c58a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_099.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+ UINT32 readSize;
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(queueID, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = 8; // 8, Read the setting size of queue buffer.
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(queueID, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue099(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue099", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_101.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_101.c
new file mode 100644
index 0000000000000000000000000000000000000000..3afe2091a24db05990eac08df04dd69748736998
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_101.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+ UINT32 readSize;
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(queueID, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = sizeof(buff1);
+ ret = LOS_QueueReadCopy(queueID, NULL, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READ_PTR_NULL, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = sizeof(buff1);
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue101(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue101", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_102.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_102.c
new file mode 100644
index 0000000000000000000000000000000000000000..fe26e478eccca5504ee4ff2e70146b83c98a62f1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_102.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+ UINT32 readSize;
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(queueID, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = sizeof(buff1);
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0xffffffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(queueID, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = sizeof(buff1);
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0xffffffff + 1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(queueID, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = sizeof(buff1);
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0xffffffff - 1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue102(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue102", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_103.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_103.c
new file mode 100644
index 0000000000000000000000000000000000000000..60b08af8ae9b1508d519e82e5218f0db60b87c35
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_103.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+
+ queueID = LOSCFG_BASE_IPC_QUEUE_CONFIG;
+ ret = LOS_QueueWriteCopy(queueID, &buff1, 8, 0); // 8, Incoming buffer size.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ queueID = LOSCFG_BASE_IPC_QUEUE_CONFIG + 1;
+ ret = LOS_QueueWriteCopy(queueID, &buff1, 8, 0); // 8, Incoming buffer size.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ queueID = LOSCFG_BASE_IPC_QUEUE_CONFIG - 1;
+ ret = LOS_QueueWriteCopy(queueID, &buff1, 8, 0); // 8, Incoming buffer size.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ queueID = 0;
+ ret = LOS_QueueWriteCopy(queueID - 1, &buff1, 8, 0); // 8, Incoming buffer size.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue103(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue103", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_104.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_104.c
new file mode 100644
index 0000000000000000000000000000000000000000..571a05d55a233f13895c27155ec140f4988abcad
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_104.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteCopy(queueID, &buff1, 8, 0); // 8, Incoming buffer size.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(queueID, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, queueID, queueInfo.uwQueueID, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteCopy(queueID, &buff1, 8, 0); // 8, Incoming buffer size.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue104(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue104", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_106.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_106.c
new file mode 100644
index 0000000000000000000000000000000000000000..624414b31e1de3dc64e6c0e7ce7cb5593e62fad5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_106.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "ABC";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID, 0, QUEUE_SHORT_BUFFER_LENTH); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteCopy(queueID, NULL, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_WRITE_PTR_NULL, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ ret = LOS_QueueRead(queueID, &buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueWriteCopy(queueID, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ ret = LOS_QueueRead(queueID, &buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue106(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue106", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_107.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_107.c
new file mode 100644
index 0000000000000000000000000000000000000000..de9dadec8d908d5fca21f6b86f1408f16fad30ce
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_107.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "123";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID, 0, QUEUE_SHORT_BUFFER_LENTH); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteCopy(queueID, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0xffffffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ ret = LOS_QueueRead(queueID, &buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteCopy(queueID, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0xffffffff + 1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ ret = LOS_QueueRead(queueID, &buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteCopy(queueID, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0xffffffff - 1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ ret = LOS_QueueRead(queueID, &buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue107(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue107", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_108.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_108.c
new file mode 100644
index 0000000000000000000000000000000000000000..311b313770e878ea7f94bb3842c9efe8fb1e4f28
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_108.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ QUEUE_INFO_S queueInfo;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ g_testCount++;
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ g_testCount++;
+
+ return;
+EXIT:
+ g_testCount = 0;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, QUEUE_SHORT_BUFFER_LENTH); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = TEST_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ g_testCount++;
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue108(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue108", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_109.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_109.c
new file mode 100644
index 0000000000000000000000000000000000000000..4f3f4336a6efd76c168f32eaf9d5d0896e0b5163
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_109.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ QUEUE_INFO_S queueInfo;
+
+ g_testCount++;
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+EXIT:
+ g_testCount = 0;
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "queue_109";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 23; // 23, Set task priority.
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, QUEUE_SHORT_BUFFER_LENTH); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ g_testCount++;
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue109(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue109", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_110.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_110.c
new file mode 100644
index 0000000000000000000000000000000000000000..72f0804a1a1c5e828937f05b931577d455252131
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_110.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(VOID)
+{
+ UINT32 ret;
+ QUEUE_INFO_S queueInfo;
+
+ g_testCount++;
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ g_testCount++;
+
+ return;
+EXIT:
+ g_testCount = 0;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, QUEUE_SHORT_BUFFER_LENTH); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID, 0xffff); // 4, Timing duration of the software timer to be created.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ LOS_SwtmrDelete(swTmrID);
+
+ g_testCount++;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue110(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue110", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_111.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_111.c
new file mode 100644
index 0000000000000000000000000000000000000000..21e8da67b094c284bb3853b4c2014a52aca355e0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_111.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ UINT32 readSize;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ g_testCount++;
+
+ ret = LOS_QueueWriteCopy(g_testQueueID01, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ readSize = QUEUE_SHORT_BUFFER_LENTH;
+ ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ return;
+EXIT:
+ g_testCount = 0;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+ UINT32 readSize;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, QUEUE_SHORT_BUFFER_LENTH); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = TEST_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ g_testCount++;
+
+ readSize = QUEUE_SHORT_BUFFER_LENTH;
+ ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+
+EXIT:
+ TEST_HwiDelete(HWI_NUM_TEST);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue111(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue111", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_112.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_112.c
new file mode 100644
index 0000000000000000000000000000000000000000..c3e087ebd178da1faacab0101e5fe0a3c29c2202
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_112.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ UINT32 readSize;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ g_testCount++;
+
+ ret = LOS_QueueWriteCopy(g_testQueueID01, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ readSize = QUEUE_SHORT_BUFFER_LENTH;
+ ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+
+ return;
+EXIT:
+ g_testCount = 0;
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ UINT32 readSize;
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.pcName = "queue_109";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 23; // 23, Set task priority.
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, QUEUE_SHORT_BUFFER_LENTH); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ g_testCount++;
+
+ readSize = QUEUE_SHORT_BUFFER_LENTH;
+ ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ return LOS_OK;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue112(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue112", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_113.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_113.c
new file mode 100644
index 0000000000000000000000000000000000000000..0ae00141bb92cf8ef8ac424aee1e623f95495f5b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_113.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID SwtmrF01(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ UINT32 readSize;
+
+ g_testCount++;
+
+ ret = LOS_QueueWriteCopy(g_testQueueID01, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ readSize = QUEUE_SHORT_BUFFER_LENTH;
+ ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+ return;
+EXIT:
+ g_testCount = 0;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT16 swTmrID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+ UINT32 readSize;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, QUEUE_SHORT_BUFFER_LENTH); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ // 4, Timing duration of the software timer to be created.
+ ret = LOS_SwtmrCreate(4, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &swTmrID, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SwtmrStart(swTmrID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ readSize = QUEUE_SHORT_BUFFER_LENTH;
+ ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, g_testQueueID01, queueInfo.uwQueueID, EXIT);
+
+ LOS_SwtmrDelete(swTmrID);
+
+ g_testCount++;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_SwtmrDelete(swTmrID);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+/*
+**********
+testcase brief in English
+**********
+*/
+
+VOID ItLosQueue113(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue113", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_114.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_114.c
new file mode 100644
index 0000000000000000000000000000000000000000..4a3b50f337b27a6aceff95e4ee470d9f7c41452d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_114.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 i;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID, 0, QUEUE_SHORT_BUFFER_LENTH); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ for (i = 0; i < 3; i++) { // 3, The loop frequency.
+ ret = LOS_QueueWriteCopy(queueID, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_QueueWrite(queueID, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISFULL, ret, EXIT);
+
+ ret = LOS_QueueWriteCopy(queueID, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISFULL, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(queueID, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, queueID, queueInfo.uwQueueID, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue114(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue114", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_116.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_116.c
new file mode 100644
index 0000000000000000000000000000000000000000..27446afa1194170c37890dcf45f5bd6bc9434e07
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_116.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+ UINT32 readSize;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteCopy(g_testQueueID01, &buff1, 8, 0); // 8, Incoming buffer size.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ readSize = 8; // 8, Read the setting size of queue buffer.
+ ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(g_testQueueID01, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ readSize = 8; // 8, Read the setting size of queue buffer.
+ ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ LOS_TaskLock();
+ readSize = 8; // 8, Read the setting size of queue buffer.
+ ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &readSize, 1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_PEND_IN_LOCK, ret, EXIT);
+ LOS_TaskUnlock();
+
+ readSize = 8; // 8, Read the setting size of queue buffer.
+ ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &readSize, 2); // 2, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_TIMEOUT, ret, EXIT);
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueue116(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue116", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_003.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..598f570dde812a009daf4ec13d94781ef7209c3e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_003.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "A";
+ CHAR buff2[8] = "B";
+ CHAR buff3[8] = "C";
+ CHAR buff4[8] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff2, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff3, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff4, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead003(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead003", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_004.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..96f772cbca74f35c6c672f158e158135100c1e5b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_004.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "A";
+ CHAR buff2[8] = "B";
+ CHAR buff3[8] = "C";
+ CHAR buff4[8] = "D";
+ CHAR buff5[8] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff2, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff3, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff4, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISFULL, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff5, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead004(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead004", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_005.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..ad7f6fdb10a49d3157e61e81b7341e8b7c59c6f2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_005.c
@@ -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.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ g_testQueueID01 = 1025; // 1025, ID of successfully created queue control structure.
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 0); // 3, Set the queue length.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_PARA_ISZERO, ret);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead005(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead005", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_006.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..5dd55becd66915dacbaefa6662628903beebe44d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_006.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 1); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead006(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead006", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_007.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..2ff2037d59aa97550c600685ddb79219d5891803
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_007.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ g_testQueueID01 = 0x5;
+
+ ret = LOS_QueueCreate("Q1", 30, &g_testQueueID01, 0, 0xFFFF); // 30, Set the queue length.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_SIZE_TOO_BIG, ret);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead007(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead007", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_008.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..5c37423850c575d7e462e49a443808bcbce3d648
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_008.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, sizeof(UINTPTR));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead008(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead008", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_009.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..86201cb1862201430db46241b682b67987f5780d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_009.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ g_testQueueID01 = 1025; // 1025, ID of successfully created queue control structure.
+
+ ret = LOS_QueueCreate("Q1", 0xFFF0, &g_testQueueID01, 0, 0xFFFF);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_SIZE_TOO_BIG, ret);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_FOUND, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead009(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead009", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_010.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..680a34b4fe4f62824c7039936a6d5b3fb00bb40c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_010.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[12] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, sizeof(UINTPTR) + 2, 0); // 2, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead010(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead010", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_011.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..cc40bcf3ac8b6c6bbf8542e7bd620702a87db4cf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_011.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[] = "UniDSPOS";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, (sizeof(UINTPTR) * 2 - 1), 0); // 2, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + 6), buff1[6], *((char *)buff2 + 6), EXIT); // 6, The offset of queue buffer.
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + 7), 'S', *((char *)buff2 + 7), EXIT); // 7, The offset of queue buffer.
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead011(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead011", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_012.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..57ccd96e2ccb4df1da14643a91763bd0a91b29f3
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_012.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[] = "UniDSPOS";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 9, 0); // 9, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + 7), buff1[7], *((char *)buff2 + 7), EXIT); // 7, The offset of queue buffer.
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + 8), '\0', *((char *)buff2 + 8), EXIT); // 8, The offset of queue buffer.
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead012(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead012", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_013.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..168fe46dd01c2622d20a1fb57c2c1b606493e2ea
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_013.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[9] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 9, 0); // 9, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 9, 0); // 9, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead013(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead013", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_014.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_014.c
new file mode 100644
index 0000000000000000000000000000000000000000..c7fbfa32ab1b29721a6d755fb2ca178934305645
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_014.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[16] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, sizeof(UINTPTR) * 2 - 1, 0); // 2, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead014(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead014", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_015.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..3fb0e44139f6d3f9fa21aceb43bda9acbbb8e69e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_015.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ UINT32 queueID[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ UINT32 exsitedQueue = QUEUE_EXISTED_NUM;
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueCreate(NULL, 3, &queueID[index], 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_QueueWriteHead(queueID[index - 1], &buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(queueID[index - 1], &buff2, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID[index], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID[index], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
+EXIT:
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueDelete(queueID[index]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead015(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead015", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_016.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_016.c
new file mode 100644
index 0000000000000000000000000000000000000000..467abed1e954dddcd79851159e21541dfd9c965d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_016.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ UINT32 queueID[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ UINT32 exsitedQueue = QUEUE_EXISTED_NUM;
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueCreate(NULL, 3, &queueID[index], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID[LOSCFG_BASE_IPC_QUEUE_CONFIG], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_CB_UNAVAILABLE, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(LOSCFG_BASE_IPC_QUEUE_CONFIG + 1, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueRead(LOSCFG_BASE_IPC_QUEUE_CONFIG + 1, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+EXIT:
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueDelete(queueID[index]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead016(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead016", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_017.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_017.c
new file mode 100644
index 0000000000000000000000000000000000000000..c6592e850dfee08946c77f1428a4d7fd9b36d544
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_017.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead017(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead017", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_018.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..cc145edb8973c72cd4c2293f528c48bee43a8451
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_018.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead018(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead018", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_019.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..85f8f20d882cd84859b7f13e7d75082461dd7171
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_019.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[] = "UniDSP_TEST";
+ UINTPTR buff2;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ for (index = 0; index < 7; index++) { // 7, The loop frequency. Queue buffer size.
+ ICUNIT_GOTO_EQUAL(*((char *)buff2 + index), buff1[index], *((char *)buff2 + index), EXIT);
+ }
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead019(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead019", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_020.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..b57bb65c4c7891e7399e036f77e5d11627cd2520
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_020.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[8] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, NULL, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_WRITE_PTR_NULL, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead020(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead020", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_021.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..97ce20ef688ed10d08b03d0469c603e0e061bf0d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_021.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead((UINT32)-1, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead021(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead021", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_022.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..d20fba715bce2611e5be122039db5f4a418a28c6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_022.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ UINT32 queueID[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8];
+
+ UINT32 exsitedQueue = QUEUE_EXISTED_NUM;
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueCreate(NULL, 3, &queueID[index], 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_QueueWriteHead(queueID[index - 1], &buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(queueID[index - 1], &buff2, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueDelete(queueID[index]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead022(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead022", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_023.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..95b4adc533b63c751e3cad73b85067c2c823daff
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_023.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(LOSCFG_BASE_IPC_QUEUE_CONFIG, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_INVALID, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead023(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead023", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_024.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_024.c
new file mode 100644
index 0000000000000000000000000000000000000000..8e52071b054ac99f4ad246456a6f46bdb62a2ec5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_024.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "DOPRA";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueCreate("Q2", 3, &g_testQueueID02, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID02, &buff2, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueDelete(g_testQueueID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead024(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead024", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_025.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_025.c
new file mode 100644
index 0000000000000000000000000000000000000000..9004ae9d2bdd69de03887d4b8b488cdf8275b3a0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_025.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ UINT32 queueID[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
+ CHAR buff1[8] = "UniDSP";
+
+ UINT32 exsitedQueue = QUEUE_EXISTED_NUM;
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueCreate(NULL, 3, &queueID[index], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID[LOSCFG_BASE_IPC_QUEUE_CONFIG], 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_CB_UNAVAILABLE, ret, EXIT);
+
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueWriteHead(queueID[index], &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+EXIT:
+ for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_CONFIG - exsitedQueue; index++) {
+ ret = LOS_QueueDelete(queueID[index]);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead025(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead025", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_026.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..77f53031ad6c2d5366259f522c50b23bcd2434a5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_026.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ for (index = 0; index < 3; index++) { // 3, The loop frequency.
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead026(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead026", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_027.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..363168b56555f0a3ee8f4ad5b04bdbbfd524faae
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_027.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[8] = "UniDSP";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ for (index = 0; index < 3; index++) { // 3, The loop frequency.
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISFULL, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead027(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead027", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_028.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_028.c
new file mode 100644
index 0000000000000000000000000000000000000000..a21b8cc9c450f6bf11054c7426e58e67f58fb186
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_028.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "DOPRA";
+ CHAR buff3[8] = "TEST";
+ UINTPTR buff4;
+ UINTPTR buff5;
+ UINTPTR buff6;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff2, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff3, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff4, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff5, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff6, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ for (index = 0; index < 8; index++) { // 8, The loop frequency.
+ ICUNIT_GOTO_EQUAL(*((char *)buff4 + index), buff3[index], *((char *)buff4 + index), EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff5 + index), buff2[index], *((char *)buff5 + index), EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff6 + index), buff1[index], *((char *)buff6 + index), EXIT);
+ }
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead028(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead028", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_029.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..146cd59ebbe49df2d8adcfb8e38b07e4bb896514
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_029.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ for (index = 0; index < 3; index++) { // 3, The loop frequency.
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ for (index = 0; index < 3; index++) { // 3, The loop frequency.
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead029(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead029", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_030.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_030.c
new file mode 100644
index 0000000000000000000000000000000000000000..b89289ddf4fb65f7e738cdd2e3cb4d89f8c1f803
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_030.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID ItQueueHead030F01(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[8] = "";
+
+ g_testCount++;
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)ItQueueHead030F01;
+ task1.pcName = "TskName";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 23; // 23, Set task priority.
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2.
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead030(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead030", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_031.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_031.c
new file mode 100644
index 0000000000000000000000000000000000000000..f8ad944696936c36cac4e30b7a1cac352808cccf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_031.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID ItQueueHead031F02(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[8] = "";
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+static VOID ItQueueHead031F01(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ TSK_INIT_PARAM_S task2 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)ItQueueHead031F01;
+ task1.pcName = "TskName1";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 22; // 22, Set task priority.
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2.
+ LOS_AtomicInc(&g_testCount);
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)ItQueueHead031F02;
+ task2.pcName = "TskName2";
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.usTaskPrio = 23; // 23, Set task priority.
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead031(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead031", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_032.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_032.c
new file mode 100644
index 0000000000000000000000000000000000000000..99e13a6988128a9a15aa1972865600e6c7ec562d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_032.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID ItQueueHead032F02(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[8] = "";
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+}
+static VOID ItQueueHead032F01(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, sizeof(UINTPTR), 100); // 100, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+
+ TSK_INIT_PARAM_S task1 = { 0 };
+ TSK_INIT_PARAM_S task2 = { 0 };
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)ItQueueHead032F01;
+ task1.pcName = "TskName1";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 22; // 22, Set task priority.
+
+ task2.pfnTaskEntry = (TSK_ENTRY_FUNC)ItQueueHead032F02;
+ task2.pcName = "TskName2";
+ task2.uwStackSize = TASK_STACK_SIZE_TEST;
+ task2.usTaskPrio = 21; // 21, Set task priority.
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, sizeof(UINTPTR));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, sizeof(UINTPTR), 100); // 100, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ TestExtraTaskDelay(TEST_TASKDELAY_10TICK);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task2);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ TestExtraTaskDelay(TEST_TASKDELAY_10TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead032(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead032", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_038.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_038.c
new file mode 100644
index 0000000000000000000000000000000000000000..38692d9df4f72d6f9923cd6e636afe78b50067fc
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_038.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "abc";
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, sizeof(UINTPTR));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskLock();
+
+ ret = LOS_QueueRead(g_testQueueID01, buff1, sizeof(UINTPTR), 0xff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_PEND_IN_LOCK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff1, sizeof(UINTPTR), 0xff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff1, sizeof(UINTPTR), 0xff);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_PEND_IN_LOCK, ret, EXIT);
+ LOS_TaskUnlock();
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead038(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead038", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_039.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_039.c
new file mode 100644
index 0000000000000000000000000000000000000000..747f44ece173d52415e8ceb981e4b4852ccba955
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_039.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "UniDSP";
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, sizeof(UINTPTR));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, buff1, sizeof(UINTPTR), 0xf);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_TIMEOUT, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff1, sizeof(UINTPTR), 0xf);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff1, sizeof(UINTPTR), 0xf);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_TIMEOUT, ret, EXIT);
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead039(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead039", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_040.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_040.c
new file mode 100644
index 0000000000000000000000000000000000000000..615b765ddca9651ea710ac5831b194e4f5e129ab
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_040.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID ItQueueHead040F01(VOID)
+{
+ UINT32 ret;
+ CHAR buff2[8] = "";
+
+ g_testCount++;
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, sizeof(UINTPTR), 0xf);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ g_testCount++;
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff2, sizeof(UINTPTR), 0xf);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff2, sizeof(UINTPTR), 0xf);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "fgh";
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)ItQueueHead040F01;
+ task1.pcName = "TskName53";
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.usTaskPrio = 23; // 23, Set task priority.
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, sizeof(UINTPTR));
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(LOSCFG_BASE_IPC_QUEUE_CONFIG + 1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_FOUND, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, buff1, sizeof(UINTPTR), 0xf);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, buff1, sizeof(UINTPTR), 0xf);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead040(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead040", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_041.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_041.c
new file mode 100644
index 0000000000000000000000000000000000000000..511c7c6d962417bba4448a6bc2807567d080c86c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_041.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+ CHAR buff1[8] = "UniDSP";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, NULL, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_WRITE_PTR_NULL, ret, EXIT);
+
+ for (index = 0; index < 3; index++) { // 3, The loop frequency.
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead041(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead041", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_042.c b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_042.c
new file mode 100644
index 0000000000000000000000000000000000000000..246ef588609d082039009e46b765680e9f624dd0
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/full/It_los_queue_head_042.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 index;
+
+ CHAR buff1[8] = "UniDSP";
+ CHAR buff2[8] = "DOPRA";
+ CHAR buff3[8] = "TEST";
+ UINTPTR buff4;
+ UINTPTR buff5;
+ UINTPTR buff6;
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff1, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff2, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff3, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, NULL, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READ_PTR_NULL, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff4, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff5, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff6, sizeof(UINTPTR), 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ for (index = 0; index < 8; index++) { // 8, The loop frequency.
+ ICUNIT_GOTO_EQUAL(*((char *)buff4 + index), buff3[index], *((char *)buff4 + index), EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff5 + index), buff2[index], *((char *)buff5 + index), EXIT);
+ ICUNIT_GOTO_EQUAL(*((char *)buff6 + index), buff1[index], *((char *)buff6 + index), EXIT);
+ }
+
+EXIT:
+ LOS_QueueDelete(g_testQueueID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead042(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead042", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_001.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..b33b771d7a9d0dce33c20e08324d130a2d4601e4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_001.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 3, &g_testQueueID01, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueRead(g_testQueueID01, &buff2, 8, 0); // 8, Read the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItLosQueue001(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue001", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_097.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_097.c
new file mode 100644
index 0000000000000000000000000000000000000000..8580c23340348112a5c175d7db049c52ba3298a6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_097.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID, 0, 8); // 3, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(queueID, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueInfoGet(queueID, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(queueInfo.usQueueLen, 3, queueInfo.usQueueLen, EXIT); // 3, Here, assert the usQueueLen.
+ ICUNIT_GOTO_EQUAL(queueInfo.uwQueueID, queueID, queueInfo.uwQueueID, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueInfoGet(queueID, &queueInfo);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue097(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue097", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_100.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_100.c
new file mode 100644
index 0000000000000000000000000000000000000000..5cc6783faa5beb3504cdac0a1807f8adfa69efaa
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_100.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "123";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ UINT32 readSize;
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID, 0, sizeof(UINTPTR)); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(queueID, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = sizeof(buff1);
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(queueID, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = sizeof(buff1) + 1;
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(queueID, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = sizeof(buff1);
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(queueID, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = 0;
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READSIZE_IS_INVALID, ret, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue100(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue100", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_105.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_105.c
new file mode 100644
index 0000000000000000000000000000000000000000..69edc59746e9a65ec6bc913abf724075ca859a68
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_105.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 queueID;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "abc";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+ QUEUE_INFO_S queueInfo;
+ UINT32 readSize;
+
+ ret = LOS_QueueCreate("Q1", 3, &queueID, 0, QUEUE_SHORT_BUFFER_LENTH); // 3, Set the queue length.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteCopy(queueID, &buff1, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ ret = LOS_QueueRead(queueID, &buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteCopy(queueID, &buff1, QUEUE_SHORT_BUFFER_LENTH + PER_ADDED_VALUE, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ ret = LOS_QueueRead(queueID, &buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueWrite(queueID, &buff1, QUEUE_SHORT_BUFFER_LENTH - 1, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ ret = LOS_QueueRead(queueID, &buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ ret = LOS_QueueRead(queueID, &buff2, QUEUE_SHORT_BUFFER_LENTH, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
+
+ ret = LOS_QueueWrite(queueID, &buff1, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ memset(buff2, 0, QUEUE_SHORT_BUFFER_LENTH);
+ readSize = 0;
+ ret = LOS_QueueReadCopy(queueID, &buff2, &readSize, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READSIZE_IS_INVALID, ret, EXIT);
+
+ ret = LOS_QueueDelete(queueID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ LOS_QueueDelete(queueID);
+ return LOS_OK;
+}
+
+VOID ItLosQueue105(VOID)
+{
+ TEST_ADD_CASE("ItLosQueue105", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_head_002.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_head_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..07d331ffc4ab2acdeb5f2cc21c434c9ff0eeb3ab
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smoke/It_los_queue_head_002.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ CHAR buff1[8] = "A";
+ CHAR buff2[8] = "B";
+ CHAR buff3[8] = "C";
+
+ ret = LOS_QueueCreate("Q1", 2, &g_testQueueID01, 0, 8); // 2, Set the queue length; 8, Set the node size of the queue.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &buff2, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_QueueWriteHead(g_testQueueID01, &buff3, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISFULL, ret, EXIT);
+
+EXIT:
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosQueueHead002(VOID)
+{
+ TEST_ADD_CASE("ItLosQueueHead002", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_001.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..fd3b19c228535413baf136c395eff999923cc78e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_001.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue001(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue001", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_002.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..554fa104ad5c9e36243da206e454607ef7f4d345
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_002.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue002(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue002", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_003.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..081912e074a1845fbd6ed88b4ec2e915e48b5143
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_003.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ CHAR buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+ CHAR buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue003(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue003", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_004.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..81b18dedabc4cbeb1abbcc4e57f539f7684c5a21
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_004.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue004(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue004", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_005.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..e7172d95a991eab9082fc459c4b0934c0c1a5f70
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_005.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue005(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue005", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_006.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..6b6ea0f6ba43f8d62b98b5fdb0a69542f557924d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_006.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_006_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ TestBusyTaskDelay(2); // 2, Set the timeout of runtime;
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelay(10); // 10, set delay time.
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue006(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue006", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_007.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..e0f6614ec7795acd25405b7ac4145ceda9467be7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_007.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ // 2, set new task priority, it is higher than the current task.
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_007_task1", TaskF01, TASK_PRIO_TEST - 2,
+ CPUID_TO_AFFI_MASK(currCpuid));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_007_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue007(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue007", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_008.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..edda2db5f6bc5abdc68f475dee2fb9297faef14d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_008.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_READ_IN_INTERRUPT, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue008(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue008", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_009.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..1c5acfbdbdbe90699644d442bcd9c2cce81a0ef9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_009.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ LOS_TaskDelay(1);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT);
+
+EXIT:
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelay(10); // 10, set delay time.
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue009(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue009", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_010.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..e18af10c6f998ceb842bb910c2abdc342c799695
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_010.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, 0); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ // 2, set new task priority, it is higher than the current task.
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_010_task1", TaskF01, TASK_PRIO_TEST - 2,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_010_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue010(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue010", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_011.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..c40c3f0645d1b11e95d274dfc8d1040638f960ae
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_011.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_011_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_011_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue011(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue011", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_012.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..748b2b01bcebf18a27b1668ec3de4d85e8b0d211
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_012.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_NO_WAIT); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue012(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue012", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_013.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..ac654e4606965c069dea09bb6ad442dc19c2e677
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_013.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 2); // 2, Here, judgment that g_testCount is not equal to 2.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_013_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_013_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.;
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue013(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue013", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_014.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_014.c
new file mode 100644
index 0000000000000000000000000000000000000000..5089977827d30e096026e4c362dcf2bff3d88799
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_014.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 2); // 2, Here, judgment that g_testCount is not equal to 2.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue014(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue014", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_015.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..35cf920bbcbde1d043c6fc5dac36caba66abb7ad
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_015.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_NO_WAIT); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 2); // 2, Here, judgment that g_testCount is not equal to 3.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue015(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue015", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_016.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_016.c
new file mode 100644
index 0000000000000000000000000000000000000000..ea005e5f281b2c6f4874ca7462dfa7abce50bdbd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_016.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_016_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue016(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue016", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_017.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_017.c
new file mode 100644
index 0000000000000000000000000000000000000000..42edef56ae4f324046bc7935a38a42c32ede82bf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_017.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_017_task2", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue017(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue017", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_018.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..795c364bca0a4fad096c1df09bc6649d8267f105
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_018.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task2", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue018(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue018", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_019.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..ecfda6461b44647b13b6ceb0c182da372b2b8828
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_019.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 "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_NO_WAIT); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue019(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue019", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_020.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..c7ea5b953f054097c646708ff257195fe2daae30
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_020.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_020_task2", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue020(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue020", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_021.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..5977a3dba8b382949c00db30ad6a0551cf36b125
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_021.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_021_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue021(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue021", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_022.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..754dfd7a9e2fe2a53abf658c5f2342be08478ad5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_022.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_READ_IN_INTERRUPT, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue022(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue022", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_023.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..b3d75d5e60d2bfbe48fcfa8e89663e483be86512
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_023.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_023_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_023_task", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // othercpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue023(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue023", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_024.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_024.c
new file mode 100644
index 0000000000000000000000000000000000000000..01e1f5a6746ea18e6d84a510e3b066d252cab164
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_024.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue024(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue024", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_025.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_025.c
new file mode 100644
index 0000000000000000000000000000000000000000..40621d02fb08cefcbaedb4b4bd29bfd762b111d5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_025.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_READ_IN_INTERRUPT, ret);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue025(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue025", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_026.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..15cecefbe976fb0d1eace2653bf731143fcb019b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_026.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to 4.
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2.
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, uvIntSave;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_033_task2", TaskF02, TASK_PRIO_TEST - 1, CPUID_TO_AFFI_MASK(currCpuid));
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestBusyTaskDelay(10); // 10, Set the timeout of runtime; let the task f02 todo pend
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_033_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ LOS_TaskLock();
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, Here, assert that g_testCount is equal to 3.
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, Here, assert that g_testCount is equal to 3.
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to 5.
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+EXIT1:
+ LOS_TaskUnlock();
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue026(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue026", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_027.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..75c416e76e17a70585ea07873e7970ed361925c1
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_027.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static volatile UINT32 g_runFlag = 1;
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ PRINT_DEBUG("task f01 pend begin\n");
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ PRINT_DEBUG("task f01 pend success\n");
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to 3.
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, uvIntSave;
+
+ PRINT_DEBUG("task f02 lock\n");
+
+ LOS_TaskLock(); // task lock on other cpu
+ LOS_AtomicInc(&g_testCount);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_runFlag == 1);
+
+ PRINT_DEBUG("task f02 unlock\n");
+ LOS_TaskUnlock(); // schedule occur ---switch to task f01
+
+ PRINT_DEBUG("task f02 back\n");
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to 4.
+
+ TestDumpCpuid();
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_runFlag = 1;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_034_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_034_task2", TaskF02, TASK_PRIO_TEST,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ /* wait for task01 to pend sem */
+ TestBusyTaskDelay(2); // 2, Set the timeout of runtime;
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT); // pend
+
+ PRINT_DEBUG("sem post\n");
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT); // not pend
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ LOS_AtomicInc(&g_testCount);
+
+ PRINT_DEBUG("try to unlock\n");
+
+ g_runFlag = 0; // unlock the other cpu
+
+ PRINT_DEBUG("finally\n");
+ TestAssertBusyTaskDelay(100, 4); // 100, Set the timeout of runtime; 4, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to 4.
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue027(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue027", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_029.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..d2997d4358477172cf7494417eea15f71cd778aa
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_029.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_029_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_029_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
+
+ /* wait for task01 to pend sem */
+ TestBusyTaskDelay(2); // 2, Set the timeout of runtime;
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count.
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelay(1); // cross delete task need time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue029(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue029", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_031.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_031.c
new file mode 100644
index 0000000000000000000000000000000000000000..b64fee415d8a1fe232c52319c897e3ce4dd786ef
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_031.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static UINT32 g_ret = 0xff;
+static VOID TaskF01(VOID)
+{
+ UINT32 ret, i;
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++); // 500, Set this loop to not more than 500 cpu cycles.
+
+ ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer.
+ g_ret = ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+ LosTaskCB *cb = NULL;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ g_ret = 0xff;
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_031_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; wait for task f01 run
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ for (j = 0; j < TRandom() % 500; j++); // 500, Set this loop to not more than 500 cpu cycles.
+
+ ret = LOS_QueueDelete(g_testQueueID01); // delete queue in current cpu
+ if ((g_ret == LOS_ERRNO_QUEUE_NOT_CREATE) && (ret == LOS_OK)) {
+ } else if ((g_ret == 0xff) && (ret == LOS_OK)) {
+ } else if ((g_ret == 0xff) && (ret == LOS_ERRNO_QUEUE_IN_TSKUSE)) {
+ } else {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret, EXIT); // report error
+ }
+
+ /* clear enviorment */
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelay(10); // 10, set delay time.
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ PRINT_DEBUG("finally delRet = 0x%x\n", ret);
+ }
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue031(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue031", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_032.c b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_032.c
new file mode 100644
index 0000000000000000000000000000000000000000..f5bb30bda102e8cbf44afb7253eabdd87ff70798
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/queue/smp/It_smp_los_queue_032.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_queue.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENTH] = "UniDSP";
+static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENTH] = "";
+static UINT32 g_ret = 0xff;
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, i;
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++); // 500, Set this loop to not more than 500 cpu cycles.
+
+ ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.
+ g_ret = ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+ LosTaskCB *cb = NULL;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ g_ret = 0xff;
+ ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_032_task1", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 0); // wait for task f01 run
+ for (j = 0; j < TRandom() % 500; j++); // 500, Set this loop to not more than 500 cpu cycles.
+
+ ret = LOS_QueueDelete(g_testQueueID01); // delete queue in current cpu
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ if ((g_ret != LOS_OK) && (g_ret != LOS_ERRNO_QUEUE_NOT_CREATE) && (g_ret != 0xff)) {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret, EXIT);
+ }
+
+ PRINT_DEBUG("writeRet = 0x%x, delRet = 0x%x\n", g_ret, ret);
+
+ /* clear enviorment */
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelay(10); // 10, set delay time.
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = LOS_QueueDelete(g_testQueueID01);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
+ PRINT_DEBUG("finally delRet = 0x%x\n", ret);
+ }
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_QueueDelete(g_testQueueID01);
+ return LOS_OK;
+}
+
+VOID ItSmpLosQueue032(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosQueue032", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/It_los_sem.c b/testsuites/kernel/sample/kernel_base/ipc/sem/It_los_sem.c
new file mode 100644
index 0000000000000000000000000000000000000000..3e8b583f740283447ce93d6a6ddb6dfcca112b4f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/It_los_sem.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+VOID ItSuiteLosSem(void)
+{
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* fixed */
+ ItSmpLosSem008();
+ ItSmpLosSem022();
+ ItSmpLosSem025();
+
+ ItSmpLosSem001();
+ ItSmpLosSem002();
+ ItSmpLosSem003();
+ ItSmpLosSem004();
+ ItSmpLosSem005();
+ ItSmpLosSem006();
+ ItSmpLosSem007();
+ ItSmpLosSem009();
+ ItSmpLosSem010();
+ ItSmpLosSem011();
+ ItSmpLosSem012();
+ ItSmpLosSem013();
+ ItSmpLosSem014();
+ ItSmpLosSem015();
+ ItSmpLosSem016();
+ ItSmpLosSem017();
+ ItSmpLosSem018();
+ ItSmpLosSem019();
+ ItSmpLosSem020();
+ ItSmpLosSem021();
+ ItSmpLosSem023();
+ ItSmpLosSem024();
+ ItSmpLosSem026();
+ ItSmpLosSem027();
+ ItSmpLosSem028();
+ ItSmpLosSem029();
+ ItSmpLosSem030();
+ ItSmpLosSem031();
+ ItSmpLosSem032();
+ ItSmpLosSem033();
+ ItSmpLosSem034();
+ ItSmpLosSem035();
+ ItSmpLosSem036();
+#endif
+
+#if defined(LOSCFG_TEST_SMOKE)
+ ItLosSem001();
+ ItLosSem003();
+ ItLosSem006();
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+ ItLosSem002();
+ ItLosSem005();
+ ItLosSem009();
+ ItLosSem012();
+ ItLosSem013();
+ ItLosSem014();
+ ItLosSem015();
+ ItLosSem016();
+ ItLosSem017();
+ ItLosSem019();
+ ItLosSem020();
+#if (LOSCFG_KERNEL_SMP != YES)
+ ItLosSem018();
+ ItLosSem021();
+ ItLosSem025();
+#endif
+ ItLosSem022();
+ ItLosSem023();
+ ItLosSem026();
+ ItLosSem027();
+ ItLosSem028();
+ ItLosSem029();
+ ItLosSem034();
+#endif
+
+#if defined(LOSCFG_TEST_PRESSURE)
+#ifndef TESTHI1980IMU
+ ItLosSem035();
+#endif
+ ItLosSem036();
+ ItLosSem037();
+ ItLosSem038();
+#if (LOSCFG_KERNEL_SMP_TASK_SYNC != YES)
+ // LOSCFG_KERNEL_SMP_TASK_SYNC is opened ,create task success is depend on created semaphore successed;
+ ItLosSem039();
+ ItLosSem040();
+ ItLosSem041();
+ ItLosSem043();
+#endif
+ ItLosSem042();
+ ItLosSem044(); // ID will not be duplicate
+#endif
+
+#if defined(LOSCFG_TEST_LLT)
+ ItLosSem004();
+ ItLosSem007();
+ ItLosSem008();
+ ItLosSem010();
+ ItLosSem011();
+ ItLosSem024();
+ ItLosSem030();
+ ItLosSem032();
+#if (LOSCFG_KERNEL_SMP != YES)
+ ItLosSem033();
+#endif
+ LltLosSem001();
+#if defined(LOSCFG_SHELL) && defined(LOSCFG_DEBUG_SEMAPHORE)
+ ItLosSemDebug001();
+#endif
+#endif
+#if defined(LOSCFG_TEST_MANUAL_SHELL) || defined(LOSCFG_TEST_MANUAL_TEST)
+#if defined(LOSCFG_DEBUG_SEMAPHORE)
+ ItLosSem045();
+ ItLosSem046();
+ ItLosSem047();
+ ItLosSem048();
+ ItLosSem049();
+ ItLosSem050();
+#endif
+#endif
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, 1);
+#endif
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/It_los_sem.h b/testsuites/kernel/sample/kernel_base/ipc/sem/It_los_sem.h
new file mode 100644
index 0000000000000000000000000000000000000000..0da88acf6dcb93df9b348565b007eca9baad35af
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/It_los_sem.h
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _IT_LOS_SEM_H
+#define _IT_LOS_SEM_H
+
+#include "osTest.h"
+#include "los_sem_pri.h"
+#include "los_task_pri.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+extern volatile UINT64 g_tickCount[];
+extern VOID ItSuiteLosSem(void);
+#define LOOP 100
+
+#ifndef spin_lock
+#define spin_lock(lock) \
+ do { \
+ LOS_TaskLock(); \
+ } while (0)
+#endif
+#ifndef spin_unlock
+#define spin_unlock(lock) \
+ do { \
+ LOS_TaskUnlock(); \
+ } while (0)
+#endif
+
+#if defined(LOSCFG_TEST_SMOKE)
+VOID ItLosSem001(void);
+VOID ItLosSem002(void);
+VOID ItLosSem003(void);
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+VOID ItLosSem005(void);
+VOID ItLosSem006(void);
+VOID ItLosSem009(void);
+VOID ItLosSem012(void);
+VOID ItLosSem013(void);
+VOID ItLosSem014(void);
+VOID ItLosSem015(void);
+VOID ItLosSem016(void);
+VOID ItLosSem017(void);
+VOID ItLosSem018(void);
+VOID ItLosSem019(void);
+VOID ItLosSem020(void);
+VOID ItLosSem021(void);
+VOID ItLosSem022(void);
+VOID ItLosSem023(void);
+VOID ItLosSem025(void);
+VOID ItLosSem026(void);
+VOID ItLosSem027(void);
+VOID ItLosSem028(void);
+VOID ItLosSem029(void);
+VOID ItLosSem034(void);
+#endif
+
+#if defined(LOSCFG_TEST_PRESSURE)
+VOID ItLosSem035(void);
+VOID ItLosSem036(void);
+VOID ItLosSem037(void);
+VOID ItLosSem038(void);
+VOID ItLosSem039(void);
+VOID ItLosSem040(void);
+VOID ItLosSem041(void);
+VOID ItLosSem042(void);
+VOID ItLosSem043(void);
+VOID ItLosSem044(void);
+#endif
+
+#if (LOSCFG_KERNEL_SMP == YES)
+VOID ItSmpLosSem001(VOID);
+VOID ItSmpLosSem002(VOID);
+VOID ItSmpLosSem003(VOID);
+VOID ItSmpLosSem004(VOID);
+VOID ItSmpLosSem005(VOID);
+VOID ItSmpLosSem006(VOID);
+VOID ItSmpLosSem007(VOID);
+VOID ItSmpLosSem008(VOID);
+VOID ItSmpLosSem009(VOID);
+VOID ItSmpLosSem010(VOID);
+VOID ItSmpLosSem011(VOID);
+VOID ItSmpLosSem012(VOID);
+VOID ItSmpLosSem013(VOID);
+VOID ItSmpLosSem014(VOID);
+VOID ItSmpLosSem015(VOID);
+VOID ItSmpLosSem016(VOID);
+VOID ItSmpLosSem017(VOID);
+VOID ItSmpLosSem018(VOID);
+VOID ItSmpLosSem019(VOID);
+VOID ItSmpLosSem020(VOID);
+VOID ItSmpLosSem021(VOID);
+VOID ItSmpLosSem022(VOID);
+VOID ItSmpLosSem023(VOID);
+VOID ItSmpLosSem024(VOID);
+VOID ItSmpLosSem025(VOID);
+VOID ItSmpLosSem026(VOID);
+VOID ItSmpLosSem027(VOID);
+VOID ItSmpLosSem028(VOID);
+VOID ItSmpLosSem029(VOID);
+VOID ItSmpLosSem030(VOID);
+VOID ItSmpLosSem031(VOID);
+VOID ItSmpLosSem032(VOID);
+VOID ItSmpLosSem033(VOID);
+VOID ItSmpLosSem034(VOID);
+VOID ItSmpLosSem035(VOID);
+VOID ItSmpLosSem036(VOID);
+#endif
+
+VOID ItSuiteLosSem(void);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif /* _IT_LOS_SEM_H */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_002.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..f20fca851310d76aa4fe89b36287a8cf6d42f256
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_002.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_SemCreate(0, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_SEM_PTR_NULL, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSem002(void) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItLosSem002", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_005.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..75c97681642db22781a66badfebf8594d800b673
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_005.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_SemCreate(2, &g_semID); // 2, Number of semaphore available
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemPend(g_semID, LOS_NO_WAIT);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SemPend(g_semID, 0xF);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ret = LOS_SemPend(g_semID, LOS_NO_WAIT);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SEM_UNAVAILABLE, ret, EXIT);
+
+ ret = LOS_SemPend(g_semID, 0xF);
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_SEM_TIMEOUT, ret);
+
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSem005(void)
+{
+ TEST_ADD_CASE("ItLosSem005", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_009.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..0546b300f487d4f28061ff71f0257b2b9ec8b73e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_009.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk9";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT2);
+
+EXIT2:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+EXIT1:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem009(void)
+{
+ TEST_ADD_CASE("ItLosSem009", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_012.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..3bcba226d127fb947a920702cf908349c3060590
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_012.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTsk = 0;
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testTsk = 1;
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+static VOID TaskF02(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testTsk = 2; // 2, Set flag number
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "Sem12";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ g_testTsk = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.pcName = "Sem12_1";
+ task.usTaskPrio = TASK_PRIO_TEST - 3; // 3, Set the priority according to the task purpose,a smaller number means a higher priority.
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT2); // 2, Here, assert that g_testCount is equal to
+
+ ICUNIT_GOTO_EQUAL(g_testTsk, 0, g_testTsk, EXIT3);
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testTsk, 1, g_testTsk, EXIT3);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ LOS_TaskDelay(1);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT2); // 4, Here, assert that g_testCount is equal to
+ ICUNIT_GOTO_EQUAL(g_testTsk, 2, g_testTsk, EXIT3); // 2, Here, assert that g_testCount is equal to
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT2:
+ LOS_TaskDelete(g_testTaskID02);
+EXIT1:
+ LOS_TaskDelete(g_testTaskID01);
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+EXIT3:
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem012()
+{
+ TEST_ADD_CASE("ItLosSem012", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_013.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..0024de1610e70dec5d04c6a31d1e6a11edc84902
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_013.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTsk = 0;
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID TaskF02(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID2, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk13";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemCreate(0, &g_semID2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT3);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.pcName = "Sem13_1";
+ task.usTaskPrio = TASK_PRIO_TEST - 2; // 2, Set the priority according to the task purpose,a smaller number means a higher priority.
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to
+
+ LOS_TaskDelete(g_testTaskID02);
+EXIT3:
+ LOS_TaskDelete(g_testTaskID01);
+EXIT2:
+ ret = LOS_SemDelete(g_semID2);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem013(void)
+{
+ TEST_ADD_CASE("ItLosSem013", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_014.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_014.c
new file mode 100644
index 0000000000000000000000000000000000000000..addcecc5d555089aa5ac94c648f52ea97f0acc24
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_014.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTsk = 0;
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testTsk = 1;
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID TaskF02(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testTsk = 2; // 2, Set flag number
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk14";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST + 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.pcName = "Sem14_1";
+ task.usTaskPrio = TASK_PRIO_TEST + 2; // 2, Set the priority according to the task purpose,a smaller number means a higher priority.
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = LOS_SemPend(g_semID, 0xF);
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_SEM_TIMEOUT, ret);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to
+
+ LOS_TaskDelete(g_testTaskID02);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem014(void)
+{
+ TEST_ADD_CASE("ItLosSem014", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_015.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..b53d6519c154865bc57c61d6fef06b5ce203d36c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_015.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTsk = 0;
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testTsk = 1;
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID TaskF02(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testTsk = 2; // 2, Set flag number
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk15";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT2);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.pcName = "Sem15_1";
+ task.usTaskPrio = TASK_PRIO_TEST + 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = LOS_SemPend(g_semID, 0xF);
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_SEM_TIMEOUT, ret);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to
+
+ LOS_TaskDelete(g_testTaskID02);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem015(void)
+{
+ TEST_ADD_CASE("ItLosSem015", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_016.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_016.c
new file mode 100644
index 0000000000000000000000000000000000000000..b75cec7027fb5462df3400d07256e8763786966f
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_016.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTsk = 0;
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID TaskF02(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk16";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT2);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.pcName = "Sem16_1";
+ task.usTaskPrio = TASK_PRIO_TEST - 2; // 2, Set the priority according to the task purpose,a smaller number means a higher priority.
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to
+
+ ret = LOS_SemPend(g_semID, 0xF);
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_SEM_TIMEOUT, ret);
+
+ LOS_TaskDelete(g_testTaskID02);
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem016(void)
+{
+ TEST_ADD_CASE("ItLosSem016", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_017.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_017.c
new file mode 100644
index 0000000000000000000000000000000000000000..92b6921616fcddb233da9866862bffb3c55925da
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_017.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk17";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem017(void)
+{
+ TEST_ADD_CASE("ItLosSem017", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_019.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..f91f89c01a3aa6d7c37a7c162e8f3bb63fb1c373
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_019.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTsk = 0;
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testTsk = 1;
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "Sem19";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+
+ g_testCount = 0;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+
+EXIT2:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSem019(void)
+{
+ TEST_ADD_CASE("ItLosSem019", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_020.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..be91142606bf4cb100a9c8bc98861404e1a1b569
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_020.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk20";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_TaskLock();
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT2); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSem020(void)
+{
+ TEST_ADD_CASE("ItLosSem020", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_022.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..db7ae18dd8c384a069ff8da2c96ea5d48dada545
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_022.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTsk = 0;
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testTsk = 1;
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID TaskF02(void)
+{
+ UINT32 ret;
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_TaskLock();
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+#if (LOSCFG_KERNEL_SMP != YES)
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+#endif
+
+ LOS_TaskUnlock();
+#if (LOSCFG_KERNEL_SMP != YES)
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+#endif
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk22";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ g_testCount = 0;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT2);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.pcName = "Sem22_1";
+ task.usTaskPrio = TASK_PRIO_TEST - 2; // 2, Set the priority according to the task purpose,a smaller number means a higher priority.
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to
+
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem022(void)
+{
+ TEST_ADD_CASE("ItLosSem022", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_023.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..4eb0ab8cdc4c3214fddafd1992177442ad54cacd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_023.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testTsk = 0;
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_testTsk = 1;
+ g_testCount++;
+
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static VOID HwiF01(void)
+{
+ UINT32 ret;
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk23";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ g_testCount = 0;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT2);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+ ret = TEST_HwiCreate(HWI_NUM_TEST, 0, 0, HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+#if (LOSCFG_KERNEL_SMP == YES)
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+#endif
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem023(void)
+{
+ TEST_ADD_CASE("ItLosSem023", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_026.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..5195b921860ba8ba017f517ffe0c131a2f92bfeb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_026.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+#if (LOSCFG_KERNEL_SMP != YES)
+ ICUNIT_TRACK_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to
+#endif
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID02);
+}
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+#if (LOSCFG_KERNEL_SMP != YES)
+ ICUNIT_TRACK_EQUAL(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to
+#endif
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk26";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ g_testCount = 0;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT2);
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task.pcName = "Sem26_1";
+ task.usTaskPrio = TASK_PRIO_TEST - 2; // 2, Set the priority according to the task purpose,a smaller number means a higher priority.
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ ret = LOS_TaskCreate(&g_testTaskID02, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT3); // 2, Here, assert that g_testCount is equal to
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskLock();
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskUnlock();
+
+ TestExtraTaskDelay(TEST_TASKDELAY_10TICK);
+ ICUNIT_TRACK_EQUAL(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to
+
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+EXIT3:
+ LOS_TaskDelete(g_testTaskID02);
+
+EXIT2:
+ LOS_TaskDelete(g_testTaskID01);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSem026(void)
+{
+ TEST_ADD_CASE("ItLosSem026", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_027.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..d52981eda5e22bbbe987100b742df570bd901685
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_027.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define IT_SEMLOOP 10
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+ UINT32 i;
+
+ g_testCount++;
+
+ for (i = 0; i < IT_SEMLOOP + 1; i++) {
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ }
+
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk_27";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ g_testCount = 0;
+ ret = LOS_SemCreate(IT_SEMLOOP, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskDelay(100); // 100, delay enouge time
+
+ ICUNIT_GOTO_NOT_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_TaskDelete(g_testTaskID01);
+
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem027(void)
+{
+ TEST_ADD_CASE("ItLosSem027", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_028.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_028.c
new file mode 100644
index 0000000000000000000000000000000000000000..2c43ef311518efd79e3711bb726f7ccac1738fc5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_028.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define IT_SEMLOOP 10
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+ UINT32 i;
+
+ g_testCount++;
+ for (i = 0; i < IT_SEMLOOP; i++) {
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ }
+
+ for (i = 0; i < IT_SEMLOOP + 1; i++) {
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ }
+
+ g_testCount++;
+ LOS_TaskDelete(g_testTaskID01);
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "SemTsk28";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ g_testCount = 0;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_GOTO_NOT_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_TaskDelete(g_testTaskID01);
+
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSem028(void)
+{
+ TEST_ADD_CASE("ItLosSem028", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_029.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..a9166b94836f0980a1f7d5682c6d26dadc36eac7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_029.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define IT_SEMLOOP 10
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 i;
+
+ g_testCount = 0;
+ ret = LOS_SemCreate(0xFFFF - IT_SEMLOOP, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (i = 0; i < IT_SEMLOOP - 1; i++) {
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_SEM_OVERFLOW, ret);
+
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItLosSem029(void)
+{
+ TEST_ADD_CASE("ItLosSem029", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_034.c b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_034.c
new file mode 100644
index 0000000000000000000000000000000000000000..aec135db04213c459dc6181bdbf6e637d7a99d78
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/full/It_los_sem_034.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(void)
+{
+ UINT32 ret;
+ UINT64 osEndTime;
+ UINT64 osStartTime;
+ UINT32 tickNum;
+
+ g_testCount++;
+
+ osStartTime = LOS_TickCountGet();
+ ret = LOS_SemPend(g_semID, 1000); // 1000, set timeout
+ osEndTime = LOS_TickCountGet();
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_SEM_TIMEOUT, ret);
+
+ tickNum = (osEndTime - osStartTime);
+
+ if (tickNum < (1000 - TEST_TASKDELAY_2TICK) || tickNum > (1000 + TEST_TASKDELAY_2TICK)) { // 1000, timeout
+ ICUNIT_ASSERT_EQUAL_VOID(tickNum, 0, tickNum);
+ }
+
+ g_testCount++;
+
+ LOS_TaskDelay(100); // 100, delay enouge time
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = { 0 };
+
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task.pcName = "Sem_34";
+ task.uwStackSize = TASK_STACK_SIZE_TEST;
+ task.usTaskPrio = TASK_PRIO_TEST - 1;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ g_testCount = 0;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ TestExtraTaskDelay(TEST_TASKDELAY_2TICK);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ LOS_TaskDelay(1000); // 1000, delay enouge time
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem034(void)
+{
+ TEST_ADD_CASE("ItLosSem034", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smoke/It_los_sem_001.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smoke/It_los_sem_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..63d4352a7e58e4b157732bbfdfff8f62c904c6c7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smoke/It_los_sem_001.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define IT_SEM_COUNT_MAX 0xFFFE
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemCreate(1, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemCreate(IT_SEM_COUNT_MAX, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemCreate(IT_SEM_COUNT_MAX + 1, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_SEM_OVERFLOW, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem001()
+{
+ TEST_ADD_CASE("ItLosSem001", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smoke/It_los_sem_003.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smoke/It_los_sem_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..957425bfd6a19ee756e6a2b492ee7399561dbdb9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smoke/It_los_sem_003.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define IT_SEM_COUNT_MAX 0xFFFE
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemPend(g_semID, 2); // 2, set timeout
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_SEM_TIMEOUT, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemCreate(1, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemCreate(IT_SEM_COUNT_MAX, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem003(void)
+{
+ TEST_ADD_CASE("ItLosSem003", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smoke/It_los_sem_006.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smoke/It_los_sem_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..3c821ee72a54aca2561e4de8bb3987f423d23958
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smoke/It_los_sem_006.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define IT_SEM_COUNT_MAX 0xFFFE
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_TRACK_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemCreate(IT_SEM_COUNT_MAX, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_TRACK_EQUAL(ret, LOS_ERRNO_SEM_OVERFLOW, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItLosSem006(void)
+{
+ TEST_ADD_CASE("ItLosSem006", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_001.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..12256ba9b8d52f65c62910d450c97a0e799df151
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_001.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_event.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(1, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem001(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem001", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_002.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..1efaf285012761d790b98913c64d4dc6f9c8e21b
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_002.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_SemCreate(1, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem002(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem002", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_003.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..20fc07f4865ec318ee69ca8cdd9dffe932bc06e5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_003.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_SemCreate(1, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem003(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem003", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_004.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..b99d0ee9423b6ad8b8b24c5a69a22b492b77de2e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_004.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_SEM_PENDED, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem004(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem004", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_005.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..d4af7754c030059837b8b3fc19705657b5dbb969
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_005.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_SEM_PENDED, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+ TestBusyTaskDelay(1);
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem005(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem005", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_006.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..92f1fabddaaa1894a74ad9f931efbaacb2e26fe4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_006.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_006_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ LOS_TaskDelay(1);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SEM_PENDED, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem006(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem006", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_007.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..7ca8611d5a0cd94c1a2db58e7b61358a38e70a01
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_007.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ /* wait for task1 to pend sem */
+ TestBusyTaskDelay(1);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_SEM_PENDED, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ // 2, Set the priority according to the task purpose,a smaller number means a higher priority.
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_007_task1", TaskF01, TASK_PRIO_TEST - 2,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_007_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+ /* wait for task1 to pend sem */
+ TestBusyTaskDelay(1);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelete(g_testTaskID02);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem007(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem007", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_008.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..15772fd29e101e8aec959018bc86174674c001d2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_008.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SEM_PEND_INTERR, ret, EXIT);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(200, 2); // 200, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert the result
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosSem008(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem008", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_009.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..722604790fe95c4f54797ec1764ae68f4e4cea6a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_009.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_SEM_PENDED, ret);
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ /* wait for task1 to pend sem */
+ TestBusyTaskDelay(1);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(200, 2); // 200, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem009(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem009", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_010.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..063970c23b83e2565aa57433c3812336a496c3c9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_010.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_010_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_010_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem010(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem010", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_011.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..9df65de7997e385913937012d97cc479e67bce60
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_011.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_011_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_011_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem011(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem011", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_012.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..117b212c0520aabcbd4607be03fe464709cef967
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_012.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem012(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem012", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_013.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..e6d603b0672bc67fc16c35538c1381a6dadb8767
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_013.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_013_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_013_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem013(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem013", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_014.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_014.c
new file mode 100644
index 0000000000000000000000000000000000000000..04339c5a8d0a3af8a9c0ac96cffd674fd22ae251
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_014.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 1);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ TestDumpCpuid();
+ return;
+}
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem014(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem014", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_015.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..65e42aaf2700f1cde3ad49448dc3d8fcf97efbcf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_015.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount != 2); // 2, wait flag is, or do nothing
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem015(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem015", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_016.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_016.c
new file mode 100644
index 0000000000000000000000000000000000000000..46f9bcd58a85760e5c7ebaa8a94c3dc9ddb7554c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_016.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 "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_016_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem016(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem016", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_017.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_017.c
new file mode 100644
index 0000000000000000000000000000000000000000..4004112cbc2fc480091b86a628463279c1ec907a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_017.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_017_task2", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem017(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem017", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_018.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..57b48fff9beb14496e26e735ad91e68cb564b4ce
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_018.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task2", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem018(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem018", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_019.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..3d0acd58aa990643f63a388207046d89b5b5b4ba
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_019.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 "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem019(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem019", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_020.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..874dc295e4def9f4bac52c8bcb159a81cd3fa004
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_020.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 "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_020_task2", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem020(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem020", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_021.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..be508e133e859b7fd48a029c36852765e30e451a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_021.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_021_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem021(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem021", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_022.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..9430eeabf6fa56484f5c9629c0aa153e4604fad9
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_022.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SEM_PEND_INTERR, ret, EXIT);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+EXIT:
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ return;
+}
+
+static UINT32 testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem022(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem022", testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_023.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..71c02351586b41d419e1cb4db40898b232960f70
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_023.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_023_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_023_task", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // othercpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem023(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem023", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_024.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_024.c
new file mode 100644
index 0000000000000000000000000000000000000000..1da69829643e37b9051595a4c7ffbe35a6745657
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_024.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem024(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem024", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_025.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_025.c
new file mode 100644
index 0000000000000000000000000000000000000000..9a5bf434f9a287c2abeda547d13a06dd29a506ae
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_025.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret;
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SEM_PEND_INTERR, ret, EXIT);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+EXIT:
+ LOS_SemDelete(g_semID);
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ return;
+}
+
+static UINT32 testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ ret = LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+
+VOID ItSmpLosSem025(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem025", testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_026.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..8618e833e7d964e944fec4f2afd7f24b834ae1ab
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_026.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_ret1 = 0xff;
+static UINT32 g_ret2 = 0xff;
+
+static UINT32 TestAbs(UINT32 num1, UINT32 num2)
+{
+ return (num1 > num2) ? num1 - num2 : num2 - num1;
+}
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ g_ret1 = ret;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ g_ret2 = ret;
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_ret1 = 0xff;
+ g_ret2 = 0xff;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_026_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_026_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to
+ if ((g_ret1 + g_ret2 == 0xff) && (TestAbs(g_ret1, g_ret2) == 0xff))
+ ICUNIT_GOTO_EQUAL(1, 1, g_ret1, EXIT);
+ else {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret1, EXIT);
+ }
+ PRINT_DEBUG("ret1=0x%x,ret2=0x%x\n", g_ret1, g_ret2);
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem026(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem026", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_027.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..addd5d6309148c28d6f19907c5305db1e95130ce
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_027.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID HwiF01(VOID)
+{
+ UINT32 ret, i;
+ LOS_AtomicInc(&g_testCount);
+ for (i = 0; i < TRandom() % 500; i++) { // Gets a random value of 0-500
+ }
+
+ ret = LOS_SemPost(g_semID); // sem post in hwi
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+ LosTaskCB *cb = NULL;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_027_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_027_task1", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 1); // wait for task f02
+
+ for (j = 0; j < TRandom() % 500; j++) { // Gets a random value of 0-500
+ }
+
+ ret = LOS_SemPost(g_semID); // sem post in task
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 4); // 100, Set the timeout of runtime; 4, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_HwiDelete(HWI_NUM_TEST, NULL);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem027(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem027", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_028.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_028.c
new file mode 100644
index 0000000000000000000000000000000000000000..5d0cce83c4575915a0c64729998c6cea578e5bef
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_028.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_ret1 = 0xff;
+static UINT32 g_ret2 = 0xff;
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret, i;
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 100; i++) { // Gets a random value of 0-100
+ }
+
+ ret = LOS_SemDelete(g_semID);
+ g_ret2 = ret;
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+ LosTaskCB *cb = NULL;
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ g_ret1 = 0xff;
+ g_ret2 = 0xff;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_030_task2", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 0); // wait for task f01
+
+ for (j = 0; j < TRandom() % 500; j++) { // Gets a random value of 0-500
+ }
+
+ ret = LOS_SemDelete(g_semID);
+ g_ret1 = ret;
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+ if (((g_ret1 == LOS_OK) && (g_ret2 != LOS_OK)) || ((g_ret2 == LOS_OK) && (g_ret1 != LOS_OK)))
+ ICUNIT_GOTO_EQUAL(1, 1, g_ret1, EXIT);
+ else
+ ICUNIT_GOTO_EQUAL(1, 2, g_ret1, EXIT); // 2, Here, assert that g_testCount is equal to
+
+ TestBusyTaskDelay(10); // 10, delay enouge time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ }
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem028(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem028", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_029.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..3f877e0910a5f78c0febbbd12908dc4ba67f43b6
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_029.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_ret = 0;
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, i;
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++) { // Gets a random value of 0-500
+ }
+
+ ret = LOS_SemDelete(g_semID); // delete event in other cpu
+ g_ret = ret;
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+ LosTaskCB *cb = NULL;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ g_ret = 0;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_031_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_031_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 1); // wait for task f02
+
+ for (j = 0; j < TRandom() % 500; j++) { // Gets a random value of 0-500
+ }
+
+ ret = LOS_SemPost(g_semID); // post sem in other cpu
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ TestAssertBusyTaskDelay(100, 4); // 100, Set the timeout of runtime; 4, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to
+
+ if ((g_ret != LOS_OK) && (g_ret != LOS_ERRNO_SEM_PENDED)) {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret, EXIT);
+ }
+
+ /* clear enviorment */
+ ret = LOS_SemDelete(g_semID);
+ if (g_ret == LOS_ERRNO_SEM_PENDED) {
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SEM_INVALID, ret, EXIT);
+ }
+
+ TestBusyTaskDelay(2); // 2, delay enouge time
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ }
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem029(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem029", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_030.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_030.c
new file mode 100644
index 0000000000000000000000000000000000000000..742a1042e2003a6c7a146be7ff80ed037938fad8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_030.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#if (LOSCFG_KERNEL_SMP == YES)
+static UINT32 g_ret1, g_ret2, g_ret3;
+static UINT32 g_szId[3] = {0};
+
+static VOID TaskF01(UINT32 index)
+{
+ UINT32 ret, i;
+ switch (index) {
+ case 0:
+ for (i = 0; i < TRandom() % 500; i++) { // Gets a random value of 0-500
+ }
+ g_ret1 = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ LOS_AtomicInc(&g_testCount);
+ break;
+ case 1:
+ for (i = 0; i < TRandom() % 500; i++) { // Gets a random value of 0-500
+ }
+ g_ret2 = LOS_SemPost(g_semID);
+ LOS_AtomicInc(&g_testCount);
+ break;
+ case 2: // 2, index
+ for (i = 0; i < TRandom() % 500; i++) { // Gets a random value of 0-500
+ }
+ g_ret3 = LOS_SemDelete(g_semID);
+ LOS_AtomicInc(&g_testCount);
+ break;
+ default:
+ break;
+ }
+
+ TestDumpCpuid();
+ return;
+}
+static UINT32 Testcase(void)
+{
+ TSK_INIT_PARAM_S testTask;
+ UINT32 ret;
+ UINT32 i, j;
+
+ g_testCount = 0;
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ g_ret1 = 0xff;
+ g_ret2 = 0xff;
+ g_ret3 = 0xff;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ for (j = 0; j < 3; j++) { // 3, max index
+ TEST_TASK_PARAM_INIT(testTask, "it_sem_030_task", TaskF01, TASK_PRIO_TEST + 1);
+ testTask.auwArgs[0] = j;
+ ret = LOS_TaskCreate(&g_szId[j], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to
+
+ if ((g_ret1 == LOS_OK) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_OK)) { // pend-post-del ///post-pend-del
+ } else if ((g_ret1 == LOS_ERRNO_SEM_INVALID) && (g_ret2 == LOS_ERRNO_SEM_INVALID) &&
+ (g_ret3 == LOS_OK)) { // del-pend-post//del-post-pend
+ } else if ((g_ret1 == LOS_OK) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_ERRNO_SEM_PENDED)) { // pend-delete-post
+ } else if ((g_ret1 == LOS_ERRNO_SEM_INVALID) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_OK)) { // post-del-pend
+ } else {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret1, EXIT);
+ }
+ for (j = 0; j < 3; j++) { // 3, max index
+ ret = OS_TCB_FROM_TID(g_szId[j])->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+ }
+ LOS_SemDelete(g_semID);
+ }
+
+EXIT:
+ for (i = 0; i < 3; i++) { // 3, max index
+ LOS_TaskDelete(g_szId[i]);
+ }
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem030(VOID)
+{
+ TEST_ADD_CASE("ItSmpLosSem030", Testcase, TEST_LOS, TEST_HWI, TEST_LEVEL1, TEST_FUNCTION);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_031.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_031.c
new file mode 100644
index 0000000000000000000000000000000000000000..6dc8e6ee8847439940580338d3af3b8e6fc3018d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_031.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sz[LOSCFG_KERNEL_CORE_NUM] = {0};
+static UINT32 TestAbs(UINT32 num1, UINT32 num2)
+{
+ return (num1 > num2) ? num1 - num2 : num2 - num1;
+}
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemPend(g_semID, 10); // 10 ticks timeout
+ if ((ret != LOS_OK) && (ret != LOS_ERRNO_SEM_TIMEOUT)) {
+ ICUNIT_ASSERT_EQUAL_VOID(1, 0, ret);
+ }
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_031_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&g_sz[i], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(5); // 5, delay enouge time
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+
+ ret = LOS_SemPost(g_semID); // post sem before 10 ticks timeout
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM + 1, g_testCount, EXIT);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM * 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(g_sz[i]);
+ }
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem031(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem031", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_032.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_032.c
new file mode 100644
index 0000000000000000000000000000000000000000..bceb578afbd5e72cc486ada693b5369093fbc9f7
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_032.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_sz[LOSCFG_KERNEL_CORE_NUM] = {0};
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemPend(g_semID, 100); // 100 ticks timeout
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_031_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK((ArchCurrCpuid() + i + 1) %
+ LOSCFG_KERNEL_CORE_NUM)); // let current cpu 's task create at the last
+ ret = LOS_TaskCreate(&g_sz[i], &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ TestAssertBusyTaskDelay(100, LOSCFG_KERNEL_CORE_NUM); // 100, Set the timeout of runtime
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount, EXIT);
+
+ ret = LOS_SemPost(g_semID); // post sem before 10 ticks timeout
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, LOSCFG_KERNEL_CORE_NUM * 3); // 100, Set the timeout of runtime; LOSCFG_KERNEL_CORE_NUM * 3, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM * 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to
+
+EXIT:
+ for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
+ LOS_TaskDelete(g_sz[i]);
+ }
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem032(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem032", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_033.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_033.c
new file mode 100644
index 0000000000000000000000000000000000000000..d05fca189e0c4d0d09342e6d79cb861d84169946
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_033.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ // other core get the sem first; 2, Here, assert that g_testCount is equal to
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, uvIntSave;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_033_task2", TaskF02, TASK_PRIO_TEST - 1, CPUID_TO_AFFI_MASK(currCpuid));
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); // let the task f02 pend sem first
+
+ TestBusyTaskDelay(10); // let the task f02 todo pend 10, delay enouge time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_033_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+ LOS_TaskLock();
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(200, 3); // 200, Set the timeout of runtime; 3, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, Here, assert that g_testCount is equal to
+
+ ret = LOS_SemPost(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, not schedule in current cpu cause tasklock
+
+ LOS_AtomicInc(&g_testCount);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, Here, assert that g_testCount is equal to
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+EXIT1:
+ LOS_TaskUnlock();
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem033(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem033", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_034.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_034.c
new file mode 100644
index 0000000000000000000000000000000000000000..a01401b8e63f971c8de399a7a5ab2e18ff28cade
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_034.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static volatile UINT32 g_runFlag = 1;
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+ PRINT_DEBUG("task f01 pend begin\n");
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ PRINT_DEBUG("task f01 pend success\n");
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, uvIntSave;
+
+ LOS_AtomicInc(&g_testCount);
+
+ PRINT_DEBUG("task f02 lock\n");
+
+ LOS_TaskLock(); // task lock on other cpu
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_runFlag == 1);
+
+ PRINT_DEBUG("task f02 unlock\n");
+ LOS_TaskUnlock(); // schedule occur ---switch to task f01
+ PRINT_DEBUG("task f02 back\n");
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i;
+ TSK_INIT_PARAM_S testTask;
+
+ g_testCount = 0;
+ g_runFlag = 1;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_034_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_034_task2", TaskF02, TASK_PRIO_TEST,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test runing count
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to
+
+ PRINT_DEBUG("sem post\n");
+ ret = LOS_SemPost(g_semID); // try to wake task f01
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay enough time for other cpu
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to // cause tasklock on other cpu ,so task f01 wake failed
+
+ LOS_AtomicInc(&g_testCount);
+
+ PRINT_DEBUG("try to unlock\n");
+
+ g_runFlag = 0; // unlock the other cpu
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ PRINT_DEBUG("finally\n");
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, Here, assert that g_testCount is equal to // not schedule in current cpu cause tasklock
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem034(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem034", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_035.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_035.c
new file mode 100644
index 0000000000000000000000000000000000000000..d970352d68b324e35c435f461098d43099d7e1fe
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_035.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret, i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ for (i = 0; i < TRandom() % 500; i++) { // Gets a random value of 0-500
+ }
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ LOS_AtomicInc(&g_testCount);
+
+ do {
+ __asm__ volatile("nop");
+ } while (1);
+
+ TestDumpCpuid();
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_035_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 0); // wait for task f01 run
+
+ for (j = 0; j < TRandom() % 500; j++) { // Gets a random value of 0-500
+ }
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ if (ret != LOS_OK && ret != LOS_ERRNO_TSK_MP_SYNC_FAILED) {
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ret = LOS_SemPost(g_semID); // try to wake task f01
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_EQUAL(ret, OS_TASK_STATUS_UNUSED, ret, EXIT);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ }
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem035(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem035", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_036.c b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_036.c
new file mode 100644
index 0000000000000000000000000000000000000000..9730450e0a35c4d32de5ad48adf3d5cfc3e284f8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_base/ipc/sem/smp/It_smp_los_sem_036.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "It_los_sem.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_ret = 0xff;
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+
+ LOS_AtomicInc(&g_testCount);
+
+ ret = LOS_SemPend(g_semID, LOS_WAIT_FOREVER); // pend on current cpu
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+
+static VOID TaskF02(VOID)
+{
+ UINT32 ret, i;
+
+ LOS_AtomicInc(&g_testCount);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 2); // 2, wait for test task
+
+ for (i = 0; i < TRandom() % 100; i++) { // Gets a random value of 0-100
+ }
+
+ ret = LOS_SemPost(g_semID); // try to wake task f01
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ TestDumpCpuid();
+ LOS_AtomicInc(&g_testCount);
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, currCpuid, i, j;
+ TSK_INIT_PARAM_S testTask;
+
+ currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM);
+
+ for (i = 0; i < LOOP; i++) {
+ g_testCount = 0;
+ g_ret = 0xff;
+
+ ret = LOS_SemCreate(0, &g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_event_037_task1", TaskF01, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu
+ ret = LOS_TaskCreate(&g_testTaskID01, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT);
+
+ TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_event_037_task2", TaskF02, TASK_PRIO_TEST - 1,
+ CPUID_TO_AFFI_MASK(currCpuid)); // other cpu
+ ret = LOS_TaskCreate(&g_testTaskID02, &testTask);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ do {
+ __asm__ volatile("nop");
+ } while (g_testCount == 1); // wait for task f02
+
+ LOS_AtomicInc(&g_testCount);
+
+ for (j = 0; j < TRandom() % 500; j++) { // Gets a random value of 0-500
+ }
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ g_ret = ret;
+
+ LOS_TaskDelay(10); // 10, delay enouge time
+
+ ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ PRINT_DEBUG("g_testCount = %d ,g_ret = 0x%x\n", g_testCount, g_ret);
+ if (g_testCount == 4) { // 4, wait for task flag
+ ICUNIT_GOTO_EQUAL(g_ret, LOS_OK, g_ret, EXIT);
+ } else if (g_testCount == 5) { // 5, wait for task flag
+ ICUNIT_GOTO_EQUAL(g_ret, LOS_ERRNO_TSK_NOT_CREATED, g_ret, EXIT);
+ } else {
+ ICUNIT_GOTO_EQUAL(1, 0, g_ret, EXIT);
+ }
+
+ ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus;
+ ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT);
+
+ ret = LOS_SemDelete(g_semID);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ }
+
+EXIT:
+
+ LOS_TaskDelete(g_testTaskID01);
+ LOS_TaskDelete(g_testTaskID02);
+ LOS_SemDelete(g_semID);
+ return LOS_OK;
+}
+
+VOID ItSmpLosSem036(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItSmpLosSem036", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/BUILD.gn b/testsuites/kernel/sample/kernel_extend/cpup/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..124579770a997f2e3b9a411e2fc7c4ee2a7a45a5
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/BUILD.gn
@@ -0,0 +1,21 @@
+static_library("test_cpup") {
+
+ sources = [
+ "It_extend_cpup.c",
+ ]
+
+ if (LOSCFG_TEST_SMOKE) {
+ sources += [
+ "smoke/It_extend_cpup_001.c",
+ "smoke/It_extend_cpup_002.c",
+ ]
+ }
+
+ include_dirs = [
+ "../../../include/",
+ "./",
+ "../../../../kernel/extended/include",
+ ]
+
+ cflags = [ "-Wno-error" ]
+}
\ No newline at end of file
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.c b/testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.c
new file mode 100644
index 0000000000000000000000000000000000000000..f4217d4eab799d44edd5c0e54e63469233f716cb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+UINT32 GetNopCount(void)
+{
+ return LOS_CyclePerTickGet();
+}
+
+#ifdef LOSCFG_CPUP_INCLUDE_IRQ
+
+CPUP_INFO_S g_testPstHwiCpupAll[OS_HWI_MAX_NUM];
+CPUP_INFO_S g_testPstHwiCpup10s[OS_HWI_MAX_NUM];
+CPUP_INFO_S g_testPstHwiCpup1s[OS_HWI_MAX_NUM];
+
+UINT32 TestGetSingleHwiCpup(UINT32 hwi, UINT32 mode)
+{
+ UINT32 size;
+ UINT32 tempHwi;
+ if (hwi < 0 || hwi > OS_HWI_MAX_NUM) {
+ return -1;
+ }
+
+ size = sizeof(CPUP_INFO_S) * LOS_GetSystemHwiMaximum();
+ switch (mode) {
+ case CPUP_LAST_ONE_SECONDS:
+ (VOID)memset_s((VOID *)g_testPstHwiCpup1s, size, 0, size);
+ (VOID)LOS_GetAllIrqCpuUsage(CPUP_LAST_ONE_SECONDS, g_testPstHwiCpup1s, size);
+ tempHwi = g_testPstHwiCpup1s[hwi].usage;
+ break;
+ case CPUP_LAST_TEN_SECONDS:
+ (VOID)memset_s((VOID *)g_testPstHwiCpup10s, size, 0, size);
+ (VOID)LOS_GetAllIrqCpuUsage(CPUP_LAST_TEN_SECONDS, g_testPstHwiCpup10s, size);
+ tempHwi = g_testPstHwiCpup10s[hwi].usage;
+ break;
+ case CPUP_ALL_TIME:
+ /* fall-through */
+ default:
+ (VOID)memset_s((VOID *)g_testPstHwiCpupAll, size, 0, size);
+ (VOID)LOS_GetAllIrqCpuUsage(CPUP_ALL_TIME, g_testPstHwiCpupAll, size);
+ tempHwi = g_testPstHwiCpupAll[hwi].usage;
+ break;
+ }
+ return tempHwi;
+}
+#endif
+
+
+VOID ItSuiteExtendCpup(VOID)
+{
+#if defined(LOSCFG_TEST_SMOKE)
+ ItExtendCpup001();
+ ItExtendCpup002();
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+ ItExtendCpup003();
+ ItExtendCpup004();
+ ItExtendCpup005();
+ ItExtendCpup006();
+ ItExtendCpup007();
+ ItExtendCpup008();
+ ItExtendCpup011();
+ ItExtendCpup012();
+#endif
+
+#if defined(LOSCFG_TEST_LLT)
+ LltExtendCpup003();
+ ItExtendCpup009();
+ ItExtendCpup010();
+#endif
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ ItSmpExtendCpup001();
+ ItSmpExtendCpup002();
+#ifdef LOSCFG_CPUP_INCLUDE_IRQ
+ ItSmpExtendCpup003();
+ ItSmpExtendCpup004();
+#endif
+ ItSmpExtendCpup005();
+ ItSmpExtendCpup007();
+ ItSmpExtendCpup008();
+ ItSmpExtendCpup009();
+ ItSmpExtendCpup010();
+ ItSmpExtendCpup011();
+ ItSmpExtendCpup012();
+#endif
+}
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.h b/testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.h
new file mode 100644
index 0000000000000000000000000000000000000000..7e54b537d8508b7fad44b1160adbc07bcb833d87
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/It_extend_cpup.h
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IT_LOS_CPUP_H
+#define IT_LOS_CPUP_H
+
+#include "los_cpup_pri.h"
+#include "los_cpup.h"
+#include "los_sys.h"
+#include "los_task.h"
+#include "osTest.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+ extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define CPU_USE_MODE1 1
+#define CPU_USE_MODE0 0
+#define CPU_USE_MIN 0
+#define TASK_STATUS_UNDETACHED 0
+
+#define CPUP_TEST_TOLERANT 50
+#define CPUP_BACKWARD 2
+
+#define ICUNIT_ASSERT_PROCESS_CPUP_USAGE(usage, lable) \
+ do { \
+ UINT32 ret_ = LOS_NOK; \
+ if (((usage) > LOS_CPUP_PRECISION) || ((usage) < CPU_USE_MIN)) { \
+ ret_ = LOS_OK; \
+ } else { \
+ ret_ = usage; \
+ } \
+ ICUNIT_GOTO_EQUAL(ret_, LOS_OK, ret_, lable); \
+ } while (0)
+
+#define ICUNIT_ASSERT_SINGLE_CPUP_USAGE(usage, lable) \
+ do { \
+ UINT32 ret_ = LOS_NOK; \
+ if (((usage) > LOS_CPUP_SINGLE_CORE_PRECISION) || ((usage) < CPU_USE_MIN)) { \
+ ret_ = LOS_OK; \
+ } else { \
+ ret_ = usage; \
+ } \
+ ICUNIT_GOTO_EQUAL(ret_, LOS_OK, ret_, lable); \
+ } while (0)
+
+extern UINT32 g_cpuTestTaskID;
+extern UINT32 g_testTaskID01;
+extern UINT32 g_testTaskID02;
+extern UINT32 g_testTaskID03;
+extern UINT32 g_cpupTestCount;
+extern VOID ItSuiteExtendCpup(VOID);
+extern UINT32 TimeClkRead(VOID);
+extern LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdCpup(INT32 argc, CHAR **argv);
+extern LITE_OS_SEC_TEXT_MINOR VOID OsTaskCycleEnd(VOID);
+extern LITE_OS_SEC_TEXT_MINOR UINT64 OsGetCpuCycle(VOID);
+
+extern UINT32 GetNopCount(void);
+#ifdef LOSCFG_CPUP_INCLUDE_IRQ
+extern UINT32 TestGetSingleHwiCpup(UINT32 hwi, UINT32 mode);
+#endif
+
+#if defined(LOSCFG_TEST_SMOKE)
+VOID ItExtendCpup001(VOID);
+VOID ItExtendCpup002(VOID);
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+VOID ItExtendCpup003(VOID);
+VOID ItExtendCpup004(VOID);
+VOID ItExtendCpup005(VOID);
+VOID ItExtendCpup006(VOID);
+VOID ItExtendCpup007(VOID);
+VOID ItExtendCpup008(VOID);
+VOID ItExtendCpup011(VOID);
+VOID ItExtendCpup012(VOID);
+#endif
+
+#if defined(LOSCFG_TEST_LLT)
+VOID LLT_EXTEND_CPUP_001(VOID);
+VOID LLT_EXTEND_CPUP_002(VOID);
+VOID LltExtendCpup003(VOID);
+VOID LLT_EXTEND_CPUP_006(VOID);
+VOID LLT_EXTEND_CPUP_007(VOID);
+VOID ItExtendCpup009(VOID);
+VOID ItExtendCpup010(VOID);
+#endif
+
+#if (LOSCFG_KERNEL_SMP == YES)
+VOID ItSmpExtendCpup001(VOID);
+VOID ItSmpExtendCpup002(VOID);
+#ifdef LOSCFG_CPUP_INCLUDE_IRQ
+VOID ItSmpExtendCpup003(VOID);
+VOID ItSmpExtendCpup004(VOID);
+#endif
+VOID ItSmpExtendCpup005(VOID);
+VOID ItSmpExtendCpup006(VOID);
+VOID ItSmpExtendCpup007(VOID);
+VOID ItSmpExtendCpup008(VOID);
+VOID ItSmpExtendCpup009(VOID);
+VOID ItSmpExtendCpup010(VOID);
+VOID ItSmpExtendCpup011(VOID);
+VOID ItSmpExtendCpup012(VOID);
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#endif
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/Makefile b/testsuites/kernel/sample/kernel_extend/cpup/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..dd4b11d9bdbc24b55f20039ee8866cb4ac4b0378
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/Makefile
@@ -0,0 +1,40 @@
+
+include $(LITEOSTESTTOPDIR)/config.mk
+
+MODULE_NAME := cpuptest
+
+LOCAL_INCLUDE := \
+ -I $(LITEOSTESTTOPDIR)/kernel/include \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/kernel_extend/cpup \
+ -I $(LITEOSTOPDIR)/kernel/extended/include/
+
+SRC_MODULES := .
+
+ifeq ($(LOSCFG_KERNEL_SMP), y)
+SMP_MODULES := smp
+endif
+
+ifeq ($(LOSCFG_TEST_LLT), y)
+LLT_MODULES := llt
+endif
+
+ifeq ($(LOSCFG_TEST_PRESSURE), y)
+PRESSURE_MODULES := pressure
+endif
+
+ifeq ($(LOSCFG_TEST_SMOKE), y)
+SMOKE_MODULES := smoke
+endif
+
+ifeq ($(LOSCFG_TEST_FULL), y)
+FULL_MODULES := full
+endif
+
+LOCAL_MODULES := $(SRC_MODULES) $(SMOKE_MODULES) $(FULL_MODULES) $(SMP_MODULES) $(LLT_MODULES)
+
+LOCAL_SRCS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.c))
+LOCAL_CHS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.h))
+
+LOCAL_FLAGS := $(LOCAL_INCLUDE) -Wno-error
+
+include $(MODULE)
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_003.c b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..cffe4dba6093bf06b3eda23257085d6d4731a6cd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_003.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 TaskF02(VOID)
+{
+ UINT32 cpupUse, ret;
+ g_testTaskID02 = LOS_GetCurrProcessID();
+
+ ret = LOS_SetProcessPriority(g_testTaskID02, TASK_PRIO_TEST - 1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 2, g_cpupTestCount); // 2, Here, assert that g_cpupTestCount is equal to the expected value.
+ g_cpupTestCount++;
+ cpupUse = LOS_HistoryProcessCpuUsage(g_testTaskID01, CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ cpupUse = LOS_HistoryProcessCpuUsage(g_testTaskID02, CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ LOS_TaskDelay(3); // 3, set delay time.
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 4, g_cpupTestCount); // 4, Here, assert that g_cpupTestCount is equal to the expected value.
+ g_cpupTestCount++;
+
+ return LOS_OK;
+
+EXIT:
+ return ret;
+}
+
+static UINT32 TaskF01(VOID)
+{
+ UINT32 cpupUse, ret;
+ g_testTaskID01 = LOS_GetCurrProcessID();
+
+ // 2, used to calculate the task priority.
+ ret = LOS_SetProcessPriority(g_testTaskID01, TASK_PRIO_TEST - 2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 0, g_cpupTestCount);
+ g_cpupTestCount++;
+
+ cpupUse = LOS_HistorySysCpuUsage(CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ LOS_TaskDelay(4); // 4, set delay time.
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 3, g_cpupTestCount); // 3, Here, assert that g_cpupTestCount is equal to the expected value.
+ g_cpupTestCount++;
+
+ return LOS_OK;
+
+EXIT:
+ return ret;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, cpupUse;
+ INT32 pid1;
+
+ g_cpupTestCount = 0;
+ INT32 pid = LOS_Fork(0, "TestCpupTsk1", TaskF01, TASK_STACK_SIZE_TEST);
+ if (pid < 0) {
+ ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
+ }
+
+ LOS_TaskDelay(2); // 2, set delay time.
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 1, g_cpupTestCount);
+ g_cpupTestCount++;
+
+ pid1 = LOS_Fork(0, "TestCpupTsk2", TaskF02, TASK_STACK_SIZE_TEST);
+ if (pid1 < 0) {
+ ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
+ }
+
+ LOS_TaskDelay(2); // 2, set delay time.
+
+ cpupUse = LOS_HistorySysCpuUsage(CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+ LOS_TaskDelay(3); // 3, set delay time.
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 5, g_cpupTestCount); // 5, Here, assert that g_cpupTestCount is equal to the expected value.
+
+ (VOID)LOS_Wait(pid, NULL, 0, NULL);
+ (VOID)LOS_Wait(pid1, NULL, 0, NULL);
+
+ return LOS_OK;
+EXIT:
+ return ret;
+}
+
+VOID ItExtendCpup003(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItExtendCpup003", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_004.c b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..98cb5671056168ba6a14531e29d6cfb292ca23b4
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_004.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 TaskF02(VOID)
+{
+ UINT32 cpupUse, ret;
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 2, g_cpupTestCount); // 2, Here, assert that g_cpupTestCount is equal to the expected value.
+ g_cpupTestCount++;
+
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return ret;
+}
+
+static UINT32 TaskF01(VOID)
+{
+ UINT32 ret, cpupUse;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "TestCpupTsk2";
+ task1.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+ task1.uwResved = TASK_STATUS_UNDETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 0, g_cpupTestCount);
+ g_cpupTestCount++;
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 1, g_cpupTestCount);
+ g_cpupTestCount++;
+
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ return ret;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, cpupUse;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "TestCpupTsk1";
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+ task1.uwResved = TASK_STATUS_UNDETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_cpupTestCount = 0;
+
+ cpupUse = LOS_HistorySysCpuUsage(CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 3, g_cpupTestCount); // 3, Here, assert that g_cpupTestCount is equal to the expected value.
+ g_cpupTestCount++;
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+
+EXIT:
+ return ret;
+}
+
+VOID ItExtendCpup004(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItExtendCpup004", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_005.c b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..b47ac53646b371addd83f23fbbbaa8119d2300d8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_005.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 TaskF01(VOID)
+{
+ UINT32 cpupUse, ret;
+ g_cpupTestCount++;
+
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPU_USE_MODE1);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID01);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return ret;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "TskTst1";
+ task1.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+ task1.uwResved = TASK_STATUS_UNDETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_cpupTestCount = 0;
+
+ LOS_TaskLock();
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 0, g_cpupTestCount);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 1, g_cpupTestCount); // 1, Here, assert that g_cpupTestCount is equal to the expected value.
+
+ return LOS_OK;
+}
+
+VOID ItExtendCpup005(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItExtendCpup005", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_006.c b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..e90de96d4881bfeeb971d5e3fb9a42470775a3fd
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_006.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 TaskF02(VOID)
+{
+ UINT32 ret, cpupUse;
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 2, g_cpupTestCount); // 2, Here, assert that g_cpupTestCount is equal to the expected value.
+ g_cpupTestCount++;
+
+ cpupUse = LOS_HistoryProcessCpuUsage(g_testTaskID01, CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return LOS_OK;
+
+EXIT:
+ ret = LOS_TaskDelete(g_testTaskID02);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+ return ret;
+}
+
+static VOID TaskF01(VOID)
+{
+ UINT32 ret;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "TskTst2";
+ task1.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+ task1.uwResved = TASK_STATUS_UNDETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ICUNIT_ASSERT_EQUAL_VOID(g_cpupTestCount, 0, g_cpupTestCount);
+ g_cpupTestCount++;
+
+ g_testTaskID01 = LOS_GetCurrProcessID();
+
+ ret = LOS_GetTaskScheduler(LOS_CurTaskIDGet());
+ // 2, used to calculate the task priority.
+ ret = LOS_SetTaskScheduler(LOS_CurTaskIDGet(), ret, TASK_PRIO_TEST - 2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
+
+ ret = LOS_TaskCreate(&g_testTaskID02, &task1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_cpupTestCount, 1, g_cpupTestCount);
+ g_cpupTestCount++;
+
+ LOS_TaskDelay(30); // 30, set delay time.
+
+ ICUNIT_ASSERT_EQUAL_VOID(g_cpupTestCount, 3, g_cpupTestCount); // 3, Here, assert that g_cpupTestCount is equal to the expected value.
+ g_cpupTestCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, cpupUse;
+ TSK_INIT_PARAM_S task1 = { 0 };
+
+ cpupUse = LOS_HistorySysCpuUsage(CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "TskTst1";
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+ task1.uwResved = TASK_STATUS_UNDETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_cpupTestCount = 0;
+ INT32 pid = LOS_Fork(0, "TestCpupTsk1", TaskF01, TASK_STACK_SIZE_TEST);
+ if (pid < 0) {
+ ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
+ }
+
+ ret = LOS_Wait(pid, NULL, 0, NULL);
+ ICUNIT_ASSERT_EQUAL(pid, ret, pid);
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 4, g_cpupTestCount); // 4, Here, assert that g_cpupTestCount is equal to the expected value.
+
+ cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ return ret;
+}
+
+VOID ItExtendCpup006(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItExtendCpup006", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_007.c b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..75e64592c1479cfc3c96d9459f2e40118777888e
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_007.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, cpupUse;
+
+ cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE0);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ // 2, used to test history func.
+ cpupUse = LOS_HistorySysCpuUsage(-2);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ cpupUse = LOS_HistorySysCpuUsage(0xFFFF);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ return LOS_OK;
+}
+
+VOID ItExtendCpup007(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItExtendCpup007", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_008.c b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..86e9e7926aefa8a22e02f53b7d3b0ae59ab30a21
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_008.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 TaskF01(VOID)
+{
+ UINT32 cpupUse, ret;
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 0, g_cpupTestCount);
+ g_cpupTestCount++;
+
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ cpupUse = LOS_HistoryProcessCpuUsage(g_taskMaxNum, CPUP_ALL_TIME);
+ ICUNIT_GOTO_NOT_EQUAL(cpupUse, LOS_OK, cpupUse, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 1, g_cpupTestCount);
+ g_cpupTestCount++;
+
+ return LOS_OK;
+EXIT:
+ return ret;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret, cpupUse;
+ TSK_INIT_PARAM_S task1 = { 0 };
+ task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
+ task1.uwStackSize = TASK_STACK_SIZE_TEST;
+ task1.pcName = "TestCpupTsk1";
+ task1.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+ task1.uwResved = TASK_STATUS_UNDETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ g_cpupTestCount = 0;
+
+ ret = LOS_TaskCreate(&g_testTaskID01, &task1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_cpupTestCount, 2, g_cpupTestCount); // 2, Here, assert that g_cpupTestCount is equal to the expected value.
+EXIT:
+ LOS_TaskDelete(g_testTaskID01);
+ return LOS_OK;
+}
+
+VOID ItExtendCpup008(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItExtendCpup008", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_011.c b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..baf3df0ac14cb1f099cf59257fb5c3adc66b3272
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_011.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 loop;
+ UINT32 ret, cpupUse;
+ UINT32 systemProcessNumber = LOS_GetSystemProcessMaximum();
+ UINT32 cpupInfoLen;
+ CPUP_INFO_S *cpup = NULL;
+
+#ifdef LOSCFG_CPUP_INCLUDE_IRQ
+ UINT32 systemIrqNumber = LOS_GetSystemHwiMaximum();
+ cpupInfoLen = systemIrqNumber * sizeof(CPUP_INFO_S);
+ cpup = (CPUP_INFO_S *)LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, cpupInfoLen);
+ if (cpup == NULL) {
+ PRINTK("%s[%d] malloc failure!\n", __FUNCTION__, __LINE__);
+ return OS_ERROR;
+ }
+
+ ret = LOS_GetAllIrqCpuUsage(CPUP_LAST_ONE_SECONDS, cpup, cpupInfoLen);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ for (loop = 0; loop < systemIrqNumber; loop++) {
+ ICUNIT_ASSERT_SINGLE_CPUP_USAGE(cpup[loop].usage, EXIT1);
+ }
+
+ ret = LOS_GetAllIrqCpuUsage(CPUP_LAST_TEN_SECONDS, cpup, cpupInfoLen);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ for (loop = 0; loop < systemIrqNumber; loop++) {
+ ICUNIT_ASSERT_SINGLE_CPUP_USAGE(cpup[loop].usage, EXIT1);
+ }
+
+ ret = LOS_GetAllIrqCpuUsage(CPUP_ALL_TIME, cpup, cpupInfoLen);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ for (loop = 0; loop < systemIrqNumber; loop++) {
+ ICUNIT_ASSERT_SINGLE_CPUP_USAGE(cpup[loop].usage, EXIT1);
+ }
+
+ LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, cpup);
+ cpup = NULL;
+#endif
+
+ cpupInfoLen = systemProcessNumber * sizeof(CPUP_INFO_S);
+ cpup = (CPUP_INFO_S *)LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, cpupInfoLen);
+ if (cpup == NULL) {
+ PRINTK("%s[%d] malloc failure!\n", __FUNCTION__, __LINE__);
+ return OS_ERROR;
+ }
+
+ ret = LOS_GetAllProcessCpuUsage(CPUP_LAST_ONE_SECONDS, cpup, cpupInfoLen);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ for (loop = 0; loop < systemProcessNumber; loop++) {
+ ICUNIT_ASSERT_PROCESS_CPUP_USAGE(cpup[loop].usage, EXIT1);
+ }
+
+ ret = LOS_GetAllProcessCpuUsage(CPUP_LAST_TEN_SECONDS, cpup, cpupInfoLen);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ for (loop = 0; loop < systemProcessNumber; loop++) {
+ ICUNIT_ASSERT_PROCESS_CPUP_USAGE(cpup[loop].usage, EXIT1);
+ }
+
+ ret = LOS_GetAllProcessCpuUsage(CPUP_ALL_TIME, cpup, cpupInfoLen);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ for (loop = 0; loop < systemProcessNumber; loop++) {
+ ICUNIT_ASSERT_PROCESS_CPUP_USAGE(cpup[loop].usage, EXIT1);
+ }
+
+ LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, cpup);
+ cpup = NULL;
+
+EXIT1:
+ LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, cpup);
+ cpup = NULL;
+ return LOS_OK;
+}
+
+VOID ItExtendCpup011(VOID)
+{
+ TEST_ADD_CASE("ItExtendCpup011", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_012.c b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..cc44dee3db0f68988d7626359c398630fff65b54
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/full/It_extend_cpup_012.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, val) \
+ do { \
+ if ((cpupUse) > LOS_CPUP_SINGLE_CORE_PRECISION || (cpupUse) < CPU_USE_MIN) { \
+ ICUNIT_ASSERT_EQUAL(cpupUse, val, cpupUse); \
+ } \
+ } while (0)
+
+static INT32 TaskF01(VOID)
+{
+ INT32 testCount = 1000; // 1000, set to init testcount.
+ UINT32 cpupUse;
+ LOS_Mdelay(5000); // 5000, set delay time.
+
+ const CHAR *taskAll = "-a";
+ OsShellCmdDumpTask(1, &taskAll);
+
+ while (testCount > 0) {
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_LAST_TEN_SECONDS);
+ ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_LAST_ONE_SECONDS);
+ ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
+
+ cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
+ if ((cpupUse > LOS_CPUP_PRECISION) || (cpupUse < CPU_USE_MIN)) {
+ ICUNIT_ASSERT_EQUAL(cpupUse, OS_INVALID_VALUE, cpupUse);
+ }
+
+ testCount--;
+ }
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
+ ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
+
+ LOS_CpupReset();
+ LOS_Mdelay(5000); // 5000, set delay time.
+
+ testCount = 1000; // 1000, set to init testcount.
+ while (testCount > 0) {
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_LAST_TEN_SECONDS);
+ ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_LAST_ONE_SECONDS);
+ ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
+
+ cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
+ if ((cpupUse > LOS_CPUP_PRECISION) || (cpupUse < CPU_USE_MIN)) {
+ ICUNIT_ASSERT_EQUAL(cpupUse, OS_INVALID_VALUE, cpupUse);
+ }
+ testCount--;
+ }
+
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPUP_ALL_TIME);
+ ICUNIT_ASSERT_CPUP_EQUAL(cpupUse, OS_INVALID_VALUE);
+
+ OsShellCmdDumpTask(1, &taskAll);
+
+EXIT:
+ return 0;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 pid = LOS_Fork(0, "TestCpupProcess", TaskF01, TASK_STACK_SIZE_TEST);
+ if (pid < 0) {
+ ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
+ }
+
+ LOS_Wait(pid, 0, 0, 0);
+
+ return LOS_OK;
+}
+
+VOID ItExtendCpup012(VOID)
+{
+ TEST_ADD_CASE("ItExtendCpup012", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smoke/It_extend_cpup_001.c b/testsuites/kernel/sample/kernel_extend/cpup/smoke/It_extend_cpup_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..41589d15c9673405b47489719a481b852bef936a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smoke/It_extend_cpup_001.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 TaskF02(VOID)
+{
+ UINT32 ret, cpupUse;
+ g_cpupTestCount++;
+ // 2, Here, assert that g_cpupTestCount is equal to the expected value.
+ ICUNIT_GOTO_EQUAL(g_cpupTestCount, 2, g_cpupTestCount, EXIT);
+ cpupUse = LOS_HistoryProcessCpuUsage(g_testTaskID01, CPUP_ALL_TIME);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_cpupTestCount++;
+ return LOS_OK;
+
+EXIT:
+ return ret;
+}
+
+static UINT32 TaskF01(VOID)
+{
+ UINT32 ret;
+ INT32 pid;
+ g_cpupTestCount++;
+ g_testTaskID01 = LOS_GetCurrProcessID();
+
+ pid = LOS_Fork(0, "TestCpupTsk2", TaskF02, LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE);
+ if (pid < 0) {
+ ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
+ }
+
+ LOS_TaskDelay(10); // 10, set delay time.
+ g_cpupTestCount++;
+ (VOID)LOS_Wait(pid, NULL, 0, NULL);
+ return LOS_OK;
+
+EXIT:
+ return ret;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 pid;
+ UINT32 ret, cpupUse;
+ g_cpupTestCount = 0;
+
+ cpupUse = LOS_HistorySysCpuUsage(CPUP_ALL_TIME);
+
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ pid = LOS_Fork(0, "TestCpupTsk", TaskF01, LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE);
+ if (pid < 0) {
+ ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
+ }
+
+ LOS_TaskDelay(10); // 10, set delay time.
+ (VOID)LOS_Wait(pid, NULL, 0, NULL);
+ return LOS_OK;
+}
+
+
+VOID ItExtendCpup001(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItExtendCpup001", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smoke/It_extend_cpup_002.c b/testsuites/kernel/sample/kernel_extend/cpup/smoke/It_extend_cpup_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..1096be00b75e46222cfdfd7aa9b24b39f9b71c20
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smoke/It_extend_cpup_002.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 TaskF01(VOID)
+{
+ UINT32 ret;
+ UINT32 cpupUse;
+ g_cpupTestCount++;
+ ICUNIT_GOTO_EQUAL(g_cpupTestCount, 1, g_cpupTestCount, EXIT);
+
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPU_USE_MODE0);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPU_USE_MODE1);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ cpupUse = LOS_HistoryProcessCpuUsage(LOS_GetCurrProcessID(), CPU_USE_MODE1);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ return ret;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 pid;
+ UINT32 ret, cpupUse;
+ g_cpupTestCount = 0;
+
+ pid = LOS_Fork(0, "TestCpupTsk", TaskF01, LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE);
+ if (pid < 0) {
+ ICUNIT_ASSERT_EQUAL(1, LOS_OK, 1);
+ }
+
+ cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE0);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ cpupUse = LOS_HistorySysCpuUsage(CPU_USE_MODE1);
+ if (cpupUse > LOS_CPUP_PRECISION || cpupUse < CPU_USE_MIN) {
+ ret = LOS_NOK;
+ } else {
+ ret = LOS_OK;
+ }
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = LOS_Wait(pid, NULL, 0, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+ return LOS_OK;
+}
+
+VOID ItExtendCpup002(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItExtendCpup002", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL0, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_001.c b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..d72a879b7a8ebf1c1b0eeea6c068d515af6e4a9c
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_001.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
+static volatile UINT32 g_testSmpCpupStop = 0;
+static void Task01(void)
+{
+ while (g_testSmpCpupStop < 1) {
+ __asm__ volatile("nop");
+ }
+ return;
+}
+static void Task02(void)
+{
+ UINT32 tempCpup;
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+ tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
+ ICUNIT_GOTO_WITHIN_EQUAL(tempCpup, LOS_CPUP_SINGLE_CORE_PRECISION - CPUP_TEST_TOLERANT,
+ LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup, EXIT2);
+
+EXIT2:
+ g_testSmpCpupStop = 1;
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+ tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
+ ICUNIT_ASSERT_EQUAL_VOID(tempCpup, CPU_USE_MIN, tempCpup);
+
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup001_task01";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* make sure that created test task is definitely on another core */
+ UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup001_task02";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD * 2 + 1)); // 2, used to calculate the delay time.
+
+EIXT1:
+ LOS_TaskDelete(g_testSmpCpupTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItSmpExtendCpup001(VOID)
+{
+ TEST_ADD_CASE("ItSmpExtendCpup001", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_002.c b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..a05abf00399810d8473c389a1bb399f96b439539
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_002.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testSmpCpupTaskID01;
+
+static void Task01(void)
+{
+ UINT32 tempCpup;
+ /* make sure that created test task is definitely on another core */
+ UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+ UINT32 idleID = g_percpu[currCpuid].idleTaskID;
+ TSK_INFO_S tempTaskInfo;
+
+ do {
+ LOS_TaskInfoGet(idleID, &tempTaskInfo);
+ } while (!(tempTaskInfo.usTaskStatus & OS_TASK_STATUS_RUNNING));
+
+ tempCpup = LOS_HistoryTaskCpuUsage(idleID, CPUP_ALL_TIME);
+ ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup, CPU_USE_MIN, LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup);
+
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup002_task01";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND);
+
+EXIT:
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItSmpExtendCpup002(VOID)
+{
+ TEST_ADD_CASE("ItSmpExtendCpup002", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_003.c b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..4b476b9a4c7444c5c1bd1beedbc0bf5fe64f34c2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_003.c
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#ifdef LOSCFG_CPUP_INCLUDE_IRQ
+static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
+static volatile UINT32 g_testSmpCpupStop = 0;
+static void HwiF01(void)
+{
+ UINT32 i;
+ UINT32 count = GetNopCount();
+ for (i = 0; i < count; i++) {
+ __asm__ volatile("nop");
+ }
+}
+static void Task01(void)
+{
+ UINT32 ret;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ while (g_testSmpCpupStop < 1) {
+ TestHwiTrigger(HWI_NUM_TEST);
+ }
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(0));
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return;
+}
+static void Task02(void)
+{
+ UINT32 tempCpup;
+
+ tempCpup = TestGetSingleHwiCpup(HWI_NUM_TEST, CPUP_LAST_ONE_SECONDS);
+ ICUNIT_ASSERT_EQUAL_VOID(tempCpup, CPU_USE_MIN, tempCpup);
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+ tempCpup = TestGetSingleHwiCpup(HWI_NUM_TEST, CPUP_LAST_ONE_SECONDS);
+ // 2, used to calculate the input of equal func.
+ ICUNIT_GOTO_WITHIN_EQUAL(tempCpup, LOS_CPUP_SINGLE_CORE_PRECISION / 2, LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup,
+ EXIT2);
+
+EXIT2:
+ g_testSmpCpupStop = 1;
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+ tempCpup = TestGetSingleHwiCpup(HWI_NUM_TEST, CPUP_LAST_ONE_SECONDS);
+ ICUNIT_ASSERT_EQUAL_VOID(tempCpup, CPU_USE_MIN, tempCpup);
+
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup003_task01";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* make sure that created test task is definitely on another core */
+ UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup003_task02";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD * 2 + 1)); // 2, used to calculate the delay time.
+
+EIXT1:
+ LOS_TaskDelete(g_testSmpCpupTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+
+ return LOS_OK;
+}
+#endif
+
+VOID ItSmpExtendCpup003(VOID)
+{
+#ifdef LOSCFG_CPUP_INCLUDE_IRQ
+ TEST_ADD_CASE("ItSmpExtendCpup003", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+#endif
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_004.c b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..1fecac727534f6c2757c6e9b4355a2eb7547aee2
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_004.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#ifdef LOSCFG_CPUP_INCLUDE_IRQ
+static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
+static volatile UINT32 g_testSmpCpupStop = 0;
+static HwiIrqParam g_dev1, g_dev2;
+static void HwiF01(void)
+{
+ UINT32 i;
+ // 2, used to calculate the conut num.
+ UINT32 count = GetNopCount() / 2;
+ for (i = 0; i < count; i++) {
+ __asm__ volatile("nop");
+ }
+}
+static void HwiF02(void)
+{
+ UINT32 i;
+ // 2, used to calculate the conut num.
+ UINT32 count = GetNopCount() / 2;
+ for (i = 0; i < count; i++) {
+ __asm__ volatile("nop");
+ }
+}
+
+static void Task01(void)
+{
+ UINT32 ret;
+ g_dev1.pDevId = (void *)1;
+ g_dev1.swIrq = HWI_NUM_TEST;
+ // 3, used to set the hwi priority.
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF01, &g_dev1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ g_dev2.pDevId = (void *)2; // 2, used to set the dev ID.
+ g_dev2.swIrq = HWI_NUM_TEST;
+ // 3, used to set the hwi priority.
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 3, IRQF_SHARED, (HWI_PROC_FUNC)HwiF02, &g_dev2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid()));
+
+ while (g_testSmpCpupStop < 1) {
+ TestHwiTrigger(HWI_NUM_TEST);
+ }
+
+ HalIrqSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(0));
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev1);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ ret = LOS_HwiDelete(HWI_NUM_TEST, &g_dev2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+
+ return;
+}
+static void Task02(void)
+{
+ UINT32 tempCpup;
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+ tempCpup = TestGetSingleHwiCpup(HWI_NUM_TEST, CPUP_LAST_ONE_SECONDS);
+ // 2, used to calculate the input of equal func.
+ ICUNIT_GOTO_WITHIN_EQUAL(tempCpup, LOS_CPUP_SINGLE_CORE_PRECISION / 2, LOS_CPUP_PRECISION, tempCpup, EXIT2);
+
+EXIT2:
+ g_testSmpCpupStop = 1;
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+ tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
+ ICUNIT_ASSERT_EQUAL_VOID(tempCpup, CPU_USE_MIN, tempCpup);
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup004_task01";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* make sure that created test task is definitely on another core */
+ UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup004_task02";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD * 2 + 1)); // 2, used to calculate the delay time.
+
+EIXT1:
+ LOS_TaskDelete(g_testSmpCpupTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+
+ return LOS_OK;
+}
+#endif
+
+VOID ItSmpExtendCpup004(VOID)
+{
+#ifdef LOSCFG_CPUP_INCLUDE_IRQ
+ TEST_ADD_CASE("ItSmpExtendCpup004", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+#endif
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_005.c b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..6b24738408e51bd668fc6482849073e0774d02bf
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_005.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02, g_testSmpCpupTaskID03, g_testSmpCpupTaskID04;
+static volatile UINT32 g_testSmpCpupStop = 0;
+static volatile UINT32 g_testSmpCpupCount = 0;
+
+static void Task03(void)
+{
+ while (g_testSmpCpupStop < 1) {
+ g_testSmpCpupCount++;
+ LOS_TaskYield();
+ }
+ return;
+}
+static void Task04(void)
+{
+ while (g_testSmpCpupStop < 1) {
+ g_testSmpCpupCount++;
+ LOS_TaskYield();
+ }
+ return;
+}
+
+static void Task01(void)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task03;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup005_task03";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID03, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task04;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup005_task04";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID04, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ while (g_testSmpCpupStop < 1) {
+ g_testSmpCpupCount++;
+ LOS_TaskYield();
+ }
+
+ // 2, the g_testSmpCpupStop possible values.
+ while (g_testSmpCpupStop < 2) {
+ // 4, used to calculate the delay time.
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND / 4);
+ }
+EXIT3:
+ LOS_TaskDelete(g_testSmpCpupTaskID04);
+EXIT2:
+ LOS_TaskDelete(g_testSmpCpupTaskID03);
+ return;
+}
+static void Task02(void)
+{
+ UINT32 tempCpup, tempCpup1, tempCpup2, tempCpup3;
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+ tempCpup1 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
+ tempCpup2 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID03, CPUP_LAST_ONE_SECONDS);
+ tempCpup3 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID04, CPUP_LAST_ONE_SECONDS);
+ tempCpup = tempCpup1 + tempCpup2 + tempCpup3;
+ ICUNIT_GOTO_WITHIN_EQUAL(tempCpup, LOS_CPUP_SINGLE_CORE_PRECISION - CPUP_TEST_TOLERANT,
+ LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup, EXIT3);
+
+EXIT3:
+ g_testSmpCpupStop = 1;
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+ tempCpup1 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
+ tempCpup2 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID03, CPUP_LAST_ONE_SECONDS);
+ tempCpup3 = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID04, CPUP_LAST_ONE_SECONDS);
+ tempCpup = tempCpup1 + tempCpup2 + tempCpup3;
+ ICUNIT_GOTO_WITHIN_EQUAL(tempCpup, CPU_USE_MIN, CPU_USE_MIN + CPUP_TEST_TOLERANT, tempCpup, EXIT2);
+
+EXIT2:
+ // 2, set the g_testSmpCpupStop possible values.
+ g_testSmpCpupStop = 2;
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup005_task01";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* make sure that created test task is definitely on another core */
+ UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup005_task02";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD * 3 + 1)); // 3, used to calculate the delay time.
+
+EIXT1:
+ LOS_TaskDelete(g_testSmpCpupTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItSmpExtendCpup005(VOID)
+{
+ TEST_ADD_CASE("ItSmpExtendCpup005", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_007.c b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..6f59678855a841c2b91b46194c9588d803f5dfbb
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_007.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
+static void Task01(void)
+{
+ // 2, set delay time.
+ LOS_TaskDelay(2);
+
+ return;
+}
+static void Task02(void)
+{
+ UINT32 tempCpup[2];
+ UINT32 index = 0x00000001;
+
+ do {
+ index ^= 0x00000001;
+ tempCpup[index] = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_ALL_TIME);
+ } while (!(LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x00) & tempCpup[index]));
+ ICUNIT_ASSERT_EQUAL_VOID(tempCpup[index], LOS_ERRNO_CPUP_NO_CREATED, tempCpup[index]);
+
+ index ^= 0x00000001;
+ ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup[index], CPU_USE_MIN, LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup[index]);
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup007_task01";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+ taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* make sure that created test task is definitely on another core */
+ UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup007_task02";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1;
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
+
+ // 10, set delay time.
+ LOS_TaskDelay(10);
+
+EIXT1:
+ LOS_TaskDelete(g_testSmpCpupTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItSmpExtendCpup007(VOID)
+{
+ TEST_ADD_CASE("ItSmpExtendCpup007", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_008.c b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..3be498fc367c5a51534dc67c17d4b1de2330a6ad
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_008.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
+static void Task01(void)
+{
+ // 2, set delay time.
+ LOS_TaskDelay(2);
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+ return;
+}
+static void Task02(void)
+{
+ UINT32 tempCpup[2];
+ UINT32 index = 0x00000001;
+
+ do {
+ index ^= 0x00000001;
+ tempCpup[index] = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_ALL_TIME);
+ } while (!(LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x00) & tempCpup[index]));
+ ICUNIT_ASSERT_EQUAL_VOID(tempCpup[index], LOS_ERRNO_CPUP_NO_CREATED, tempCpup[index]);
+
+ index ^= 0x00000001;
+ ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup[index], CPU_USE_MIN, LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup[index]);
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup008_task01";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* make sure that created test task is definitely on another core */
+ UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup008_task02";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
+ // 10, set delay time.
+ LOS_TaskDelay(10);
+
+EIXT1:
+ LOS_TaskDelete(g_testSmpCpupTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItSmpExtendCpup008(VOID)
+{
+ TEST_ADD_CASE("ItSmpExtendCpup008", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_009.c b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..d64b84861ec4d7fb81814a79cd1141ce513c4101
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_009.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02, g_testSmpCpupTaskID03;
+
+static void Task03(void)
+{
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+ return;
+}
+
+static void Task01(void)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task03;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup009_task03";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+ taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID03, &taskInitParam);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
+ // 2, set delay time.
+ LOS_TaskDelay(2);
+ LOS_TaskDelete(g_testSmpCpupTaskID03);
+
+ return;
+}
+
+static void Task02(void)
+{
+ UINT32 tempCpup[2] = {0};
+ UINT32 index = 0x00000001;
+
+ do {
+ index ^= 0x00000001;
+ tempCpup[index] = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID03, CPUP_ALL_TIME);
+ } while (!(LOS_ERRNO_OS_ERROR(LOS_MOD_SYS, 0x00) & tempCpup[index]));
+ ICUNIT_ASSERT_EQUAL_VOID(tempCpup[index], LOS_ERRNO_CPUP_NO_CREATED, tempCpup[index]);
+
+ index ^= 0x00000001;
+ ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup[index], CPU_USE_MIN, LOS_CPUP_SINGLE_CORE_PRECISION, tempCpup[index]);
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup009_task01";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+ taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* make sure that created test task is definitely on another core */
+ UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup009_task02";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD + 1));
+
+EIXT1:
+ LOS_TaskDelete(g_testSmpCpupTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItSmpExtendCpup009(VOID)
+{
+ TEST_ADD_CASE("ItSmpExtendCpup009", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_010.c b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..d20373383587907d55046ae352407d74abecccf8
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_010.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
+static volatile UINT32 g_testSmpCpupStop = 0;
+
+static void Task01(void)
+{
+ UINT32 i;
+
+ // 2, set delay time.
+ LOS_TaskDelay(2);
+ LOS_CpupReset();
+ g_testSmpCpupStop = 1;
+
+ return;
+}
+
+static void Task02(void)
+{
+ UINT32 tempCpup;
+
+ do {
+ tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_ALL_TIME);
+ } while ((!(LOS_ERRNO_OS_ERROR(LOS_MOD_CPUP, 0x00) & tempCpup)) && (g_testSmpCpupStop != 1));
+ ICUNIT_ASSERT_EQUAL_VOID(tempCpup, LOS_ERRNO_CPUP_NO_INIT, tempCpup);
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup001_task01";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+ taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* make sure that created test task is definitely on another core */
+ UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup001_task02";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
+
+ // 10, set delay time.
+ LOS_TaskDelay(10);
+
+EIXT1:
+ LOS_TaskDelete(g_testSmpCpupTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItSmpExtendCpup010(VOID)
+{
+ TEST_ADD_CASE("ItSmpExtendCpup010", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_011.c b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..b572f834ad5db0db3c637755cf2f2a9995eb278a
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_011.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
+static volatile UINT32 g_testSmpCpupStop = 0;
+static CPUP_INFO_S g_psttaskcpup1st[LOSCFG_BASE_CORE_TSK_LIMIT];
+static UINT32 StatisticsTaskCpup(CPUP_INFO_S *taskCpup)
+{
+ UINT32 i;
+ UINT32 tmpCpup = 0;
+ for (i = 0; i < LOSCFG_BASE_CORE_TSK_LIMIT; i++) {
+ tmpCpup += taskCpup[i].usage;
+ }
+ return tmpCpup;
+}
+
+static void Task01(void)
+{
+ while (g_testSmpCpupStop < 1) {
+ __asm__ volatile("nop");
+ }
+
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+
+ return;
+}
+
+static void Task02(void)
+{
+ UINT32 tempCpup;
+ UINT32 ret;
+ UINT32 cpupBeforeDel;
+ TSK_INFO_S tempTaskInfo;
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+ cpupBeforeDel = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
+ // 2, used to calculate the input of equal func.
+ ICUNIT_GOTO_WITHIN_EQUAL(cpupBeforeDel, LOS_CPUP_SINGLE_CORE_PRECISION / 2, LOS_CPUP_SINGLE_CORE_PRECISION,
+ cpupBeforeDel, EXIT2);
+
+EXIT2:
+ g_testSmpCpupStop = 1;
+
+ do {
+ ret = LOS_TaskInfoGet(g_testSmpCpupTaskID01, &tempTaskInfo);
+ } while (ret != LOS_ERRNO_TSK_NOT_CREATED);
+
+ return;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup001_task01";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* make sure that created test task is definitely on another core */
+ UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup001_task02";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD * 2 + 1)); // 2, used to calculate the delay time.
+
+EIXT1:
+ LOS_TaskDelete(g_testSmpCpupTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+
+ return LOS_OK;
+}
+
+VOID ItSmpExtendCpup011(VOID)
+{
+ TEST_ADD_CASE("ItSmpExtendCpup011", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_012.c b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..7a320ed63588f0a182f8b0b08602e86a14a4496d
--- /dev/null
+++ b/testsuites/kernel/sample/kernel_extend/cpup/smp/It_smp_extend_cpup_012.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_extend_cpup.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 g_testSmpCpupTaskID01, g_testSmpCpupTaskID02;
+static void Task01(void)
+{
+ UINT32 tempCpup;
+ UINT32 ret;
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+ ret = LOS_EventRead(&g_eventCB, 0x00000001, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+
+ tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID02, CPUP_LAST_ONE_SECONDS);
+ ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup, CPU_USE_MIN, CPU_USE_MIN + CPUP_TEST_TOLERANT, tempCpup);
+
+ return;
+}
+static void Task02(void)
+{
+ UINT32 tempCpup;
+ UINT32 ret;
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * CPUP_BACKWARD);
+
+ ret = LOS_EventRead(&g_eventCB, 0x00000001, LOS_WAITMODE_AND, LOS_WAIT_FOREVER);
+
+ tempCpup = LOS_HistoryTaskCpuUsage(g_testSmpCpupTaskID01, CPUP_LAST_ONE_SECONDS);
+ ICUNIT_ASSERT_WITHIN_EQUAL_VOID(tempCpup, CPU_USE_MIN, CPU_USE_MIN + CPUP_TEST_TOLERANT, tempCpup);
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ TSK_INIT_PARAM_S taskInitParam;
+ UINT32 ret;
+
+ g_eventCB.uwEventID = 0;
+ ret = LOS_EventInit(&g_eventCB);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT0);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup001_task01";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 2; // 2, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* make sure that created test task is definitely on another core */
+ UINT32 currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM;
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid);
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID01, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ (VOID)memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
+ taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02;
+ taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
+ taskInitParam.pcName = "SmpCpup001_task02";
+ taskInitParam.usTaskPrio = TASK_PRIO_TEST - 1; // 1, used to calculate the task priority.
+#if (LOSCFG_KERNEL_SMP == YES)
+ taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+ ret = LOS_TaskCreate(&g_testSmpCpupTaskID02, &taskInitParam);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EIXT1);
+
+ ret = LOS_EventWrite(&g_eventCB, 0x00000001);
+
+ LOS_TaskDelay(LOSCFG_BASE_CORE_TICK_PER_SECOND * (CPUP_BACKWARD + 1));
+
+ LOS_EventClear(&g_eventCB, ~0x00000001);
+
+EIXT1:
+ LOS_TaskDelete(g_testSmpCpupTaskID02);
+EXIT:
+ LOS_TaskDelete(g_testSmpCpupTaskID01);
+EXIT0:
+ LOS_EventDestroy(&g_eventCB);
+
+ return LOS_OK;
+}
+
+VOID ItSmpExtendCpup012(VOID)
+{
+ TEST_ADD_CASE("ItSmpExtendCpup012", Testcase, TEST_EXTEND, TEST_CPUP, TEST_LEVEL2, TEST_FUNCTION);
+}
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/BUILD.gn b/testsuites/kernel/sample/posix/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..109c3b06b71003c196ae4c61f4794dd8b15f8936
--- /dev/null
+++ b/testsuites/kernel/sample/posix/BUILD.gn
@@ -0,0 +1,89 @@
+static_library("test_posix") {
+
+ sources = [
+ "mqueue/It_posix_queue.c",
+ "mutex/It_posix_mutex.c",
+ "sem/It_posix_sem.c",
+ "pthread/It_posix_pthread.c",
+ "swtmr/It_posix_swtmr.c",
+ "sched/It_posix_sched.c",
+ "mem/It_posix_mem.c",
+ "smp/It_posix_smp_001.c",
+ "smp/It_posix_smp_002.c",
+ "smp/It_posix_smp_003.c",
+ "smp/It_posix_smp_004.c",
+ "smp/It_posix_smp_005.c",
+ "smp/It_posix_smp_006.c",
+ "smp/It_posix_smp_007.c",
+ "smp/It_posix_smp_008.c",
+ "smp/It_posix_smp_009.c",
+ "smp/It_posix_smp_010.c",
+ "smp/It_posix_smp_011.c",
+ "smp/It_posix_smp_012.c",
+ "smp/It_posix_smp_013.c",
+ "smp/It_posix_smp_014.c",
+ "smp/It_posix_smp_015.c",
+ "smp/It_posix_smp_016.c",
+ "smp/It_posix_smp_017.c",
+ "smp/It_posix_smp_018.c",
+ "smp/It_posix_smp.c",
+ ]
+
+ if (LOSCFG_TEST_SMOKE) {
+ sources += [
+ "mqueue/smoke/It_posix_queue_001.c",
+ "mqueue/smoke/It_posix_queue_003.c",
+ "mqueue/smoke/It_posix_queue_028.c",
+ "mqueue/smoke/It_posix_queue_062.c",
+ "mutex/smoke/It_posix_mutex_001.c",
+ "mutex/smoke/It_posix_mutex_007.c",
+ "mutex/smoke/It_posix_mutex_012.c",
+ "mutex/smoke/It_posix_mutex_015.c",
+ "mutex/smoke/It_posix_mutex_016.c",
+ "mutex/smoke/It_posix_mutex_019.c",
+ "mutex/smoke/It_posix_mutex_020.c",
+ "sem/smoke/It_posix_sem_001.c",
+ "sem/smoke/It_posix_sem_002.c",
+ "pthread/smoke/It_posix_pthread_003.c",
+ "pthread/smoke/It_posix_pthread_004.c",
+ "pthread/smoke/It_posix_pthread_005.c",
+ "pthread/smoke/It_posix_pthread_006.c",
+ "pthread/smoke/It_posix_pthread_009.c",
+ "pthread/smoke/It_posix_pthread_018.c",
+ "pthread/smoke/It_posix_pthread_019.c",
+ "pthread/smoke/It_posix_pthread_020.c",
+ "pthread/smoke/It_posix_pthread_021.c",
+ "pthread/smoke/It_posix_pthread_022.c",
+ "swtmr/smoke/It_posix_swtmr_001.c",
+ "swtmr/smoke/It_posix_swtmr_013.c",
+ "swtmr/smoke/It_posix_swtmr_046.c",
+ "swtmr/smoke/It_posix_swtmr_047.c",
+ "swtmr/smoke/It_posix_swtmr_049.c",
+ "swtmr/smoke/It_posix_swtmr_055.c",
+ "swtmr/smoke/It_posix_swtmr_065.c",
+ "swtmr/smoke/It_posix_swtmr_067.c",
+ "swtmr/smoke/It_posix_swtmr_101.c",
+ "swtmr/smoke/It_posix_swtmr_103.c",
+ "swtmr/smoke/It_posix_swtmr_105.c",
+ "swtmr/smoke/It_posix_swtmr_106.c",
+ "mem/smoke/It_posix_mem_001.c",
+ "mem/smoke/It_posix_mem_002.c",
+ "mem/smoke/It_posix_mem_003.c",
+ ]
+ }
+
+ include_dirs = [
+ "../../../compat/posix/src",
+ "../../include",
+ "mem",
+ "mqueue",
+ "mutex",
+ "pthread",
+ "sched",
+ "sem",
+ "smp",
+ "swtmr",
+ ]
+
+ cflags = [ "-Wno-error" ]
+}
diff --git a/testsuites/kernel/sample/posix/Makefile b/testsuites/kernel/sample/posix/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..3b9cead1c92e70dc90b1b57cda9e1a3f6473514e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/Makefile
@@ -0,0 +1,37 @@
+
+include $(LITEOSTESTTOPDIR)/config.mk
+
+MODULE_NAME := $(notdir $(shell pwd))test
+
+LOCAL_INCLUDE := \
+ -I $(LITEOSTOPDIR)/compat/posix/src \
+ -I $(LITEOSTESTTOPDIR)/kernel/include \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/posix/mutex \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/posix/pthread
+
+SRC_MODULES := mqueue mutex sem pthread swtmr sched mem
+
+ifeq ($(LOSCFG_TEST_LLT), y)
+LLT_MODULES := mqueue/llt mutex/llt sem/llt pthread/llt swtmr/llt sched/llt mem/llt
+endif
+
+ifeq ($(LOSCFG_TEST_SMOKE), y)
+SMOKE_MODULES := mqueue/smoke mutex/smoke sem/smoke pthread/smoke swtmr/smoke sched/smoke mem/smoke
+endif
+
+ifeq ($(LOSCFG_TEST_FULL), y)
+FULL_MODULES := mqueue/full mutex/full sem/full pthread/full swtmr/full sched/full mem/full
+endif
+
+ifeq ($(LOSCFG_TEST_PRESSURE), y)
+PRESSURE_MODULES := mqueue/pressure mutex/pressure sem/pressure pthread/pressure swtmr/pressure sched/pressure mem/pressure
+endif
+
+LOCAL_MODULES := $(SRC_MODULES) $(LLT_MODULES) $(PRESSURE_MODULES) $(SMOKE_MODULES) $(FULL_MODULES)
+
+LOCAL_SRCS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.c))
+LOCAL_CHS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.h))
+
+LOCAL_FLAGS := $(LOCAL_INCLUDE) -Wno-error
+
+include $(MODULE)
diff --git a/testsuites/kernel/sample/posix/mutex/It_posix_mutex.c b/testsuites/kernel/sample/posix/mutex/It_posix_mutex.c
new file mode 100644
index 0000000000000000000000000000000000000000..da2a543f4c6d61f16b97d48fb87e14cb86d7b686
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/It_posix_mutex.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+int g_retval;
+int g_returned;
+int g_canceled;
+int g_value;
+int g_ctrl;
+
+
+VOID ItSuitePosixMutex(void)
+{
+#if defined(LOSCFG_TEST_SMOKE)
+ ItPosixMux001();
+ ItPosixMux007();
+ ItPosixMux012();
+ ItPosixMux015();
+ ItPosixMux016();
+ ItPosixMux019();
+ ItPosixMux020();
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+ ItPosixMux002();
+ ItPosixMux003();
+ ItPosixMux004();
+ ItPosixMux005();
+ ItPosixMux006();
+ ItPosixMux008();
+ ItPosixMux009();
+ ItPosixMux010();
+ ItPosixMux011();
+ ItPosixMux013();
+ ItPosixMux014();
+ ItPosixMux017();
+ ItPosixMux018();
+ ItPosixMux021();
+ ItPosixMux022();
+ ItPosixMux023();
+ ItPosixMux024();
+ ItPosixMux025();
+ ItPosixMux026();
+ ItPosixMux027();
+ ItPosixMux028();
+ ItPosixMux029();
+ ItPosixMux032();
+ ItPosixMux033();
+ ItPosixMux034();
+ ItPosixMux035();
+ ItPosixMux036();
+ ItPosixMux037();
+ ItPosixMux038();
+ ItPosixMux039();
+ ItPosixMux040();
+ ItPosixMux041();
+ ItPosixMux042();
+ ItPosixMux043();
+ ItPosixMux044();
+ ItPosixMux045();
+ ItPosixMux046();
+ ItPosixMux047();
+ ItPosixMux048();
+ ItPosixMux049();
+ ItPosixMux050();
+ ItPosixMux054();
+ ItPosixMux055();
+ ItPosixMux056();
+ ItPosixMux057();
+ ItPosixMux058();
+ ItPosixMux059();
+ ItPosixMux060();
+ ItPosixMux061();
+ ItPosixMux062();
+ ItPosixMux063();
+ ItPosixMux064();
+ ItPosixMux065();
+ ItPosixMux066();
+ ItPosixMux067();
+ ItPosixMux068();
+ ItPosixMux069();
+ ItPosixMux070();
+ ItPosixMux071();
+ ItPosixMux072();
+ ItPosixMux073();
+ ItPosixMux074();
+#if (LOSCFG_KERNEL_SMP != YES)
+ ItPosixMux075();
+#endif
+ ItPosixMux076();
+ ItPosixMux077();
+ ItPosixMux078();
+ ItPosixMux079();
+ ItPosixMux080();
+ ItPosixMux081();
+ ItPosixMux082();
+ ItPosixMux084();
+ ItPosixMux085();
+ ItPosixMux086();
+ ItPosixMux087();
+ ItPosixMux089();
+ ItPosixMux090();
+ ItPosixMux091();
+ ItPosixMux092();
+ ItPosixMux093();
+ ItPosixMux094();
+ ItPosixMux095();
+ ItPosixMux097();
+ ItPosixMux098();
+ ItPosixMux099();
+ ItPosixMux101();
+#endif
+}
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/It_posix_mutex.h b/testsuites/kernel/sample/posix/mutex/It_posix_mutex.h
new file mode 100644
index 0000000000000000000000000000000000000000..0d737ba3137afdfe041af93743477960ac8199a5
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/It_posix_mutex.h
@@ -0,0 +1,205 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _IT_POSIX_MUTEX_H
+#define _IT_POSIX_MUTEX_H
+
+#include "osTest.h"
+#include "pthread.h"
+#include "errno.h"
+#include "sched.h"
+#include "semaphore.h"
+#include "unistd.h"
+#include "los_task_pri.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#ifdef LOSCFG_DEBUG_DEADLOCK
+#define TEST_MUTEX_INIT \
+ { \
+ { 0, 0, 0, 0 }, \
+ { \
+ { 0, 0 }, { 0, 0 }, 0, 0 \
+ } \
+ }
+#else
+#define TEST_MUTEX_INIT \
+ { \
+ { 0, 0, 0, 0 }, \
+ { \
+ { 0, 0 }, 0, 0 \
+ } \
+ }
+#endif
+#define MUTEX_TEST_NUM 100
+
+extern int g_retval;
+extern int g_value;
+extern int g_ctrl;
+
+long sysconf(int name);
+
+#if defined(LOSCFG_TEST_SMOKE)
+VOID IT_FS_VNODE_001(void);
+VOID IT_FS_NAMECACHE_001(void);
+
+VOID ItPosixMux001(void);
+VOID ItPosixMux007(void);
+VOID ItPosixMux012(void);
+VOID ItPosixMux015(void);
+VOID ItPosixMux016(void);
+VOID ItPosixMux019(void);
+VOID ItPosixMux020(void);
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+VOID ItPosixMux002(void);
+VOID ItPosixMux003(void);
+VOID ItPosixMux004(void);
+VOID ItPosixMux005(void);
+VOID ItPosixMux006(void);
+VOID ItPosixMux008(void);
+VOID ItPosixMux009(void);
+VOID ItPosixMux010(void);
+VOID ItPosixMux011(void);
+VOID ItPosixMux013(void);
+VOID ItPosixMux014(void);
+VOID ItPosixMux017(void);
+VOID ItPosixMux018(void);
+VOID ItPosixMux021(void);
+VOID ItPosixMux022(void);
+VOID ItPosixMux023(void);
+VOID ItPosixMux024(void);
+VOID ItPosixMux025(void);
+VOID ItPosixMux026(void);
+VOID ItPosixMux027(void);
+VOID ItPosixMux028(void);
+VOID ItPosixMux029(void);
+VOID ItPosixMux032(void);
+VOID ItPosixMux033(void);
+VOID ItPosixMux034(void);
+VOID ItPosixMux035(void);
+VOID ItPosixMux036(void);
+VOID ItPosixMux037(void);
+VOID ItPosixMux038(void);
+VOID ItPosixMux039(void);
+VOID ItPosixMux040(void);
+VOID ItPosixMux041(void);
+VOID ItPosixMux042(void);
+VOID ItPosixMux043(void);
+VOID ItPosixMux044(void);
+VOID ItPosixMux045(void);
+VOID ItPosixMux046(void);
+VOID ItPosixMux047(void);
+VOID ItPosixMux048(void);
+VOID ItPosixMux049(void);
+VOID ItPosixMux050(void);
+VOID ItPosixMux054(void);
+VOID ItPosixMux055(void);
+VOID ItPosixMux056(void);
+VOID ItPosixMux057(void);
+VOID ItPosixMux058(void);
+VOID ItPosixMux059(void);
+VOID ItPosixMux060(void);
+VOID ItPosixMux061(void);
+VOID ItPosixMux062(void);
+VOID ItPosixMux063(void);
+VOID ItPosixMux064(void);
+VOID ItPosixMux065(void);
+VOID ItPosixMux066(void);
+VOID ItPosixMux067(void);
+VOID ItPosixMux068(void);
+VOID ItPosixMux069(void);
+VOID ItPosixMux070(void);
+VOID ItPosixMux071(void);
+VOID ItPosixMux072(void);
+VOID ItPosixMux073(void);
+VOID ItPosixMux074(void);
+VOID ItPosixMux075(void);
+VOID ItPosixMux076(void);
+VOID ItPosixMux077(void);
+VOID ItPosixMux078(void);
+VOID ItPosixMux079(void);
+VOID ItPosixMux080(void);
+VOID ItPosixMux081(void);
+VOID ItPosixMux082(void);
+VOID ItPosixMux084(void);
+VOID ItPosixMux085(void);
+VOID ItPosixMux086(void);
+VOID ItPosixMux087(void);
+VOID ItPosixMux089(void);
+VOID ItPosixMux090(void);
+VOID ItPosixMux091(void);
+VOID ItPosixMux092(void);
+VOID ItPosixMux093(void);
+VOID ItPosixMux094(void);
+VOID ItPosixMux095(void);
+VOID ItPosixMux097(void);
+VOID ItPosixMux098(void);
+VOID ItPosixMux099(void);
+VOID ItPosixMux101(void);
+#endif
+
+#if defined(LOSCFG_TEST_LLT)
+VOID LltPosixMux001(VOID);
+VOID LltPosixMux002(VOID);
+VOID LltPosixMux003(VOID);
+VOID LltPosixMux004(VOID);
+VOID LltPosixMux005(VOID);
+VOID ItPosixMux031(void);
+VOID ItPosixMux083(void);
+VOID ItPosixMux088(void);
+VOID ItPosixMux096(void);
+VOID ItPosixMux100(void);
+VOID LltPosixMux006(void);
+VOID LltPosixMux007(void);
+#endif
+
+#if defined(LOSCFG_TEST_PRESSURE)
+VOID ItPosixMux051(void);
+VOID ItPosixMux052(void);
+VOID ItPosixMux053(void);
+#endif
+
+VOID ItSuitePosixMutex(void);
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _IT_POSIX_MUTEX_H */
diff --git a/testsuites/kernel/sample/posix/mutex/Makefile b/testsuites/kernel/sample/posix/mutex/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..d4cdb0c73aecf411af677ee472bbfd8784942fc4
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/Makefile
@@ -0,0 +1,35 @@
+
+include $(LITEOSTESTTOPDIR)/config.mk
+
+MODULE_NAME := mutextest
+
+LOCAL_INCLUDE := \
+ -I $(LITEOSTESTTOPDIR)/kernel/include \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/posix/mutex
+
+SRC_MODULES := .
+
+ifeq ($(LOSCFG_TEST_LLT), y)
+LLT_MODULES := llt
+endif
+
+ifeq ($(LOSCFG_TEST_PRESSURE), y)
+PRESSURE_MODULES := pressure
+endif
+
+ifeq ($(LOSCFG_TEST_SMOKE), y)
+SMOKE_MODULES := smoke
+endif
+
+ifeq ($(LOSCFG_TEST_FULL), y)
+FULL_MODULES := full
+endif
+
+LOCAL_MODULES := $(SRC_MODULES) $(LLT_MODULES) $(PRESSURE_MODULES) $(SMOKE_MODULES) $(FULL_MODULES)
+
+LOCAL_SRCS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.c))
+LOCAL_CHS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.h))
+
+LOCAL_FLAGS := $(LOCAL_INCLUDE) -Wno-error
+
+include $(MODULE)
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_002.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..fa2a8d0ff1c2d4887076da77155a9f036faa8fcf
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_002.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_init 3-1.c
+ * Test that pthread_mutexattr_init()
+ * Upon successful completion, pthread_mutexattr_init() shall return a value of 0.
+
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init()
+ * 2. ENOMEM is the only uwErr it returns, so if it doesn't return that uwErr,
+ * the return number should be 0.
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t *mta = NULL;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(mta);
+ ICUNIT_GOTO_EQUAL(rc, EINVAL, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux002(void)
+{
+ TEST_ADD_CASE("ItPosixMux002", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_003.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..81e1abdeabf6adfa39eeafbf06efe4f519d549c3
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_003.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_destroy 1-1.c
+ * Test that pthread_mutexattr_destroy()
+ * shall destroy a mutex attributes object.
+ *
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object using pthread_mutexattr_init()
+ * 2. Destroy the attributes object using pthread_mutexattr_destroy()
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Destroy the mutex attributes object */
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux003(void)
+{
+ TEST_ADD_CASE("ItPosixMux003", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_004.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..9201f5c5caa154c07172a924814b712851d6efc5
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_004.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_destroy 2-1.c
+ * Test pthread_mutexattr_destroy()
+ * A destroyed 'attr' attributes object can be reinitialized using
+ * pthread_mutexattr_init(); the results of otherwise referencing the
+ * object after it has been destroyed are undefined.
+ *
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object using pthread_mutexattr_init()
+ * 2. Destroy that initialized attribute using pthread_mutexattr_destroy()
+ * 3. Initialize the pthread_mutexattr_t object again. This should not result
+ * in any uwErr.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Destroy the mutex attributes object */
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ /* Initialize the mutex attributes object again. This shouldn't result in an uwErr. */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux004(void)
+{
+ TEST_ADD_CASE("ItPosixMux004", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_005.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..3f268b3e8ea5c4453c86692b355937f6f19a83da
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_005.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_destroy 3-1.c
+ * Test pthread_mutexattr_destroy()
+ * Upon successful completion, pthread_mutexattr_destroy() shall
+ * return a value of 0.
+ *
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object using pthread_mutexattr_init()
+ * 2. Destroy that initialized attribute using pthread_mutexattr_destroy().
+ * This should return 0;
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Destroy the mutex attributes object */
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux005(void)
+{
+ TEST_ADD_CASE("ItPosixMux005", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_006.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..c27db8bcff218d0baea16998e827e09eb289c4fc
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_006.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_destroy 4-1.c
+ * Test pthread_mutexattr_destroy()
+ * If it fails, an uwErr number shall be returned to indicate the uwErr:
+ * [EINVAL] The value specified by 'attr' is invalid
+ *
+ * Steps:
+ * Try to destroy a NULL mutex attributes object using pthread_mutexattr_destroy().
+ * If it returns EINVAL, the test passes.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t *mta = NULL;
+ int rc;
+
+ /* Try to destroy a NULL mutex attributes object using pthread_mutexattr_destroy()
+ * It should return EINVAL */
+ rc = pthread_mutexattr_destroy(mta);
+ ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux006(void)
+{
+ TEST_ADD_CASE("ItPosixMux006", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_008.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..724b19218b36f7f978bab9e430650aca3e230035
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_008.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_setprotocol 3-1.c
+ * Test that pthread_mutexattr_setprotocol()
+ *
+ * It Shall fail if:
+ * [ENOTSUP] The value specified by protocol is an unsupported value.
+ * It may fail if:
+ * [EINVAL] 'protocol' is invalid
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int protocol;
+
+ int ret;
+
+ /* Initialize a mutex attributes object */
+ ret = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ protocol = mta.protocol;
+
+ while (protocol == PTHREAD_PRIO_NONE || protocol == PTHREAD_PRIO_INHERIT || protocol == PTHREAD_PRIO_PROTECT) {
+ protocol--;
+ }
+
+ /* Set the protocol to an invalid value. */
+ ret = pthread_mutexattr_setprotocol(&mta, protocol);
+ ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
+
+ ret = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(ret, ENOERR, ret, EXIT);
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux008(void)
+{
+ TEST_ADD_CASE("ItPosixMux008", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_009.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..12f4ef5219c2aed7fefe89803e080f5507d1e5a5
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_009.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_setprotocol 3-2.c
+ * Test that pthread_mutexattr_setprotocol()
+ *
+ * It may fail if:
+ * [EINVAL] The value specified by 'attr' is invalid.
+ *
+ * Steps:
+ * 1. Call pthread_mutexattr_setprotocol with an uninitialized pthread_mutexattr_t object.
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int ret;
+
+ /* Set the protocol to an invalid value. */
+ ret = pthread_mutexattr_setprotocol(&mta, PTHREAD_PRIO_NONE);
+ ICUNIT_ASSERT_EQUAL(ret, ENOERR, ret);
+
+ ret = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(ret, ENOERR, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux009(void)
+{
+ TEST_ADD_CASE("ItPosixMux009", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_010.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..c92efefc135c94481d076b95dea8fc2a11ed553e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_010.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_getprotocol 1-1.c
+ * Test that pthread_mutexattr_getprotocol()
+ *
+ * Gets the protocol attribute of a mutexattr object (which was prev. created
+ * by the function pthread_mutexattr_init()).
+ *
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init()
+ * 2. Call pthread_mutexattr_getprotocol() to obtain the protocol.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int protocol, rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Get the protocol mutex attr. */
+ rc = pthread_mutexattr_getprotocol(&mta, &protocol);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux010(void)
+{
+ TEST_ADD_CASE("ItPosixMux010", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_011.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..9755d5e4b957fa32b185c30beed837f1b0e54033
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_011.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_getprotocol 1-2.c
+ * Test that pthread_mutexattr_getprotocol()
+ *
+ * Gets the protocol attribute of a mutexattr object (which was prev. created
+ * by the function pthread_mutexattr_init()).
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int protocol, protcls[3], i;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ protcls[0] = PTHREAD_PRIO_NONE;
+ protcls[1] = PTHREAD_PRIO_INHERIT;
+ protcls[2] = PTHREAD_PRIO_PROTECT; // 2, buffer index.
+
+ for (i = 0; i < 3; i++) { // 3, The loop frequency.
+ /* Set the protocol to one of the 3 valid protocols. */
+ rc = pthread_mutexattr_setprotocol(&mta, protcls[i]);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ /* Get the protocol mutex attr. */
+ rc = pthread_mutexattr_getprotocol(&mta, &protocol);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ /* Make sure that the protocol set is the protocl we get when calling
+ * pthread_mutexattr_getprocol() */
+ if (protocol != protcls[i]) {
+ ICUNIT_GOTO_EQUAL(1, 0, LOS_NOK, EXIT);
+ }
+ }
+
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux011(void)
+{
+ TEST_ADD_CASE("ItPosixMux011", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_013.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..54b9025b01855d9281a19803e2aa4933a8d39c13
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_013.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int prioceiling, ret;
+
+ prioceiling = sched_get_priority_max(SCHED_RR);
+ prioceiling++;
+
+ /* Set the prioceiling of an unintialized mutex attr. */
+ ret = pthread_mutexattr_setprioceiling(&mta, prioceiling);
+ ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
+
+ ret = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(ret, ENOERR, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux013(void)
+{
+ TEST_ADD_CASE("ItPosixMux013", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_014.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_014.c
new file mode 100644
index 0000000000000000000000000000000000000000..2534ae4894391c3e33cc6dc1051a4a1b5cbfdeac
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_014.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_setprioceiling 3-2.c
+ * Test that pthread_mutexattr_setprioceiling()
+ *
+ * It MAY fail if:
+ *
+ * [EINVAL] - 'attr' or 'prioceiling' is invalid.
+ * [EPERM] - The caller doesn't have the privilege to perform the operation.
+ *
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init()
+ * 2. Call pthread_mutexattr_setprioceiling() with an invalid prioceiling value.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int prioceiling, ret;
+
+ /* Set 'prioceiling' out of SCHED_FIFO boundry. */
+ prioceiling = sched_get_priority_min(SCHED_RR);
+ prioceiling--;
+
+ /* Set the prioceiling to an invalid prioceiling. */
+ ret = pthread_mutexattr_setprioceiling(&mta, prioceiling);
+ ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
+
+ ret = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(ret, ENOERR, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux014(void)
+{
+ TEST_ADD_CASE("ItPosixMux014", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_017.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_017.c
new file mode 100644
index 0000000000000000000000000000000000000000..4a542a85e0c87064d01ed62145eb16eb8d534f80
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_017.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_getprioceiling 3-1.c
+ * Test that pthread_mutexattr_getprioceiling()
+ *
+ * It MAY fail if:
+ *
+ * [EINVAL] - 'attr' or 'prioceiling' is invalid.
+ * [EPERM] - The caller doesn't have the privilege to perform the operation.
+ *
+ * This function shall not return an uwErr code of [EINTR]
+ *
+ * Steps:
+ * 1. Call pthread_mutexattr_getprioceiling() to obtain the prioceiling for an
+ * uninitialized pthread_mutexattr_t object.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ int prioceiling, ret;
+ pthread_mutexattr_t mta;
+
+ /* Get the prioceiling of an unintialized mutex attr. */
+ ret = pthread_mutexattr_getprioceiling(&mta, &prioceiling);
+ ICUNIT_ASSERT_EQUAL(ret, ENOERR, ret);
+
+ ret = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(ret, ENOERR, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux017(void)
+{
+ TEST_ADD_CASE("ItPosixMux017", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_018.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..96b0932aeeeac3be4f197b4432db554950125e0f
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_018.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex1, g_mutex2;
+
+/* pthread_mutex_init 1-1.c
+ * Test that pthread_mutex_init()
+ * initializes a mutex referenced by 'mutex' with attributes specified
+ * by 'attr'. If 'attr' is NULL, the default mutex attributes are used.
+ * The effect shall be the same as passing the address of a default
+ * mutex attributes.
+
+ * NOTE: There is no direct way to judge if two mutexes have the same effect,
+ * thus this test does not cover the statement in the last sentence.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Initialize mutex1 with the default mutex attributes */
+ rc = pthread_mutex_init(&g_mutex1, &mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT1);
+
+ /* Initialize mutex2 with NULL attributes */
+ rc = pthread_mutex_init(&g_mutex2, NULL);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT2);
+
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT1);
+
+ rc = pthread_mutex_destroy(&g_mutex1);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT2);
+
+ rc = pthread_mutex_destroy(&g_mutex2);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT3);
+
+ return LOS_OK;
+
+EXIT1:
+ pthread_mutexattr_destroy(&mta);
+
+EXIT2:
+ pthread_mutex_destroy(&g_mutex1);
+
+EXIT3:
+ pthread_mutex_destroy(&g_mutex2);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux018(void)
+{
+ TEST_ADD_CASE("ItPosixMux018", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_021.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..9c3fb5ffc5077d3f3d75c5828acc9e46b3da7ae3
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_021.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_init 3-1.c
+ * Test that the macro PTHREAD_MUTEX_INITIALIZER can be sued to intiailize
+ * mutexes that are statically allocated.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutex_t data = PTHREAD_MUTEX_INITIALIZER;
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux021(void)
+{
+ TEST_ADD_CASE("ItPosixMux021", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_022.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_022.c
new file mode 100644
index 0000000000000000000000000000000000000000..7d06e933f1d11c276f371cea47eb0c7e3bb44eec
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_022.c
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t *g_mtx;
+static sem_t g_semA, g_semB;
+static pthread_mutex_t g_mtxNull;
+static pthread_mutex_t g_mtxMacro = PTHREAD_MUTEX_INITIALIZER;
+
+void *UnlockIssue022(void *arg)
+{
+ int ret;
+ TestBusyTaskDelay(20); // 20, Set the timeout of runtime.
+ g_testCount++;
+
+ if ((ret = pthread_mutex_lock(g_mtx))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+
+ if ((ret = sem_post(&g_semA))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+
+ if ((ret = sem_wait(&g_semB))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+
+ if (g_retval != 0) { /* parent thread failed to unlock the mutex) */
+ if ((ret = pthread_mutex_unlock(g_mtx))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+ }
+
+ g_testCount++;
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t thr;
+
+ pthread_mutex_t *tabMutex[2];
+ int tabRes[2][3] = { {0, 0, 0}, {0, 0, 0} };
+
+ int ret;
+ void *thRet = NULL;
+
+ int i;
+
+ g_retval = 0;
+
+ g_testCount = 0;
+
+ /* We first initialize the two mutexes. */
+ if ((ret = pthread_mutex_init(&g_mtxNull, NULL))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ tabMutex[0] = &g_mtxNull;
+ tabMutex[1] = &g_mtxMacro;
+
+ if ((ret = sem_init(&g_semA, 0, 0))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+ if ((ret = sem_init(&g_semB, 0, 0))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+ /* OK let's go for the first part of the test : abnormals unlocking */
+
+ /* We first check if unlocking an unlocked mutex returns an uwErr. */
+ g_retval = pthread_mutex_unlock(tabMutex[0]);
+ ICUNIT_ASSERT_NOT_EQUAL(g_retval, ENOERR, g_retval);
+
+ ret = pthread_mutex_unlock(tabMutex[1]);
+ if (ret != g_retval) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* Now we focus on unlocking a mutex lock by another thread */
+ for (i = 0; i < 2; i++) { // 2, The loop frequency.
+ g_mtx = tabMutex[i];
+ tabRes[i][0] = 0;
+ tabRes[i][1] = 0;
+ tabRes[i][2] = 0; // 2, buffer index.
+
+ if ((ret = pthread_create(&thr, NULL, UnlockIssue022, NULL))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if (i == 0) {
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+ }
+ if (i == 1) {
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Assert that g_testCount.
+ }
+
+ if ((ret = sem_wait(&g_semA))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ g_retval = pthread_mutex_unlock(g_mtx);
+ ICUNIT_ASSERT_EQUAL(g_retval, EPERM, g_retval);
+
+ if ((ret = sem_post(&g_semB))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+ if (ret = pthread_join(thr, &thRet)) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if (i == 0) {
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Assert that g_testCount.
+ }
+ if (i == 1) {
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, Assert that g_testCount.
+ }
+
+ tabRes[i][0] = g_retval;
+ }
+
+ if (tabRes[0][0] != tabRes[1][0]) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ (void)pthread_mutex_destroy(&g_mtxNull);
+ (void)pthread_mutex_destroy(&g_mtxMacro);
+ (void)pthread_mutex_destroy(tabMutex[0]);
+ (void)pthread_mutex_destroy(tabMutex[1]);
+
+ ret = sem_destroy(&g_semA);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_destroy(&g_semB);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux022(void)
+{
+ TEST_ADD_CASE("ItPosixMux022", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_023.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..076fc3f5d982c81ec73bae8c0d4a2d4a4c6ab87c
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_023.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_init 4-1.c
+ * Test that pthread_mutex_init()
+ * Upon succesful completion, it shall return a 0
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Initialize a mutex object with the default mutex attributes */
+ rc = pthread_mutex_init(&mutex, &mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT1);
+
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT2);
+
+ rc = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT2);
+
+ return LOS_OK;
+
+EXIT2:
+ pthread_mutex_destroy(&mutex);
+
+EXIT1:
+ pthread_mutexattr_destroy(&mta);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux023(void)
+{
+ TEST_ADD_CASE("ItPosixMux023", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_024.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_024.c
new file mode 100644
index 0000000000000000000000000000000000000000..e0a331e48b90bea849fa3a1210e12140f22eecaa
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_024.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_destroy 1-1.c
+ * Test that pthread_mutex_destroy()
+ * shall destroy the mutex referenced by 'mutex'; the mutex object in effect
+ * becomes uninitialized.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ pthread_mutex_t mutex1 = TEST_MUTEX_INIT;
+ pthread_mutex_t mutex2 = TEST_MUTEX_INIT;
+ pthread_mutex_t mutex3 = PTHREAD_MUTEX_INITIALIZER;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Initialize mutex1 with the default mutex attributes */
+ rc = pthread_mutex_init(&mutex1, &mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT1);
+
+ /* Initialize mutex2 with NULL attributes */
+ rc = pthread_mutex_init(&mutex2, NULL);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT3);
+
+ /* Destroy the mutex attributes object */
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT3);
+
+ /* Destroy mutex1 */
+ rc = pthread_mutex_destroy(&mutex1);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT3);
+
+ /* Destroy mutex2 */
+ rc = pthread_mutex_destroy(&mutex2);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT2);
+
+ /* Destroy mutex3 */
+ rc = pthread_mutex_destroy(&mutex3);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT1);
+
+ return LOS_OK;
+
+EXIT3:
+ pthread_mutex_destroy(&mutex1);
+
+EXIT2:
+ pthread_mutex_destroy(&mutex2);
+
+EXIT1:
+ pthread_mutexattr_destroy(&mta);
+ pthread_mutex_destroy(&mutex3);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux024(void)
+{
+ TEST_ADD_CASE("ItPosixMux024", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_025.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_025.c
new file mode 100644
index 0000000000000000000000000000000000000000..b7dc31310970ccf04408cdc29e5705ad063c1505
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_025.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_destroy 2-1.c
+ * Test pthread_mutex_destroy() that
+ * a destroyed mutex object can be reinitialized using pthread_mutex_init()
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Destroy the mutex attributes object */
+ rc = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ /* Initialize the mutex attributes object again. This shouldn't result in an uwErr. */
+ rc = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ rc = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutex_destroy(&mutex);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux025(void)
+{
+ TEST_ADD_CASE("ItPosixMux025", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_026.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_026.c
new file mode 100644
index 0000000000000000000000000000000000000000..134786beae585ac556b864777649eb439785c3bc
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_026.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+struct _scenar_028 {
+ int m_type; /* Mutex type to use */
+ int m_pshared; /* 0: mutex is process-private (default) ~ !0: mutex is process-shared, if supported */
+ char *descr; /* Case description */
+} g_scenarii028[] = {
+ {PTHREAD_MUTEX_DEFAULT, 0, "Default mutex"},
+ {PTHREAD_MUTEX_NORMAL, 0, "Normal mutex"},
+ {PTHREAD_MUTEX_ERRORCHECK, 0, "Errorcheck mutex"},
+ {PTHREAD_MUTEX_RECURSIVE, 0, "Recursive mutex"},
+ {PTHREAD_MUTEX_DEFAULT, 1, "Pshared mutex"},
+ {PTHREAD_MUTEX_NORMAL, 1, "Pshared Normal mutex"},
+ {PTHREAD_MUTEX_ERRORCHECK, 1, "Pshared Errorcheck mutex"},
+ {PTHREAD_MUTEX_RECURSIVE, 1, "Pshared Recursive mutex"}
+};
+
+#define NSCENAR (sizeof(g_scenarii028) / sizeof(g_scenarii028[0]))
+
+/* pthread_mutex_destroy 2-2.c
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ * This sample test aims to check the following assertion:
+ *
+ * pthread_mutex_init() can be used to re-initialize a destroyed mutex.
+
+ * The steps are:
+ * -> Initialize a mutex with a given attribute.
+ * -> Destroy the mutex
+ * -> Initialize again the mutex with another attribute.
+ */
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ int i, j;
+ pthread_mutex_t mtx;
+ pthread_mutexattr_t ma[NSCENAR + 1];
+ pthread_mutexattr_t *pma[NSCENAR + 2];
+ long pshared;
+
+ /* System abilities */
+ pshared = sysconf(_SC_THREAD_PROCESS_SHARED);
+
+ /* Initialize the mutex attributes objects */
+ for (i = 0; i < NSCENAR; i++) {
+ ret = pthread_mutexattr_init(&ma[i]);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ }
+ /* Default mutexattr object */
+ ret = pthread_mutexattr_init(&ma[i]);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ /* Initialize the pointer array */
+ /* 2, The loop frequency. */
+ for (i = 0; i < NSCENAR + 2; i++)
+ /* NULL pointer */
+ pma[i] = NULL;
+
+ /* Ok, we can now proceed to the test */
+ for (i = 0; i < NSCENAR + 2; i++) { // 2, The loop frequency.
+ for (j = 0; j < NSCENAR + 2; j++) { // 2, The loop frequency.
+ ret = pthread_mutex_init(&mtx, pma[i]);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mtx);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&mtx, pma[j]);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mtx);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ }
+ }
+ for (i = 0; i < NSCENAR + 1; i++) {
+ ret = pthread_mutexattr_destroy(&ma[i]);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ }
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux026(void)
+{
+ TEST_ADD_CASE("ItPosixMux026", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_027.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_027.c
new file mode 100644
index 0000000000000000000000000000000000000000..655faa033338ccdf10dd0a596c53d535589453af
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_027.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_destroy 3-1.c
+ * Test that pthread_mutex_destroy()
+ * Upon succesful completion, it shall return a 0
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+ int rc;
+
+ /* Initialize a mutex object */
+ rc = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ rc = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutex_destroy(&mutex);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux027(void)
+{
+ TEST_ADD_CASE("ItPosixMux027", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_028.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_028.c
new file mode 100644
index 0000000000000000000000000000000000000000..fb0a43e4114c4e9706bd226284e6f1fe664c3630
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_028.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_destroy 4-2.c
+ * Test that when a pthread_mutex_destroy is called on a
+ * locked mutex, it fails and returns EBUSY
+
+ * Steps:
+ * 1. Create a mutex
+ * 2. Lock the mutex
+ * 3. Try to destroy the mutex
+ * 4. Check that this may fail with EBUSY
+ */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+ int rc;
+
+ /* Lock the mutex */
+ rc = pthread_mutex_lock(&mutex);
+ if (rc != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, rc);
+ }
+
+ /* Try to destroy the locked mutex */
+ rc = pthread_mutex_destroy(&mutex);
+ if (rc == EBUSY) {
+ pthread_mutex_unlock(&mutex);
+ pthread_mutex_destroy(&mutex);
+ return LOS_OK;
+ }
+
+ return LOS_NOK;
+}
+
+
+VOID ItPosixMux028(void)
+{
+ TEST_ADD_CASE("ItPosixMux028", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_029.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..ef4473b37045b262a1f738acbbd10a007a054ef3
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_029.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_destroy 5-1.c
+ * Test that pthread_mutex_destroy()
+ * It shall be safe to destroy an initialized mutex that is unlocked.
+ */
+static UINT32 Testcase(VOID)
+{
+ int rc;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ /* Initialize mutex with the default mutex attributes */
+ rc = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Lock mutex */
+ rc = pthread_mutex_lock(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ sleep(1);
+ /* Unlock */
+ rc = pthread_mutex_unlock(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT1);
+
+ /* Destroy mutex after it is unlocked */
+ rc = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT1:
+ pthread_mutex_unlock(&mutex);
+
+EXIT:
+ pthread_mutex_destroy(&mutex);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux029(void)
+{
+ TEST_ADD_CASE("ItPosixMux029", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_032.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_032.c
new file mode 100644
index 0000000000000000000000000000000000000000..981d840925b09acd0f0216a1faedc0aac2b2e9b8
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_032.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_getprioceiling 1-1.c
+ *
+ * Test that pthread_mutex_getprioceiling() returns the current prioceiling of
+ * the mutex with PTHREAD_PRIO_PROTECT.
+ *
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init()
+ * 2. Set the protocol using PTHREAD_PRIO_PROTECT.
+ * 3. Call pthread_mutex_getprioceiling() to obtain the prioceiling.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mutexAttr;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+ int err, prioceiling;
+
+ err = pthread_mutexattr_init(&mutexAttr);
+ ICUNIT_ASSERT_EQUAL(err, ENOERR, err);
+
+ /*
+ * Has to be something other than PTHREAD_PRIO_NONE, the default as per
+ * pthread_mutexattr_getprotocol.
+ */
+ err = pthread_mutexattr_setprotocol(&mutexAttr, PTHREAD_PRIO_PROTECT);
+ ICUNIT_ASSERT_EQUAL(err, ENOERR, err);
+
+ /* Initialize a mutex object */
+ err = pthread_mutex_init(&mutex, &mutexAttr);
+ ICUNIT_ASSERT_EQUAL(err, ENOERR, err);
+
+ /* Get the prioceiling of the mutex. */
+ err = pthread_mutex_getprioceiling(&mutex, &prioceiling);
+ ICUNIT_ASSERT_EQUAL(err, ENOERR, err);
+
+ err = pthread_mutexattr_destroy(&mutexAttr);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT1);
+
+ err = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT2);
+
+ return LOS_OK;
+
+EXIT1:
+ pthread_mutexattr_destroy(&mutexAttr);
+
+EXIT2:
+ pthread_mutex_destroy(&mutex);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux032(void)
+{
+ TEST_ADD_CASE("ItPosixMux032", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_033.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_033.c
new file mode 100644
index 0000000000000000000000000000000000000000..cd4443ff822736663e9ca091554f90d6074d92fb
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_033.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_getprioceiling 3-1.c
+ * Test that pthread_mutex_getprioceiling() fails because:
+ *
+ * [EINVAL]
+ * The protocol attribute of mutex is PTHREAD_PRIO_NONE.
+ *
+ * by not specifying PTHREAD_PRIO_NONE and noting that the default (as per
+ * pthread_mutexattr_getprotocol) is PTHREAD_PRIO_NONE.
+ *
+ * Steps:
+ * 1. Initialize a mutex via pthread_mutex_init.
+ * 2. Do not modify the mutex.
+ * 3. Call pthread_mutex_getprioceiling() to obtain the prioceiling.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+ int err, prioceiling;
+
+ /* Initialize a mutex object */
+ err = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(err, ENOERR, err);
+
+ /* Get the prioceiling of the mutex. */
+ err = pthread_mutex_getprioceiling(&mutex, &prioceiling);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT);
+
+ err = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutex_destroy(&mutex);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux033(void)
+{
+ TEST_ADD_CASE("ItPosixMux033", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_034.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_034.c
new file mode 100644
index 0000000000000000000000000000000000000000..763603021ded53f9e390a0b9a5b8800d36df423e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_034.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_getprioceiling 3-2.c
+ * Test that pthread_mutex_getprioceiling() fails because:
+ *
+ * [EINVAL]
+ * The protocol attribute of mutex is PTHREAD_PRIO_NONE.
+ *
+ * by explicitly specifying the protocol as PTHREAD_PRIO_NONE.
+ *
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init()
+ * 2. Explicitly set the protocol using PTHREAD_PRIO_NONE.
+ * 3. Call pthread_mutex_getprioceiling() to obtain the prioceiling.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mutexAttr;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+ int err, prioceiling;
+
+ err = pthread_mutexattr_init(&mutexAttr);
+ ICUNIT_ASSERT_EQUAL(err, ENOERR, err);
+
+ /*
+ * The default protocol is PTHREAD_PRIO_NONE according to
+ * pthread_mutexattr_getprotocol.
+ */
+ err = pthread_mutexattr_setprotocol(&mutexAttr, PTHREAD_PRIO_NONE);
+ ICUNIT_ASSERT_EQUAL(err, ENOERR, err);
+
+ /* Initialize a mutex object */
+ err = pthread_mutex_init(&mutex, &mutexAttr);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT1);
+
+ /* Get the prioceiling of the mutex. */
+ err = pthread_mutex_getprioceiling(&mutex, &prioceiling);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT2);
+
+ err = pthread_mutexattr_destroy(&mutexAttr);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT1);
+
+ err = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT2);
+
+ return LOS_OK;
+
+EXIT2:
+ pthread_mutex_destroy(&mutex);
+
+EXIT1:
+ pthread_mutexattr_destroy(&mutexAttr);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux034(void)
+{
+ TEST_ADD_CASE("ItPosixMux034", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_035.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_035.c
new file mode 100644
index 0000000000000000000000000000000000000000..1c26f5849d2c3bc5124006cfa7beb5c2bd032af9
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_035.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_getprioceiling 3-3.c
+ * Test that pthread_mutex_getprioceiling() fails because:
+ *
+ * [EINVAL]
+ * The protocol attribute of mutex is PTHREAD_PRIO_NONE.
+ *
+ * by explicitly specifying the protocol as PTHREAD_PRIO_NONE.
+ *
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init()
+ * 2. Explicitly set the protocol using PTHREAD_PRIO_NONE.
+ * 3. Call pthread_mutex_getprioceiling() to obtain the prioceiling.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mutexAttr;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+ int err, prioceiling;
+
+ err = pthread_mutexattr_init(&mutexAttr);
+ ICUNIT_ASSERT_EQUAL(err, ENOERR, err);
+
+ /*
+ * The default protocol is PTHREAD_PRIO_NONE according to
+ * pthread_mutexattr_getprotocol.
+ */
+ err = pthread_mutexattr_setprotocol(&mutexAttr, PTHREAD_PRIO_INHERIT);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT1);
+
+ /* Initialize a mutex object */
+ err = pthread_mutex_init(&mutex, &mutexAttr);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT1);
+
+ /* Get the prioceiling of the mutex. */
+ err = pthread_mutex_getprioceiling(&mutex, &prioceiling);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT2);
+
+ err = pthread_mutexattr_destroy(&mutexAttr);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT1);
+
+ err = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(err, ENOERR, err, EXIT2);
+
+ return LOS_OK;
+
+EXIT2:
+ pthread_mutex_destroy(&mutex);
+
+EXIT1:
+ pthread_mutexattr_destroy(&mutexAttr);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux035(void)
+{
+ TEST_ADD_CASE("ItPosixMux035", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_036.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_036.c
new file mode 100644
index 0000000000000000000000000000000000000000..64f75083b32f139a947bcfc7071636e0c0c8da4c
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_036.c
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+#define THREAD_NUM 5
+#define LOOPS 4
+
+static pthread_mutex_t g_mutex036 = PTHREAD_MUTEX_INITIALIZER;
+
+/* pthread_mutex_lock 1-1.c
+ * Test that pthread_mutex_lock()
+ * shall lock the mutex object referenced by 'mutex'. If the mutex is
+ * already locked, the calling thread shall block until the mutex becomes
+ * available. This operation shall return with the mutex object referenced
+ * by 'mutex' in the locked state with the calling thread as its owner.
+
+ * Steps:
+ * -- Initialize a mutex to protect a global variable 'value'
+ * -- Create N threads. Each is looped M times to acquire the mutex,
+ * increase the value, and then release the mutex.
+ * -- Check if the value has increased properly (M*N); a broken mutex
+ * implementation may cause lost augments.
+ *
+ */
+
+static void *TaskF01(void *parm)
+{
+ int i, tmp;
+ int rc;
+
+ /* Loopd M times to acquire the mutex, increase the value,
+ and then release the mutex. */
+ for (i = 0; i < LOOPS; ++i) {
+ rc = pthread_mutex_lock(&g_mutex036);
+ if (rc != 0) {
+ return (void *)(LOS_NOK);
+ }
+
+ tmp = g_value;
+ tmp = tmp + 1;
+ sleep(1);
+ g_value = tmp;
+
+ rc = pthread_mutex_unlock(&g_mutex036);
+ if (rc != 0) {
+ return (void *)(LOS_NOK);
+ }
+ sleep(1);
+ }
+
+ return (void *)(LOS_OK);
+}
+
+static UINT32 Testcase(VOID)
+{
+ int i, rc;
+ pthread_attr_t pta;
+ pthread_t threads[THREAD_NUM];
+
+ g_value = 0;
+
+ pthread_attr_init(&pta);
+ pthread_attr_setdetachstate(&pta, PTHREAD_CREATE_JOINABLE);
+
+ /* Create threads */
+ for (i = 0; i < THREAD_NUM; ++i) {
+ rc = pthread_create(&threads[i], &pta, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ /* Wait to join all threads */
+ for (i = 0; i < THREAD_NUM; ++i) {
+ rc = pthread_join(threads[i], NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+ pthread_attr_destroy(&pta);
+ pthread_mutex_destroy(&g_mutex036);
+
+ /* Check if the final value is as expected */
+ if (g_value != (THREAD_NUM)*LOOPS) {
+ return LOS_NOK;
+ }
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux036(void)
+{
+ TEST_ADD_CASE("ItPosixMux036", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_037.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_037.c
new file mode 100644
index 0000000000000000000000000000000000000000..101b34aea9be3ac3b016e8133b9adb2c98d3766f
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_037.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_lock 2-1.c
+ * This file is licensed under the GPL license. For the full content
+ * of this license, see the COPYING file at the top level of this
+ * source tree.
+
+ * Test that pthread_mutex_lock()
+ * Upon succesful completion, it shall return a 0
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutex_t mutex;
+ int rc;
+
+ /* Initialize a mutex object with the default mutex attributes */
+ rc = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Lock the mutex using pthread_mutex_lock() */
+ rc = pthread_mutex_lock(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT1);
+
+ rc = pthread_mutex_unlock(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT2);
+
+ rc = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT1);
+
+ return LOS_OK;
+
+EXIT2:
+ pthread_mutex_unlock(&mutex);
+EXIT1:
+ pthread_mutex_destroy(&mutex);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux037(void)
+{
+ TEST_ADD_CASE("ItPosixMux037", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_038.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_038.c
new file mode 100644
index 0000000000000000000000000000000000000000..cef2e59a5eecc615d0917942e2e52c3506c08062
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_038.c
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex038;
+static sem_t g_sem038;
+
+/* pthread_mutex_lock 4-1.c
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ * This sample test aims to check the following assertion:
+ *
+ * If the mutex type is PTHREAD_MUTEX_RECURSIVE,
+ * then the mutex maintains the concept of a lock count.
+ * When a thread successfully acquires a mutex for the first time,
+ * the lock count is set to one. Every time a thread relocks this mutex,
+ * the lock count is incremented by one.
+ * Each time the thread unlocks the mutex,
+ * the lock count is decremented by one.
+ * When the lock count reaches zero,
+ * the mutex becomes available and others threads can acquire it.
+
+ * The steps are:
+ * ->Create a mutex with recursive attribute
+ * ->Create a threads
+ * ->Parent locks the mutex twice, unlocks once.
+ * ->Child attempts to lock the mutex.
+ * ->Parent unlocks the mutex.
+ * ->Parent unlocks the mutex (shall fail)
+ * ->Child unlocks the mutex.
+ */
+static void *TaskF01(void *arg)
+{
+ int ret;
+
+ /* Try to lock the mutex once. The call must fail here. */
+ ret = pthread_mutex_trylock(&g_mutex038);
+ if (ret == 0) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+
+ /* Free the parent thread and lock the mutex (must success) */
+ if ((ret = sem_post(&g_sem038))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+
+ if ((ret = pthread_mutex_lock(&g_mutex038))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+
+ /* Wait for the parent to let us go on */
+ if ((ret = sem_post(&g_sem038))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+
+ /* Unlock and exit */
+ if ((ret = pthread_mutex_unlock(&g_mutex038))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ int i;
+ pthread_mutexattr_t ma;
+ pthread_t child;
+
+ /* Initialize the semaphore */
+ if ((ret = sem_init(&g_sem038, 0, 0))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* We initialize the recursive mutex */
+ if ((ret = pthread_mutexattr_init(&ma))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if ((ret = pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if ((ret = pthread_mutex_init(&g_mutex038, &ma))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if ((ret = pthread_mutexattr_destroy(&ma))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* -- The mutex is now ready for testing -- */
+
+ /* First, we lock it twice and unlock once */
+ if ((ret = pthread_mutex_lock(&g_mutex038))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if ((ret = pthread_mutex_lock(&g_mutex038))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if ((ret = pthread_mutex_unlock(&g_mutex038))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* Here this thread owns the mutex and the internal count is "1" */
+
+ /* We create the child thread */
+ if ((ret = pthread_create(&child, NULL, TaskF01, NULL))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* then wait for child to be ready */
+ if ((ret = sem_wait(&g_sem038))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* We can now unlock the mutex */
+ if ((ret = pthread_mutex_unlock(&g_mutex038))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* We wait for the child to lock the mutex */
+ if ((ret = sem_wait(&g_sem038))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* Then, try to unlock the mutex (owned by the child or unlocked) */
+ ret = pthread_mutex_unlock(&g_mutex038);
+ if (ret == ENOERR) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* Everything seems OK here */
+ if ((ret = pthread_join(child, NULL))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* Simple loop to double-check */
+ for (i = 0; i < 50; i++) { // 50, The loop frequency.
+ if ((ret = pthread_mutex_lock(&g_mutex038))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+ }
+ for (i = 0; i < 50; i++) { // 50, The loop frequency.
+ if ((ret = pthread_mutex_unlock(&g_mutex038))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+ }
+
+ ret = pthread_mutex_unlock(&g_mutex038);
+ if (ret == 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+ /* The test passed, we destroy the mutex */
+ if ((ret = pthread_mutex_destroy(&g_mutex038))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ ret = sem_destroy(&g_sem038);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux038(void)
+{
+ TEST_ADD_CASE("ItPosixMux038", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_039.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_039.c
new file mode 100644
index 0000000000000000000000000000000000000000..563e16a884c8a7427cb41beb63f2e5fbd40f7bce
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_039.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_unlock 1-1.c
+ * Test that pthread_mutex_unlock()
+ * shall release the mutex object 'mutex'.
+
+ * Steps:
+ * -- Initilize a mutex object
+ * -- Get the mutex using pthread_mutex_lock()
+ * -- Release the mutex using pthread_mutex_unlock()
+ * -- Try to get the mutex using pthread_mutex_trylock()
+ * -- Release the mutex using pthread_mutex_unlock()
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ int rc;
+ pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+ /* Get the mutex using pthread_mutex_lock() */
+ rc = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Release the mutex using pthread_mutex_unlock() */
+ rc = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Get the mutex using pthread_mutex_trylock() */
+ rc = pthread_mutex_trylock(&mutex);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Release the mutex using pthread_mutex_unlock() */
+ rc = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ rc = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutex_destroy(&mutex);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux039(void)
+{
+ TEST_ADD_CASE("ItPosixMux039", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_040.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_040.c
new file mode 100644
index 0000000000000000000000000000000000000000..4da3826782a36acb50119aeb8fddb01159805e58
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_040.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+#define THREAD_NUM 6
+#define LOOPS 3
+
+static pthread_mutex_t g_mutex040 = PTHREAD_MUTEX_INITIALIZER;
+
+/* pthread_mutex_unlock 2-1.c
+ * Test that pthread_mutex_unlock()
+ * If there are threads blocked on the mutex object referenced by 'mutex' when
+ * pthread_mutex_unlock() is called, resulting in the mutex becoming available,
+ * the scheduling policy shall determine which thread shall acquire the mutex.
+
+ * NOTES:
+ * The default scheduling policy is implementation dependent, thus this case
+ * will only demo the scheduling sequence instead of testing it.
+
+ * Steps:
+ * -- Initialize a mutex to protect a global variable 'value'
+ * -- Create N threads. Each is looped M times to acquire the mutex,
+ increase the value, and then release the mutex.
+ * -- Check if the value has increased properly (M*N); a broken mutex
+ implementation may cause lost augments.
+ *
+ */
+static void *TaskF01(void *parm)
+{
+ int i, tmp;
+ int rc;
+
+ /* Loopd M times to acquire the mutex, increase the value,
+ and then release the mutex. */
+
+ for (i = 0; i < LOOPS; ++i) {
+ rc = pthread_mutex_lock(&g_mutex040);
+ if (rc != 0) {
+ return (void *)(LOS_NOK);
+ }
+
+ tmp = g_value;
+ tmp = tmp + 1;
+ usleep(1000); // 1000, delay the increasement operation.
+ g_value = tmp;
+
+ rc = pthread_mutex_unlock(&g_mutex040);
+ if (rc != 0) {
+ return (void *)(LOS_NOK);
+ }
+ sleep(1);
+ }
+ pthread_exit(0);
+ return (void *)(LOS_OK);
+}
+
+static UINT32 Testcase(VOID)
+{
+ int i, rc;
+ pthread_t threads[THREAD_NUM];
+
+ g_value = 0;
+ /* Create threads */
+ for (i = 0; i < THREAD_NUM; ++i) {
+ rc = pthread_create(&threads[i], NULL, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ /* Wait to join all threads */
+ for (i = 0; i < THREAD_NUM; ++i) {
+ rc = pthread_join(threads[i], NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+ pthread_mutex_destroy(&g_mutex040);
+
+ /* Check if the final value is as expected */
+ if (g_value != (THREAD_NUM)*LOOPS) {
+ ICUNIT_ASSERT_EQUAL(1, 0, LOS_NOK);
+ }
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux040(void)
+{
+ TEST_ADD_CASE("ItPosixMux040", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_041.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_041.c
new file mode 100644
index 0000000000000000000000000000000000000000..ea40a1b3d30ca859c091509370183572a9eca012
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_041.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_unlock 3-1.c
+ * Test that pthread_mutex_unlock()
+ * Upon succesful completion, it shall return zero
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+ int rc;
+
+ /* Initialize a mutex object */
+ rc = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ rc = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Release the mutex using pthread_mutex_unlock() */
+ rc = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ rc = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux041(void)
+{
+ TEST_ADD_CASE("ItPosixMux041", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_042.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_042.c
new file mode 100644
index 0000000000000000000000000000000000000000..f26da6a6c648aaa317824bb78734036c83e11bcd
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_042.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex042;
+
+/* pthread_mutex_unlock 5-1.c
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+
+ * This sample test aims to check the following assertion:
+ * If the mutex type is PTHREAD_MUTEX_RECURSIVE,
+ * and a thread attempts to unlock a mutex that it does not own,
+ * an uwErr is returned.
+
+ * The steps are:
+ * -> Initialize and lock a recursive mutex
+ * -> create a child thread which tries to unlock this mutex. *
+ */
+static void *TaskF01(void *arg)
+{
+ int ret;
+ ret = pthread_mutex_unlock(&g_mutex042);
+ ICUNIT_GOTO_EQUAL(ret, EPERM, ret, EXIT);
+
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutexattr_t ma;
+ pthread_t th;
+
+ ret = pthread_mutexattr_init(&ma);
+ ICUNIT_ASSERT_EQUAL(ret, ENOERR, ret);
+
+ ret = pthread_mutex_init(&g_mutex042, &ma);
+ ICUNIT_ASSERT_EQUAL(ret, ENOERR, ret);
+
+ ret = pthread_mutex_lock(&g_mutex042);
+ ICUNIT_ASSERT_EQUAL(ret, ENOERR, ret);
+
+ /* destroy the mutex attribute object */
+ ret = pthread_mutexattr_destroy(&ma);
+ ICUNIT_ASSERT_EQUAL(ret, ENOERR, ret);
+
+ ret = pthread_create(&th, NULL, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, ENOERR, ret);
+
+ /* Let the thread terminate */
+ ret = pthread_join(th, NULL);
+ ICUNIT_GOTO_EQUAL(ret, ENOERR, ret, EXIT);
+
+ /* We can clean everything and exit */
+ ret = pthread_mutex_unlock(&g_mutex042);
+ ICUNIT_GOTO_EQUAL(ret, ENOERR, ret, EXIT);
+
+ ret = pthread_mutex_destroy(&g_mutex042);
+ ICUNIT_GOTO_EQUAL(ret, ENOERR, ret, EXIT);
+ return LOS_OK;
+
+EXIT:
+ pthread_join(th, NULL);
+ pthread_mutex_unlock(&g_mutex042);
+ pthread_mutex_destroy(&g_mutex042);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux042(void)
+{
+ TEST_ADD_CASE("ItPosixMux042", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_043.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_043.c
new file mode 100644
index 0000000000000000000000000000000000000000..83461d75abc0056c5058660f5095031c0772efe2
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_043.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_unlock 5-2.c
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+
+ * This sample test aims to check the following assertion:
+ * If the mutex type is PTHREAD_MUTEX_RECURSIVE,
+ * and a thread attempts to unlock an unlocked mutex,
+ * an uwErr is returned.
+
+ * The steps are:
+ * -> Initialize a recursive mutex
+ * -> Attempt to unlock the mutex when it is unlocked
+ * and when it has been locked then unlocked.
+ */
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+ pthread_mutexattr_t ma;
+
+ ret = pthread_mutexattr_init(&ma);
+ if (ret != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ ret = pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE);
+ if (ret != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ ret = pthread_mutex_init(&mutex, &ma);
+ if (ret != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ ret = pthread_mutex_unlock(&mutex);
+ if (ret == 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ ret = pthread_mutex_lock(&mutex);
+ if (ret != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+ ret = pthread_mutex_lock(&mutex);
+ if (ret != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+ ret = pthread_mutex_unlock(&mutex);
+ if (ret != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+ ret = pthread_mutex_unlock(&mutex);
+ if (ret != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* destroy the mutex attribute object */
+ ret = pthread_mutexattr_destroy(&ma);
+ if (ret != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ ret = pthread_mutex_unlock(&mutex);
+ if (ret == 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ if (ret == 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux043(void)
+{
+ TEST_ADD_CASE("ItPosixMux043", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_044.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_044.c
new file mode 100644
index 0000000000000000000000000000000000000000..f0af9e21dd3ffd0babd331152be21e612009e5ea
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_044.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex044 = PTHREAD_MUTEX_INITIALIZER;
+static int g_t1Start = 0;
+static int g_t1Pause = 1;
+
+static void *TaskF01(void *parm)
+{
+ int rc;
+ if ((rc = pthread_mutex_lock(&g_mutex044)) != 0) {
+ ICUNIT_GOTO_EQUAL(1, 0, rc, EXIT);
+ }
+
+ g_t1Start = 1;
+
+ g_testCount++;
+
+ while (g_t1Pause)
+ sleep(1);
+
+ g_testCount++;
+
+ if ((rc = pthread_mutex_unlock(&g_mutex044)) != 0) {
+ ICUNIT_GOTO_EQUAL(1, 0, rc, EXIT);
+ }
+ g_testCount++;
+
+EXIT:
+ pthread_exit(0);
+ return (void *)(LOS_OK);
+}
+
+static UINT32 Testcase(VOID)
+{
+ int i, rc;
+ pthread_t t1;
+ g_testCount = 0;
+
+ /* Create a secondary thread and wait until it has locked the mutex */
+ rc = pthread_create(&t1, NULL, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ while (!g_t1Start) {
+ sleep(1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ /* Trylock the mutex and expect it returns EBUSY */
+ rc = pthread_mutex_trylock(&g_mutex044);
+ if (rc != EBUSY) {
+ ICUNIT_ASSERT_EQUAL(1, 0, rc);
+ }
+
+ /* Allow the secondary thread to go ahead */
+ g_t1Pause = 0;
+ /* Trylock the mutex for N times */
+ for (i = 0; i < 5; i++) { // 5, The loop frequency.
+ rc = pthread_mutex_trylock(&g_mutex044);
+ if (rc == 0) {
+ pthread_mutex_unlock(&g_mutex044);
+ break;
+ } else if (rc == EBUSY) {
+ sleep(1);
+ continue;
+ } else {
+ ICUNIT_ASSERT_EQUAL(1, 0, rc);
+ }
+ }
+
+ /* Clean up */
+ pthread_join(t1, NULL);
+ pthread_mutex_destroy(&g_mutex044);
+
+ if (i >= 5) { // 5, The loop frequency.
+ ICUNIT_ASSERT_EQUAL(1, 0, LOS_NOK);
+ }
+
+ g_t1Pause = 1;
+ g_t1Start = 0;
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux044(void)
+{
+ TEST_ADD_CASE("ItPosixMux044", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_045.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_045.c
new file mode 100644
index 0000000000000000000000000000000000000000..185691e503c0be08c1f90284611a5298eb19d756
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_045.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static pthread_mutex_t g_mutex045;
+
+/* pthread_mutex_trylock 1-2.c
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ * This sample test aims to check the following assertion:
+ *
+ * The pthread_mutex_trylock() function locks the mutex object
+ * when it is unlocked.
+
+ * The steps are:
+ *
+ * -> For each kind of mutex,
+ * -> trylock the mutex. It shall suceed.
+ * -> trylock the mutex again. It shall fail (except in case of recursive mutex).
+ * -> create a new child (either thread or process)
+ * -> the new child trylock the mutex. It shall fail.
+ * -> undo everything.
+ */
+static VOID *TaskF01(void *argument)
+{
+ int ret;
+ ret = pthread_mutex_trylock(&g_mutex045);
+ ICUNIT_GOTO_EQUAL(ret, EBUSY, ret, EXIT);
+
+ return NULL;
+
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int ret;
+
+ pthread_attr_t attr;
+ pthread_t newTh;
+
+ ret = pthread_mutexattr_init(&mta);
+ ret = pthread_mutex_init(&g_mutex045, &mta);
+
+ ret = pthread_mutex_trylock(&g_mutex045);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&g_mutex045);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex045);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ pthread_mutex_destroy(&g_mutex045);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux045(void)
+{
+ TEST_ADD_CASE("ItPosixMux045", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_046.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_046.c
new file mode 100644
index 0000000000000000000000000000000000000000..08ada66f2df0a44297a3f6f0fcc7a8311600c400
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_046.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static pthread_mutex_t g_mutex046;
+static UINT32 g_nID;
+
+/* pthread_mutex_trylock 2-1.c
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ * This sample test aims to check the following assertion:
+ *
+ * If the mutex is of type PTHREAD_MUTEX_RECURSIVE,
+ * and the calling thread already owns the mutex,
+ * the call is successful (the lock count is incremented).
+
+ * The steps are:
+ *
+ * -> trylock the mutex. It shall suceed.
+ * -> trylock the mutex again. It shall suceed again
+ * -> unlock once
+ * -> create a new child (either thread or process)
+ * -> the new child trylock the mutex. It shall fail.
+ * -> Unlock. It shall succeed.
+ * -> Unlock again. It shall fail.
+ * -> undo everything.
+ */
+static void *TaskF01(void *arg)
+{
+ int ret;
+ ret = pthread_mutex_trylock(&g_mutex046);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ g_nID = OsCurrTaskGet()->taskID;
+ LOS_TaskSuspend(OsCurrTaskGet()->taskID);
+
+ ret = pthread_mutex_unlock(&g_mutex046);
+
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ ret = pthread_mutex_init(&g_mutex046, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&g_mutex046);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&g_mutex046);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex046);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex046);
+ ICUNIT_ASSERT_EQUAL(ret, EPERM, ret);
+
+ LOS_TaskResume(g_nID);
+
+ ret = pthread_mutex_unlock(&g_mutex046);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, ENOERR, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex046);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux046(void)
+{
+ TEST_ADD_CASE("ItPosixMux046", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_047.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_047.c
new file mode 100644
index 0000000000000000000000000000000000000000..a2c6d8fc37378f58bb91cc68c26578668c7c5648
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_047.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+/* pthread_mutex_trylock 3-1.c
+ * Test that pthread_mutex_trylock()
+ * Upon succesful completion, it shall return a 0
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ int rc;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+ /* Initialize a mutex object with the default mutex attributes */
+ if ((rc = pthread_mutex_init(&mutex, NULL)) != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, rc);
+ }
+
+ /* Try to lock the mutex using pthread_mutex_trylock() */
+ if ((rc = pthread_mutex_trylock(&mutex)) == 0) {
+ pthread_mutex_unlock(&mutex);
+ pthread_mutex_destroy(&mutex);
+ return LOS_OK;
+
+ /* Check if returned values are tolerable */
+ /* PATCH: since we are using the mutex properly, */
+ /* errors are NOT tolerable here */
+ } else if (rc == EBUSY) {
+ ICUNIT_ASSERT_EQUAL(1, 0, rc);
+ } else if (rc == EINVAL) {
+ ICUNIT_ASSERT_EQUAL(1, 0, rc);
+ } else if (rc == EAGAIN) {
+ ICUNIT_ASSERT_EQUAL(1, 0, rc);
+ }
+}
+
+
+VOID ItPosixMux047(void)
+{
+ TEST_ADD_CASE("ItPosixMux047", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_048.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_048.c
new file mode 100644
index 0000000000000000000000000000000000000000..331c0fcb1e86f899ac9d84eaad03061d7032d637
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_048.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_trylock 4-1.c
+ * Test that pthread_mutex_trylock()
+ * Upon failure, it shall return:
+ * -[EBUSY] The mutex could not be acquired because it was already locked.
+
+ * Steps:
+ * -- Initilize a mutex object
+ * -- Lock the mutex using pthread_mutex_lock()
+ * -- Try to lock the mutex using pthread_mutex_trylock() and expect EBUSY
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ int rc;
+ pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+ if ((rc = pthread_mutex_lock(&mutex)) != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, rc);
+ }
+
+ rc = pthread_mutex_trylock(&mutex);
+ if (rc != EBUSY) {
+ ICUNIT_ASSERT_EQUAL(1, 0, rc);
+ }
+
+ pthread_mutex_unlock(&mutex);
+ pthread_mutex_destroy(&mutex);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux048(void)
+{
+ TEST_ADD_CASE("ItPosixMux048", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_049.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_049.c
new file mode 100644
index 0000000000000000000000000000000000000000..21baa319f0aefe7ab9085f76e8aad69b65fa0d6d
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_049.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex049;
+
+/* pthread_mutex_trylock 4-2.c
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ * This sample test aims to check the following assertion:
+ *
+ * If the mutex was already locked, the call returns EBUSY immediatly.
+
+ * The steps are:
+ * -> Set a timeout.
+ * -> For each kind of mutex,
+ * -> Lock the mutex.
+ * -> create a new child (either thread or process)
+ * -> the new child trylock the mutex. It shall fail.
+ * -> undo everything.
+ */
+static VOID *TaskF01(void *argument)
+{
+ int ret;
+ ret = pthread_mutex_trylock(&g_mutex049);
+ ICUNIT_GOTO_EQUAL(ret, 16, ret, EXIT); // 16, Here, assert the g_testCount.
+
+ return NULL;
+
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int ret;
+
+ pthread_attr_t attr;
+ pthread_t newTh;
+
+ ret = pthread_mutexattr_init(&mta);
+ ret = pthread_mutex_init(&g_mutex049, &mta);
+
+ ret = pthread_mutex_lock(&g_mutex049);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex049);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ pthread_mutex_destroy(&g_mutex049);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux049(void)
+{
+ TEST_ADD_CASE("ItPosixMux049", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_050.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_050.c
new file mode 100644
index 0000000000000000000000000000000000000000..7f355e7c6937330a4219fc208ffa6f3446128888
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_050.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex050;
+
+static void *TaskF01(void *argument)
+{
+ int ret;
+ LOS_TaskLock();
+
+ ret = pthread_mutex_lock(&g_mutex050);
+ ICUNIT_GOTO_EQUAL(ret, EDEADLK, ret, EXIT);
+
+ ret = pthread_mutex_lock(&g_mutex050);
+ ICUNIT_GOTO_EQUAL(ret, EDEADLK, ret, EXIT);
+
+ LOS_TaskUnlock();
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutexattr_t mta;
+
+ pthread_attr_t attr;
+ pthread_t newTh;
+
+ ret = pthread_mutexattr_init(&mta);
+
+ ret = pthread_mutex_init(&g_mutex050, &mta);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = pthread_mutex_lock(&g_mutex050);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ TestBusyTaskDelay(3); // 3, Set the timeout of runtime.
+
+ ret = pthread_mutex_unlock(&g_mutex050);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)pthread_mutex_destroy(&g_mutex050);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+EXIT:
+ ret = pthread_mutex_destroy(&g_mutex050);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+}
+
+
+VOID ItPosixMux050(void)
+{
+ TEST_ADD_CASE("ItPosixMux050", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_054.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_054.c
new file mode 100644
index 0000000000000000000000000000000000000000..e46bea03c794e486909d6b0f392f7143d18345f3
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_054.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutexattr_t mta;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&mutex, &mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutexattr_destroy(&mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux054(void)
+{
+ TEST_ADD_CASE("ItPosixMux054", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_055.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_055.c
new file mode 100644
index 0000000000000000000000000000000000000000..940914419ae2595cd3d5f5724ee247ec2c942060
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_055.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutexattr_t mta;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&mutex, &mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ (void)pthread_mutexattr_destroy(&mta);
+ pthread_mutex_destroy(&mutex);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux055(void)
+{
+ TEST_ADD_CASE("ItPosixMux055", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_056.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_056.c
new file mode 100644
index 0000000000000000000000000000000000000000..7cfdf8450276da61ac6f5b6aaadf1db3564e2521
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_056.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex056;
+
+static VOID *TaskF01(void *argument)
+{
+ int ret;
+
+ ret = pthread_mutex_trylock(&g_mutex056);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = pthread_mutex_unlock(&g_mutex056);
+ g_testCount++;
+
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutexattr_t mta;
+
+ pthread_attr_t attr;
+ pthread_t newTh;
+
+ g_testCount = 0;
+
+ ret = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&g_mutex056, &mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_mutex_destroy(&g_mutex056);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ (void)pthread_mutexattr_destroy(&mta);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux056(void)
+{
+ TEST_ADD_CASE("ItPosixMux056", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_057.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_057.c
new file mode 100644
index 0000000000000000000000000000000000000000..c1af362f3369b940805f3aeb7bd55cc74be1b151
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_057.c
@@ -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.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutexattr_t mta;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&mutex, &mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ (void)pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux057(void)
+{
+ TEST_ADD_CASE("ItPosixMux057", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_058.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_058.c
new file mode 100644
index 0000000000000000000000000000000000000000..219c82c283a85ec9f29fbc7092fb3a0baf989075
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_058.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static pthread_mutex_t g_mutex058;
+
+static VOID HwiF01(void)
+{
+ int ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = pthread_mutex_unlock(&g_mutex058);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, EINTR, ret);
+
+ ret = pthread_mutex_lock(&g_mutex058);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, EINTR, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex058);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, EINTR, ret);
+
+ g_testCount++;
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutexattr_t mta;
+
+ g_testCount = 0;
+
+ ret = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&g_mutex058, &mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 0, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ ret = pthread_mutex_lock(&g_mutex058);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex058);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex058);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ (void)pthread_mutexattr_destroy(&mta);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux058(void)
+{
+ TEST_ADD_CASE("ItPosixMux058", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_059.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_059.c
new file mode 100644
index 0000000000000000000000000000000000000000..a2630d053757baa207885f588b85f05cd5287403
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_059.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutexattr_t mta;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ sem_t sem;
+ int pshared;
+
+ ret = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&mutex, &mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_init(&sem, pshared, 2); // 2, The initial number of available semaphores.
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_wait(&sem);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem.sem->semCount;
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+
+ ret = sem_wait(&sem);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_post(&sem);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_wait(&sem);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_destroy(&sem);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ (void)pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux059(void)
+{
+ TEST_ADD_CASE("ItPosixMux059", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_060.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_060.c
new file mode 100644
index 0000000000000000000000000000000000000000..7d4bda07b7464030b29666ea54b35a753271447e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_060.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex060;
+
+static VOID HwiF01(void)
+{
+ int ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = pthread_mutex_lock(&g_mutex060);
+ ICUNIT_ASSERT_NOT_EQUAL_VOID(ret, 0, ret);
+
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutexattr_t mta;
+
+ g_testCount = 0;
+
+ ret = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&g_mutex060, &mta);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 0, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_mutex_lock(&g_mutex060);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex060);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex060);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ (void)pthread_mutexattr_destroy(&mta);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux060(void)
+{
+ TEST_ADD_CASE("ItPosixMux060", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_061.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_061.c
new file mode 100644
index 0000000000000000000000000000000000000000..a3aec68c9c4b3ff4120d0b70655336008298abdf
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_061.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_init(NULL, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux061(void)
+{
+ TEST_ADD_CASE("ItPosixMux061", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_062.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_062.c
new file mode 100644
index 0000000000000000000000000000000000000000..cc1dab6f78fa07118da125e9ae0c988eb757e80f
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_062.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_destroy(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutex_destroy(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux062(void)
+{
+ TEST_ADD_CASE("ItPosixMux062", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_063.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_063.c
new file mode 100644
index 0000000000000000000000000000000000000000..b4ad2728409a300fbe95876b6edb981b8f844030
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_063.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_lock(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux063(void)
+{
+ TEST_ADD_CASE("ItPosixMux063", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_064.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_064.c
new file mode 100644
index 0000000000000000000000000000000000000000..95e00c2e1968be5a46d6bec67274c8c27a83eb92
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_064.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_trylock(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux064(void)
+{
+ TEST_ADD_CASE("ItPosixMux064", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_065.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_065.c
new file mode 100644
index 0000000000000000000000000000000000000000..e473c7986d2cd2463e2a617c04e527b362aa26ac
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_065.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_unlock(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux065(void)
+{
+ TEST_ADD_CASE("ItPosixMux065", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_066.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_066.c
new file mode 100644
index 0000000000000000000000000000000000000000..6e81eabe5b44fe1da179ada466954e1c9444c5b4
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_066.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex066;
+
+static void *TaskF01(void *argv)
+{
+ UINT32 ret;
+ g_testCount++;
+
+ ret = pthread_mutex_trylock(&g_mutex066);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&g_mutex066);
+ ICUNIT_TRACK_EQUAL(ret, EBUSY, ret);
+
+ LOS_TaskDelay(2); // 2, set delay time.
+
+ ret = pthread_mutex_unlock(&g_mutex066);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex066);
+ ICUNIT_TRACK_NOT_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ g_testCount = 0;
+
+ ret = pthread_mutex_init(&g_mutex066, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_mutex_destroy(&g_mutex066);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ LOS_TaskDelay(3); // 3, set delay time.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Assert that g_testCount.
+
+ ret = pthread_mutex_destroy(&g_mutex066);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux066(void)
+{
+ TEST_ADD_CASE("ItPosixMux066", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_067.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_067.c
new file mode 100644
index 0000000000000000000000000000000000000000..bc37665057537270a4469fa8dbfe52d16d83a18a
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_067.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex067;
+
+static int HwiF01(void)
+{
+ UINT32 ret;
+
+ TEST_HwiClear(HWI_NUM_TEST);
+
+ ret = pthread_mutex_init(&g_mutex067, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&g_mutex067);
+ ICUNIT_ASSERT_EQUAL(ret, EINTR, ret);
+
+ ret = pthread_mutex_lock(&g_mutex067);
+ ICUNIT_ASSERT_EQUAL(ret, EINTR, ret);
+
+ ret = pthread_mutex_trylock(&g_mutex067);
+ ICUNIT_ASSERT_EQUAL(ret, EINTR, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex067);
+ ICUNIT_ASSERT_EQUAL(ret, EINTR, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex067);
+ ICUNIT_ASSERT_EQUAL(ret, EINTR, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex067);
+ ICUNIT_ASSERT_EQUAL(ret, EINTR, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex067);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ g_testCount++;
+
+ return LOS_OK;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ g_testCount = 0;
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 0, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux067(void)
+{
+ TEST_ADD_CASE("ItPosixMux067", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_068.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_068.c
new file mode 100644
index 0000000000000000000000000000000000000000..a4e35c2eca7b8e98a8a9d118a0203687289c2674
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_068.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex068;
+
+static VOID *TaskF01(void *argv)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = pthread_mutex_lock(&g_mutex068);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+
+ LOS_TaskDelay(30); // 30, set delay time.
+
+ ret = pthread_mutex_unlock(&g_mutex068);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(100); // 100, set delay time.
+
+ return NULL;
+}
+static VOID *TaskF02(void *argv)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = pthread_mutex_lock(&g_mutex068);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+
+ LOS_TaskDelay(30); // 30, set delay time.
+
+ ret = pthread_mutex_unlock(&g_mutex068);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(100); // 100, set delay time.
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+ pthread_t newTh2;
+ pthread_attr_t attr2;
+
+ ret = pthread_mutex_init(&g_mutex068, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ g_testCount = 0;
+
+ LOS_TaskLock();
+
+ ret = PosixPthreadInit(&attr, 10); // 10, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr2, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh2, &attr2, TaskF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskUnlock();
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, Assert that g_testCount.
+
+ LOS_TaskDelay(40); // 40, set delay time.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, Assert that g_testCount.
+
+ LOS_TaskDelay(30); // 30, set delay time.
+
+ ret = pthread_mutex_destroy(&g_mutex068);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux068(void)
+{
+ TEST_ADD_CASE("ItPosixMux068", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_069.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_069.c
new file mode 100644
index 0000000000000000000000000000000000000000..b65071acaa89c24ec9a1562eb0c49c948b838fc0
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_069.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex069;
+
+static VOID *TaskF01(void *argv)
+{
+ UINT32 ret;
+
+ ret = pthread_mutex_lock(&g_mutex069);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ret = pthread_mutex_unlock(&g_mutex069);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+
+ ret = pthread_mutex_trylock(&g_mutex069);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ret = pthread_mutex_unlock(&g_mutex069);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ ret = pthread_mutex_init(&g_mutex069, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ ret = pthread_mutex_unlock(&g_mutex069);
+ ICUNIT_ASSERT_EQUAL(ret, EPERM, ret);
+
+ LOS_TaskDelay(15); // 15, set delay time.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_mutex_unlock(&g_mutex069);
+ ICUNIT_ASSERT_EQUAL(ret, EPERM, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+
+ ret = pthread_mutex_unlock(&g_mutex069);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Assert that g_testCount.
+
+ ret = pthread_mutex_destroy(&g_mutex069);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux069(void)
+{
+ TEST_ADD_CASE("ItPosixMux069", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_070.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_070.c
new file mode 100644
index 0000000000000000000000000000000000000000..9c14d8c7ad0d52f8f95477e79182a53dac1a92cb
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_070.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex070;
+
+static VOID *TaskF01(void *arg)
+{
+ int i;
+ UINT32 ret;
+
+ g_testCount = 0;
+
+ ret = pthread_mutex_lock(&g_mutex070);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ for (i = 1; i <= 10; i++) { // 10, The loop frequency.
+ g_testCount++;
+ }
+
+ ret = pthread_mutex_unlock(&g_mutex070);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 10, g_testCount); // 10, Here, assert that g_testCount is equal to 30.
+
+ ret = LOS_EventWrite(&g_eventCB, 0x1);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static VOID *TaskF02(void *arg)
+{
+ int i;
+ UINT32 ret;
+
+ ret = pthread_mutex_lock(&g_mutex070);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ for (i = 1; i <= 10; i++) { // 10, The loop frequency.
+ g_testCount += 2; // 2, Set g_testCount.
+ }
+
+ ret = pthread_mutex_unlock(&g_mutex070);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 30, g_testCount); // 30, Here, assert that g_testCount is equal to 30.
+
+ ret = LOS_EventWrite(&g_eventCB, 0x10);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+ pthread_t newTh2;
+ pthread_attr_t attr2;
+
+ ret = pthread_mutex_init(&g_mutex070, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = LOS_EventInit(&g_eventCB);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ LOS_TaskLock();
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr2, 4); // 4, Set thread priority.
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, TaskF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ LOS_TaskUnlock();
+
+ ret = LOS_EventRead(&g_eventCB, 0x11, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
+ ICUNIT_GOTO_EQUAL(ret, 0x11, ret, EXIT3);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = LOS_EventDestroy(&g_eventCB);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = pthread_mutex_destroy(&g_mutex070);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return 0;
+
+EXIT3:
+ PosixPthreadDestroy(&attr, newTh2);
+
+EXIT2:
+ PosixPthreadDestroy(&attr, newTh);
+
+EXIT1:
+ LOS_EventDestroy(&g_eventCB);
+
+EXIT:
+ pthread_mutex_destroy(&g_mutex070);
+ return 0;
+}
+
+
+VOID ItPosixMux070(void)
+{
+ TEST_ADD_CASE("ItPosixMux070", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_071.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_071.c
new file mode 100644
index 0000000000000000000000000000000000000000..96cc70e7ebf2051393b94bdf06dff819f1be1475
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_071.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex071;
+
+static VOID *TaskF01(void *arg)
+{
+ UINT32 ret;
+ ret = pthread_mutex_lock(&g_mutex071);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ LOS_TaskDelay(20); // 20, set delay time.
+ ret = pthread_mutex_unlock(&g_mutex071);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2.
+ g_testCount++;
+
+ return LOS_OK;
+}
+
+static VOID *TaskF02(void *arg)
+{
+ UINT32 ret;
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = pthread_mutex_lock(&g_mutex071);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+ TestBusyTaskDelay(1);
+ ICUNIT_TRACK_EQUAL(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to 3.
+ g_testCount++;
+
+ ret = pthread_mutex_unlock(&g_mutex071);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to 4.
+ g_testCount++;
+
+ return LOS_OK;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ pthread_t newTh2;
+ pthread_attr_t attr2;
+
+ ret = pthread_mutex_init(&g_mutex071, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr2, 10); // 10, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh2, &attr2, TaskF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(50); // 50, set delay time.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, Assert that g_testCount.
+
+ ret = pthread_mutex_destroy(&g_mutex071);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux071(void)
+{
+ TEST_ADD_CASE("ItPosixMux071", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_072.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_072.c
new file mode 100644
index 0000000000000000000000000000000000000000..8a810f2843676fd95287749a8be009e9e16c31e8
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_072.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex072;
+
+static VOID *TaskF01(void *arg)
+{
+ UINT32 ret;
+ ret = pthread_mutex_lock(&g_mutex072);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = pthread_mutex_unlock(&g_mutex072);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(6); // 6, set delay time.
+ ICUNIT_TRACK_EQUAL(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to 4.
+ g_testCount++;
+
+ return LOS_OK;
+}
+
+static VOID *TaskF02(void *arg)
+{
+ UINT32 ret;
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+
+ ret = pthread_mutex_lock(&g_mutex072);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2.
+ g_testCount++;
+
+ ret = pthread_mutex_unlock(&g_mutex072);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ICUNIT_TRACK_EQUAL(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to 3.
+ g_testCount++;
+
+ return LOS_OK;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ pthread_t newTh2;
+ pthread_attr_t attr2;
+
+ ret = pthread_mutex_init(&g_mutex072, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr, 10); // 10, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr2, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh2, &attr2, TaskF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(8); // 8, set delay time.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, Assert that g_testCount.
+
+ ret = pthread_mutex_destroy(&g_mutex072);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux072(void)
+{
+ TEST_ADD_CASE("ItPosixMux072", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_073.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_073.c
new file mode 100644
index 0000000000000000000000000000000000000000..2ccab35b3e985f151e84f09e58fc6a68a8b594db
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_073.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux073(void)
+{
+ TEST_ADD_CASE("ItPosixMux073", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_074.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_074.c
new file mode 100644
index 0000000000000000000000000000000000000000..b0bbae94a179e0f4a43c5a7989e1f0d5ff0546ac
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_074.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex074;
+static sem_t g_sem074;
+static int g_pshared074;
+
+static VOID *TaskF01(void *arg)
+{
+ UINT32 ret;
+ ret = pthread_mutex_lock(&g_mutex074);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+
+ LOS_TaskDelay(5); // 5, set delay time.
+
+ ret = sem_wait(&g_sem074);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 5, g_testCount); // 5, Here, assert that g_testCount is equal to 5.
+
+ ret = sem_post(&g_sem074);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 6, g_testCount); // 6, Here, assert that g_testCount is equal to 6.
+
+ ret = pthread_mutex_unlock(&g_mutex074);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+static VOID *TaskF02(void *arg)
+{
+ UINT32 ret;
+ LOS_TaskDelay(1);
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2.
+
+ ret = pthread_mutex_lock(&g_mutex074);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 7, g_testCount); // 7, Here, assert that g_testCount is equal to 7.
+
+ ret = pthread_mutex_unlock(&g_mutex074);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+static VOID *TaskF03(void *arg)
+{
+ UINT32 ret;
+
+ LOS_TaskDelay(2); // 2, set delay time.
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to 3.
+
+ ret = sem_wait(&g_sem074);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to 4.
+
+ LOS_TaskDelay(4); // 4, set delay time.
+ ret = sem_post(&g_sem074);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 8, g_testCount); // 8, Here, assert that g_testCount is equal to 8.
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+ pthread_t newTh2;
+ pthread_attr_t attr2;
+ pthread_t newTh3;
+ pthread_attr_t attr3;
+ g_testCount = 0;
+
+ ret = pthread_mutex_init(&g_mutex074, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_init(&g_sem074, g_pshared074, 2); // 2, The initial number of available semaphores.
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 15); // 15, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr2, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh2, &attr2, TaskF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr3, 10); // 10, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh3, &attr3, TaskF03, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(10); // 10, set delay time.
+ ret = pthread_mutex_destroy(&g_mutex074);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_destroy(&g_sem074);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr3, newTh3);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux074(void)
+{
+ TEST_ADD_CASE("ItPosixMux074", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_075.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_075.c
new file mode 100644
index 0000000000000000000000000000000000000000..20decee81464d8678d2f805a3570835a9037b298
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_075.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex075;
+static sem_t g_sem075;
+static int g_pshared075;
+
+static VOID *TaskF01(void *arg)
+{
+ UINT32 ret;
+ ret = pthread_mutex_lock(&g_mutex075);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 3, g_testCount); // 3, Here, assert that g_testCount is equal to 3.
+
+ ret = sem_wait(&g_sem075);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 6, g_testCount); // 6, Here, assert that g_testCount is equal to 6.
+
+ ret = sem_post(&g_sem075);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 7, g_testCount); // 7, Here, assert that g_testCount is equal to 7.
+
+ ret = pthread_mutex_unlock(&g_mutex075);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+static VOID *TaskF02(void *arg)
+{
+ UINT32 ret;
+ LOS_TaskDelay(2); // 2, set delay time.
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to 4.
+
+ ret = pthread_mutex_lock(&g_mutex075);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret); //
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 8, g_testCount); // 8, Here, assert that g_testCount is equal to 8.
+
+ ret = pthread_mutex_unlock(&g_mutex075);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+static VOID *TaskF03(void *arg)
+{
+ UINT32 ret;
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert that g_testCount is equal to 2.
+
+ LOS_TaskDelay(3); // 3, set delay time.
+
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 5, g_testCount); // 5, Here, assert that g_testCount is equal to 5.
+
+ ret = sem_post(&g_sem075);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(1);
+ g_testCount++;
+ ICUNIT_TRACK_EQUAL(g_testCount, 9, g_testCount); // 9, Here, assert the g_testCount.
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+ pthread_t newTh2;
+ pthread_attr_t attr2;
+ pthread_t newTh3;
+ pthread_attr_t attr3;
+ g_testCount = 0;
+
+ ret = pthread_mutex_init(&g_mutex075, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_init(&g_sem075, g_pshared075, 0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 10); // 10, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF03, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr2, 15); // 15, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh2, &attr2, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr3, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh3, &attr3, TaskF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(5); // 5, set delay time.
+ ret = pthread_mutex_destroy(&g_mutex075);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_destroy(&g_sem075);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr3, newTh3);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux075(void)
+{
+ TEST_ADD_CASE("ItPosixMux075", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_076.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_076.c
new file mode 100644
index 0000000000000000000000000000000000000000..0e0288c397c27bbb65e440c6f7efb19f26f2048b
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_076.c
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex1076;
+static pthread_mutex_t g_mutex2076;
+
+static VOID *TaskF01(void *arg)
+{
+ UINT32 ret;
+ ret = pthread_mutex_lock(&g_mutex1076);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex1076);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+ pthread_mutexattr_t mutexAttr;
+ g_testCount = 0;
+
+ pthread_mutexattr_init(&mutexAttr);
+
+ pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_ERRORCHECK);
+
+ ret = pthread_mutex_init(&g_mutex1076, &mutexAttr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&g_mutex2076, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&g_mutex1076);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&g_mutex1076);
+ ICUNIT_ASSERT_EQUAL(ret, EDEADLK, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex1076);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex1076);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(5); // 5, set delay time.
+
+ ret = pthread_mutex_destroy(&g_mutex1076);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex2076);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux076(void)
+{
+ TEST_ADD_CASE("ItPosixMux076", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_077.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_077.c
new file mode 100644
index 0000000000000000000000000000000000000000..1f0ac09854efddbda9fe9ae012bc2fb99f9bf866
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_077.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex077;
+
+static VOID *TaskF01(void *arg)
+{
+ UINT32 ret;
+ ret = pthread_mutex_trylock(&g_mutex077);
+ ICUNIT_TRACK_EQUAL(ret, EBUSY, ret);
+
+ g_testCount++;
+
+ ret = pthread_mutex_lock(&g_mutex077);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex077);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+ g_testCount++;
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+ pthread_mutexattr_t mutexAttr;
+
+ g_testCount = 0;
+ ret = pthread_mutex_lock(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutex_lock(&g_mutex077);
+ ICUNIT_ASSERT_EQUAL(ret, EBADF, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex077);
+ ICUNIT_ASSERT_EQUAL(ret, EBADF, ret);
+ pthread_mutexattr_init(&mutexAttr);
+
+ pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_ERRORCHECK);
+
+ ret = pthread_mutex_init(&g_mutex077, &mutexAttr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&g_mutex077);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(5); // 5, set delay time.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_mutex_unlock(&g_mutex077);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ TestExtraTaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Assert that g_testCount.
+
+ ret = pthread_mutex_lock(&g_mutex077);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&g_mutex077);
+ ICUNIT_ASSERT_EQUAL(ret, EDEADLK, ret);
+
+ ret = pthread_mutex_lock(&g_mutex077);
+ ICUNIT_ASSERT_EQUAL(ret, EDEADLK, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex077);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex077);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex077);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex077);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux077(void)
+{
+ TEST_ADD_CASE("ItPosixMux077", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_078.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_078.c
new file mode 100644
index 0000000000000000000000000000000000000000..849091c6abeee830edf199bfe9cc05a8b2886afa
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_078.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_mutexattr_t mutexAttr;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ pthread_mutexattr_init(&mutexAttr);
+
+ pthread_mutexattr_settype(&mutexAttr, PTHREAD_MUTEX_ERRORCHECK);
+
+ ret = pthread_mutex_init(&mutex, &mutexAttr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, EDEADLK, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux078(void)
+{
+ TEST_ADD_CASE("ItPosixMux078", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_079.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_079.c
new file mode 100644
index 0000000000000000000000000000000000000000..db8b5b4fcbae7dfa913ab692cdfc19e6ea9597ac
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_079.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex079;
+static sem_t g_sem079;
+static int g_pshared084;
+
+static VOID *TaskF01(void *arg)
+{
+ UINT32 ret;
+ ret = pthread_mutex_trylock(&g_mutex079);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = sem_wait(&g_sem079);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex079);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+static VOID *TaskF02(void *arg)
+{
+ UINT32 ret;
+
+ ret = sem_post(&g_sem079);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+ return NULL;
+}
+static VOID *TaskF03(void *arg)
+{
+ UINT32 ret;
+
+ ret = pthread_mutex_lock(&g_mutex079);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex079);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+ pthread_t newTh2;
+ pthread_attr_t attr2;
+ pthread_t newTh3;
+ pthread_attr_t attr3;
+
+ ret = pthread_mutex_init(&g_mutex079, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_init(&g_sem079, g_pshared084, 0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr2, 3); // 3, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh2, &attr2, TaskF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr3, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh3, &attr3, TaskF03, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex079);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_destroy(&g_sem079);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr3, newTh3);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux079(void)
+{
+ TEST_ADD_CASE("ItPosixMux079", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_080.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_080.c
new file mode 100644
index 0000000000000000000000000000000000000000..909f17bceb4eaf13f22975d4e3e718c20a85c123
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_080.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex080;
+
+static VOID *TaskF01(void *arg)
+{
+ INT32 ret;
+ ret = pthread_mutex_unlock(&g_mutex080);
+ ICUNIT_TRACK_NOT_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ ret = pthread_mutex_init(&g_mutex080, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&g_mutex080);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(1);
+
+ ret = pthread_mutex_unlock(&g_mutex080);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex080);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux080(void)
+{
+ TEST_ADD_CASE("ItPosixMux080", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_081.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_081.c
new file mode 100644
index 0000000000000000000000000000000000000000..25ef3325a41d33862e1dd86787df3788eea2c7a6
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_081.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 prioceiling;
+ pthread_mutexattr_t mattr;
+
+ ret = pthread_mutexattr_setprioceiling(NULL, 1);
+ if (ret != EINVAL) {
+ ICUNIT_ASSERT_EQUAL(1, 0, prioceiling);
+ }
+
+ ret = pthread_mutexattr_init(&mattr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ prioceiling = mattr.prioceiling;
+ if (prioceiling != OS_TASK_PRIORITY_LOWEST) {
+ ICUNIT_ASSERT_EQUAL(1, 0, prioceiling);
+ }
+
+ ret = pthread_mutexattr_setprioceiling(&mattr, 0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ prioceiling = mattr.prioceiling;
+ if (prioceiling != 0) {
+ ICUNIT_ASSERT_EQUAL(1, 0, prioceiling);
+ }
+
+ ret = pthread_mutexattr_setprioceiling(&mattr, OS_TASK_PRIORITY_LOWEST + 1);
+ if (ret != EINVAL) {
+ ICUNIT_ASSERT_EQUAL(1, 0, prioceiling);
+ }
+
+ ret = pthread_mutexattr_setprioceiling(&mattr, OS_TASK_PRIORITY_HIGHEST - 1);
+ if (ret != EINVAL) {
+ ICUNIT_ASSERT_EQUAL(1, 0, prioceiling);
+ }
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux081(void)
+{
+ TEST_ADD_CASE("ItPosixMux081", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_082.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_082.c
new file mode 100644
index 0000000000000000000000000000000000000000..fa3ba9f14919d9a6d189ed0dcac0f48b1d16a090
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_082.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINT32 prioceiling;
+ pthread_mutexattr_t mattr;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutexattr_init(&mattr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&mutex, &mattr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_getprioceiling(&mutex, &prioceiling);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ if (prioceiling != OS_TASK_PRIORITY_LOWEST) {
+ ICUNIT_ASSERT_EQUAL(1, 0, prioceiling);
+ }
+
+ prioceiling = 8; // 8, task priority.
+ ret = pthread_mutex_setprioceiling(&mutex, prioceiling, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_getprioceiling(&mutex, &prioceiling);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ if (prioceiling != 8) { // 8, task priority.
+ ICUNIT_ASSERT_EQUAL(1, 0, prioceiling);
+ }
+
+ prioceiling = 6; // 6, task priority.
+
+ ret = pthread_mutex_setprioceiling(&mutex, prioceiling, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_getprioceiling(&mutex, &prioceiling);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ if (prioceiling != 6) { // 6, task priority.
+ ICUNIT_ASSERT_EQUAL(1, 0, prioceiling);
+ }
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux082(void)
+{
+ TEST_ADD_CASE("ItPosixMux082", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_084.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_084.c
new file mode 100644
index 0000000000000000000000000000000000000000..6a764e929842e8d0a54c0ca8d055a607098e4182
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_084.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutex_t mutex1084 = TEST_MUTEX_INIT;
+ pthread_mutex_t mutex2084 = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_init(&mutex1084, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&mutex1084);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&mutex2084, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex2084);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&mutex2084);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ ret = pthread_mutex_unlock(&mutex1084);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex1084);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex2084);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex2084);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux084(void)
+{
+ TEST_ADD_CASE("ItPosixMux084", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_085.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_085.c
new file mode 100644
index 0000000000000000000000000000000000000000..2e906dd58a94143571359675f4b18981f110579e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_085.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutexattr_t mattr;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutexattr_init(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutexattr_setprotocol(NULL, 1);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutexattr_getprotocol(NULL, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutexattr_getprioceiling(NULL, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutex_init(NULL, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutex_getprioceiling(NULL, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutex_setprioceiling(NULL, 0, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_mutexattr_init(&mattr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_init(&mutex, &mattr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux085(void)
+{
+ TEST_ADD_CASE("ItPosixMux085", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_086.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_086.c
new file mode 100644
index 0000000000000000000000000000000000000000..106e8df522feb859a751a2d36ddeee15f3d81e5b
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_086.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ mutex.attr.type = PTHREAD_MUTEX_RECURSIVE;
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux086(void)
+{
+ TEST_ADD_CASE("ItPosixMux086", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_087.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_087.c
new file mode 100644
index 0000000000000000000000000000000000000000..c1396704c9086fb7019c83514cab3807d81ca1e6
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_087.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ mutex.attr.type = PTHREAD_MUTEX_RECURSIVE;
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_trylock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux087(void)
+{
+ TEST_ADD_CASE("ItPosixMux087", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_089.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_089.c
new file mode 100644
index 0000000000000000000000000000000000000000..562597d361ceff0ec30fed943382cbdd41204e8a
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_089.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ mutex.attr.type = 1;
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux089(void)
+{
+ TEST_ADD_CASE("ItPosixMux089", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_090.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_090.c
new file mode 100644
index 0000000000000000000000000000000000000000..8af7da2f6b3b8ca3df499d2f1ce107da4310dcb3
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_090.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ mutex.attr.type = PTHREAD_MUTEX_RECURSIVE;
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux090(void)
+{
+ TEST_ADD_CASE("ItPosixMux090", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_091.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_091.c
new file mode 100644
index 0000000000000000000000000000000000000000..cfaedb2634deab26fb6b1db902dce0cf5dee85ff
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_091.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex091;
+
+static VOID *TaskF01(void *arg)
+{
+ INT32 ret;
+ ret = pthread_mutex_unlock(&g_mutex091);
+ ICUNIT_TRACK_NOT_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ ret = pthread_mutex_init(&g_mutex091, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ g_mutex091.attr.type = 1;
+
+ ret = pthread_mutex_lock(&g_mutex091);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(5); // 5, set delay time.
+
+ ret = pthread_mutex_unlock(&g_mutex091);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex091);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux091(void)
+{
+ TEST_ADD_CASE("ItPosixMux091", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_092.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_092.c
new file mode 100644
index 0000000000000000000000000000000000000000..7699b528c011dac196495c7c4306115d4d18309a
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_092.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex1092;
+static pthread_mutex_t g_mutex2092;
+
+static VOID *TaskF01(void *arg)
+{
+ INT32 ret;
+
+ ret = pthread_mutex_init(&g_mutex2092, NULL);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_mutex2092.attr.type = 1;
+
+ ret = pthread_mutex_lock(&g_mutex2092);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex2092);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ ret = pthread_mutex_init(&g_mutex1092, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ g_mutex1092.attr.type = 1;
+
+ ret = pthread_mutex_lock(&g_mutex1092);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(5); // 5, set delay time.
+
+ ret = pthread_mutex_unlock(&g_mutex1092);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex1092);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex2092);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux092(void)
+{
+ TEST_ADD_CASE("ItPosixMux092", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_093.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_093.c
new file mode 100644
index 0000000000000000000000000000000000000000..0329721f4071005cddf1feb65b61ce739e0068c8
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_093.c
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex1093;
+static pthread_mutex_t g_mutex2093;
+
+static VOID *TaskF01(void *arg)
+{
+ UINT32 ret;
+
+ ret = pthread_mutex_init(&g_mutex1093, NULL);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_mutex1093.attr.type = 1;
+
+ ret = pthread_mutex_lock(&g_mutex1093);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&g_mutex1093);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex1093);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex1093);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static VOID *TaskF02(void *arg)
+{
+ UINT32 ret;
+
+ ret = pthread_mutex_init(&g_mutex2093, NULL);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_mutex2093.attr.type = 1;
+
+ ret = pthread_mutex_lock(&g_mutex2093);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&g_mutex2093);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex2093);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex2093);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ pthread_t newTh2;
+ pthread_attr_t attr2;
+
+ ret = PosixPthreadInit(&attr, 10); // 10, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr2, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh2, &attr2, TaskF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex1093);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex2093);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux093(void)
+{
+ TEST_ADD_CASE("ItPosixMux093", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_094.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_094.c
new file mode 100644
index 0000000000000000000000000000000000000000..dc2d0a125b47e8ca05b8cd3186103cf89d93b824
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_094.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ mutex.attr.type = PTHREAD_MUTEX_ERRORCHECK;
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, EDEADLK, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux094(void)
+{
+ TEST_ADD_CASE("ItPosixMux094", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_095.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_095.c
new file mode 100644
index 0000000000000000000000000000000000000000..34c314694b350843253ebfcdd6e35545c34f91e8
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_095.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ pthread_mutex_t mutex = TEST_MUTEX_INIT;
+ ret = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ mutex.attr.type = PTHREAD_MUTEX_ERRORCHECK;
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, EDEADLK, ret);
+
+ ret = pthread_mutex_trylock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, EBUSY, ret);
+
+ ret = pthread_mutex_unlock(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&mutex);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux095(void)
+{
+ TEST_ADD_CASE("ItPosixMux095", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_097.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_097.c
new file mode 100644
index 0000000000000000000000000000000000000000..8892449f2ea2ad35502726e6b0d8c32888b3034d
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_097.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex097;
+
+static VOID *TaskF01(void *arg)
+{
+ INT32 ret;
+ ret = pthread_mutex_unlock(&g_mutex097);
+ ICUNIT_TRACK_NOT_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ ret = pthread_mutex_init(&g_mutex097, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ g_mutex097.attr.type = PTHREAD_MUTEX_ERRORCHECK;
+
+ ret = pthread_mutex_lock(&g_mutex097);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(5); // 5, set delay time.
+
+ ret = pthread_mutex_unlock(&g_mutex097);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex097);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux097(void)
+{
+ TEST_ADD_CASE("ItPosixMux097", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_098.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_098.c
new file mode 100644
index 0000000000000000000000000000000000000000..3811a2a9d587ead88c7c2d8b07a02a1944b877d5
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_098.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutex1098;
+static pthread_mutex_t g_mutex2098;
+
+static VOID *TaskF01(void *arg)
+{
+ INT32 ret;
+
+ ret = pthread_mutex_init(&g_mutex2098, NULL);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_mutex2098.attr.type = PTHREAD_MUTEX_ERRORCHECK;
+
+ ret = pthread_mutex_lock(&g_mutex2098);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex2098);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ ret = pthread_mutex_init(&g_mutex1098, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ g_mutex1098.attr.type = PTHREAD_MUTEX_ERRORCHECK;
+ ret = pthread_mutex_lock(&g_mutex1098);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(5); // 5, set delay time.
+
+ ret = pthread_mutex_unlock(&g_mutex1098);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex1098);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex2098);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux098(void)
+{
+ TEST_ADD_CASE("ItPosixMux098", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_099.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_099.c
new file mode 100644
index 0000000000000000000000000000000000000000..f6b602b54b81d7035756684304e1933590b5133d
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_099.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+pthread_mutex_t g_mutex1099;
+pthread_mutex_t g_mutex2099;
+
+static VOID *TaskF01(void *arg)
+{
+ UINT32 ret;
+
+ ret = pthread_mutex_init(&g_mutex1099, NULL);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_mutex1099.attr.type = PTHREAD_MUTEX_ERRORCHECK;
+
+ ret = pthread_mutex_lock(&g_mutex1099);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&g_mutex1099);
+ ICUNIT_TRACK_EQUAL(ret, EDEADLK, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex1099);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static VOID *TaskF02(void *arg)
+{
+ UINT32 ret;
+
+ ret = pthread_mutex_init(&g_mutex2099, NULL);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ g_mutex2099.attr.type = PTHREAD_MUTEX_ERRORCHECK;
+
+ ret = pthread_mutex_lock(&g_mutex2099);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_lock(&g_mutex2099);
+ ICUNIT_TRACK_EQUAL(ret, EDEADLK, ret);
+
+ ret = pthread_mutex_unlock(&g_mutex2099);
+ ICUNIT_TRACK_EQUAL(ret, 0, ret);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_t newTh;
+ pthread_attr_t attr;
+
+ pthread_t newTh2;
+ pthread_attr_t attr2;
+
+ ret = PosixPthreadInit(&attr, 10); // 10, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh, &attr, TaskF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadInit(&attr2, 4); // 4, Set thread priority.
+ ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
+
+ ret = pthread_create(&newTh2, &attr2, TaskF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex1099);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mutex2099);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux099(void)
+{
+ TEST_ADD_CASE("ItPosixMux099", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_101.c b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_101.c
new file mode 100644
index 0000000000000000000000000000000000000000..68e625199cc27d180119fbd1ccf4e91eebf7a1e9
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/full/It_posix_mutex_101.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 "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t g_mutexTest100 = { 0 };
+
+static VOID TestMutexInit101(UINT8 type)
+{
+ int ret;
+ pthread_mutexattr_t mta = { 0 };
+
+ /* Initialize a mutex attributes object */
+ ret = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, ENOERR, ret);
+
+ mta.type = type;
+
+ ret = pthread_mutex_init(&g_mutexTest100, &mta);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
+
+ (void)pthread_mutexattr_destroy(&mta);
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+
+ ICUNIT_ASSERT_EQUAL(OsCurrTaskGet()->priority, TASK_PRIO_TEST, OsCurrTaskGet()->priority);
+
+ TestMutexInit101(PTHREAD_MUTEX_ERRORCHECK);
+
+ ret = pthread_mutex_lock(&g_mutexTest100);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = pthread_mutex_setprioceiling(&g_mutexTest100, 21, NULL); // 21, task priority.
+ ICUNIT_GOTO_EQUAL(ret, EDEADLK, ret, EXIT1);
+
+ ret = pthread_mutex_unlock(&g_mutexTest100);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = pthread_mutex_destroy(&g_mutexTest100);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT1:
+ ret = pthread_mutex_unlock(&g_mutexTest100);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+EXIT:
+ ret = pthread_mutex_destroy(&g_mutexTest100);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return LOS_OK;
+}
+
+VOID ItPosixMux101(void)
+{
+ TEST_ADD_CASE("ItPosixMux101", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_001.c b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..814d621538a7b00dacdc93ce8ccc853edeee9760
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_001.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_init 1-1.c
+ * Test that pthread_mutexattr_init()
+ * shall initialize a mutex attributes object 'attr' with the default
+ * value for all of the attributes defined by the implementation.
+
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init()
+ * 2. Call pthread_mutexattr_getpshared() to check if the process-shared
+ * attribute is set as the default value PTHREAD_PROCESS_PRIVATE.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux001(void)
+{
+ TEST_ADD_CASE("ItPosixMux001", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_007.c b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..d834eb338ac98d21958fb7640e3223e014b0e1f4
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_007.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_setprotocol 1-1.c
+ * Test that pthread_mutexattr_setprotocol()
+ *
+ * Sets the protocol attribute of a mutexattr object (which was prev. created
+ * by the function pthread_mutexattr_init()).
+ *
+ * Steps:
+ * 1. In a for loop, call pthread_mutexattr_setprotocol with all the valid 'protocol' values.
+ * 2. In the for loop, then call pthread_mutexattr_getprotocol and ensure that the same
+ * value that was set was the same value that was retrieved from this function.
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int protocol, protcls[3], i;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ protcls[0] = PTHREAD_PRIO_NONE;
+ protcls[1] = PTHREAD_PRIO_INHERIT;
+ protcls[2] = PTHREAD_PRIO_PROTECT; // 2, priority buffer index.
+
+ for (i = 0; i < 3; i++) { // 3, The loop frequency.
+ /* Set the protocol to one of the 3 valid protocols. */
+ rc = pthread_mutexattr_setprotocol(&mta, protcls[i]);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Get the protocol mutex attr. */
+ rc = pthread_mutexattr_getprotocol(&mta, &protocol);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Make sure that the protocol set is the protocl we get when calling
+ * pthread_mutexattr_getprocol() */
+ if (protocol != protcls[i]) {
+ ICUNIT_ASSERT_EQUAL(1, 0, LOS_NOK);
+ }
+ }
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux007(void)
+{
+ TEST_ADD_CASE("ItPosixMux007", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_012.c b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_012.c
new file mode 100644
index 0000000000000000000000000000000000000000..b7e5b48d59382df141cd5864889aaa7715c24f15
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_012.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_setprioceiling 1-1.c
+ * Test that pthread_mutexattr_setprioceiling()
+ *
+ * Sets the priority ceiling attribute of a mutexattr object (which was prev. created
+ * by the function pthread_mutexattr_init()).
+ *
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init()
+ * 2. Get the min and max boundries for SCHED_FIFO of what prioceiling can be.
+ * 3. In a for loop, go through each valid SCHED_FIFO value, set the prioceiling.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int maxPrio, minPrio, i;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ maxPrio = OS_TASK_PRIORITY_HIGHEST;
+ minPrio = OS_TASK_PRIORITY_LOWEST;
+
+ for (i = maxPrio; (i < minPrio + 1); i++) {
+ /* Set the prioceiling to a priority number in the boundries
+ * of SCHED_FIFO policy */
+ rc = pthread_mutexattr_setprioceiling(&mta, i);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+ }
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux012(void)
+{
+ TEST_ADD_CASE("ItPosixMux012", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_015.c b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_015.c
new file mode 100644
index 0000000000000000000000000000000000000000..57a6b63da4c30a62e7a403636168086de964c180
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_015.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_getprioceiling 1-1.c
+ * Test that pthread_mutexattr_getprioceiling()
+ *
+ * Gets the priority ceiling attribute of a mutexattr object (which was prev. created
+ * by the function pthread_mutexattr_init()).
+ *
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init()
+ * 2. Call pthread_mutexattr_getprioceiling() to obtain the prioceiling.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t ma;
+ int prioceiling, maxPrio, minPrio, ret;
+
+ /* Initialize a mutex attributes object */
+ ret = pthread_mutexattr_init(&ma);
+ ICUNIT_ASSERT_EQUAL(ret, ENOERR, ret);
+
+ ret = pthread_mutexattr_setprotocol(&ma, PTHREAD_PRIO_PROTECT);
+ ICUNIT_GOTO_EQUAL(ret, ENOERR, ret, EXIT);
+
+ /* Get the prioceiling mutex attr. */
+ ret = pthread_mutexattr_getprioceiling(&ma, &prioceiling);
+ ICUNIT_GOTO_EQUAL(ret, ENOERR, ret, EXIT);
+
+ /* Get the max and min according to SCHED_FIFO */
+ maxPrio = OS_TASK_PRIORITY_HIGHEST; // 0
+ minPrio = OS_TASK_PRIORITY_LOWEST; // 31
+
+ /* Ensure that prioceiling is within legal limits. */
+ if ((prioceiling > minPrio) || (prioceiling < maxPrio)) {
+ ICUNIT_GOTO_EQUAL(1, 0, LOS_NOK, EXIT);
+ }
+
+ ret = pthread_mutexattr_destroy(&ma);
+ ICUNIT_GOTO_EQUAL(ret, ENOERR, ret, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&ma);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux015(void)
+{
+ TEST_ADD_CASE("ItPosixMux015", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_016.c b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_016.c
new file mode 100644
index 0000000000000000000000000000000000000000..7644b60a848ae0f03d494acd96824a3782a3d006
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_016.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutexattr_getprioceiling 1-2.c
+ * Test that pthread_mutexattr_getprioceiling()
+ *
+ * Gets the priority ceiling attribute of a mutexattr object (which was prev. created
+ * by the function pthread_mutexattr_init()).
+ *
+ * Steps:
+ * 1. Initialize a pthread_mutexattr_t object with pthread_mutexattr_init()
+ * 2. Get the min and max boundries for SCHED_FIFO of what prioceiling can be.
+ * 3. In a for loop, go through each valid SCHED_FIFO value, set the prioceiling, then
+ * get the prio ceiling. These should always be the same. If not, fail the test.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mta;
+ int prioceiling, maxPrio, minPrio, i;
+ int rc;
+
+ /* Initialize a mutex attributes object */
+ rc = pthread_mutexattr_init(&mta);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Get the max and min prio according to SCHED_FIFO (posix scheduling policy) */
+ maxPrio = OS_TASK_PRIORITY_HIGHEST; // 0
+ minPrio = OS_TASK_PRIORITY_LOWEST; // 31
+
+ for (i = maxPrio; (i < minPrio + 1); i++) {
+ /* Set the prioceiling to a priority number in the boundries
+ * of SCHED_FIFO policy */
+ rc = pthread_mutexattr_setprioceiling(&mta, i);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ /* Get the prioceiling mutex attr. */
+ rc = pthread_mutexattr_getprioceiling(&mta, &prioceiling);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ /* Make sure that prioceiling is withing the legal SCHED_FIFO boundries. */
+ if (prioceiling != i) {
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+ return LOS_NOK;
+ }
+ }
+ rc = pthread_mutexattr_destroy(&mta);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
+
+ return LOS_OK;
+
+EXIT:
+ pthread_mutexattr_destroy(&mta);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux016(void)
+{
+ TEST_ADD_CASE("ItPosixMux016", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_019.c b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..20be1cf9535ca6f7d3c3c8ca42339e8d493bdf80
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_019.c
@@ -0,0 +1,242 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+static pthread_mutex_t *g_mtx;
+static sem_t g_semA, g_semB;
+static pthread_mutex_t g_mtxNull, g_mtxDef;
+
+/* pthread_mutex_init 1-2.c
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ * This sample test aims to check the following assertion:
+ *
+ * If the mutex attribute pointer passed to pthread_mutex_init is NULL,
+ * the effects on the mutex are the same as if a default mutex attribute object had been passed.
+ *
+ * The steps are:
+ * * create two mutexes. One is initialized with NULL attribute, the other with a default attribute object.
+ * * Compare the following features between the two mutexes:
+ * -> Can it cause / detect a deadlock? (attempt to lock a mutex the thread already owns).
+ * If detected, do both mutexes cause the same uwErr code?
+ * -> Is an uwErr returned when unlocking the mutex in unlocked state?
+ * When unlocking the mutex owned by another thread?
+ *
+ * The test will pass if the results of each feature are the same for the two mutexes
+ * (making no assumption on what is the default behavior).
+ * The test will be unresolved if any initialization fails.
+ * The test will fail if a feature differs between the two mutex objects.
+ */
+
+static void *TaskF01(void *arg)
+{
+ int ret;
+
+ TestBusyTaskDelay(20); // 20, Set the timeout of runtime.
+
+ g_testCount++;
+
+ if ((ret = pthread_mutex_lock(g_mtx))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+
+ if ((ret = sem_post(&g_semA))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+
+ if ((ret = sem_wait(&g_semB))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+
+ if (g_retval != 0) { /* parent thread failed to unlock the mutex) */
+ if ((ret = pthread_mutex_unlock(g_mtx))) {
+ ICUNIT_GOTO_EQUAL(1, 0, ret, EXIT);
+ }
+ }
+
+ g_testCount++;
+
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_mutexattr_t mattr;
+ pthread_t thr;
+
+ pthread_mutex_t *tabMutex[2];
+ int tabRes[2][3] = { {0, 0, 0}, {0, 0, 0} };
+
+ int ret;
+ void *thRet = NULL;
+
+ int i;
+
+ g_retval = 0;
+
+ g_testCount = 0;
+
+ /* We first initialize the two mutexes. */
+ if ((ret = pthread_mutex_init(&g_mtxNull, NULL))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if ((ret = pthread_mutexattr_init(&mattr))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if ((ret = pthread_mutex_init(&g_mtxDef, &mattr))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if ((ret = pthread_mutexattr_destroy(&mattr))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ tabMutex[0] = &g_mtxNull;
+ tabMutex[1] = &g_mtxDef;
+
+ if ((ret = sem_init(&g_semA, 0, 0))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if ((ret = sem_init(&g_semB, 0, 0))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ /* OK let's go for the first part of the test : abnormals unlocking */
+
+ /* We first check if unlocking an unlocked mutex returns an uwErr. */
+ ret = pthread_mutex_unlock(tabMutex[0]);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, ENOERR, ret);
+
+ ret = pthread_mutex_unlock(tabMutex[1]);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, ENOERR, ret);
+
+ /* Now we focus on unlocking a mutex lock by another thread */
+ for (i = 0; i < 2; i++) { // 2, Set the timeout of runtime
+ g_mtx = tabMutex[i];
+ tabRes[i][0] = 0;
+ tabRes[i][1] = 0;
+ tabRes[i][2] = 0; // 2, buffer index.
+
+ if ((ret = pthread_create(&thr, NULL, TaskF01, NULL))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if (i == 0) {
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+ }
+ if (i == 1) {
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert the g_testCount.
+ }
+
+ if ((ret = sem_wait(&g_semA))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ g_retval = pthread_mutex_unlock(g_mtx);
+ ICUNIT_ASSERT_EQUAL(g_retval, EPERM, g_retval);
+
+ if (i == 0) {
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ }
+ if (i == 1) {
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, Here, assert the g_testCount.
+ }
+
+ if ((ret = sem_post(&g_semB))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if ((ret = pthread_join(thr, &thRet))) {
+ ICUNIT_ASSERT_EQUAL(1, 0, ret);
+ }
+
+ if (i == 0) {
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, Here, assert the g_testCount.
+ }
+ if (i == 1) {
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, Here, assert the g_testCount.
+ }
+
+ tabRes[i][0] = g_retval;
+ }
+
+ if (tabRes[0][0] != tabRes[1][0]) {
+ ICUNIT_ASSERT_EQUAL(1, 0, LOS_NOK);
+ }
+
+ /* We start with testing the NULL mutex features */
+ (void)pthread_mutexattr_destroy(&mattr);
+ ret = pthread_mutex_destroy(&g_mtxNull);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_mutex_destroy(&g_mtxDef);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_destroy(&g_semA);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = sem_destroy(&g_semB);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux019(void)
+{
+ TEST_ADD_CASE("ItPosixMux019", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_020.c b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_020.c
new file mode 100644
index 0000000000000000000000000000000000000000..f1750ae1e227ff0f34824ce270a361761258e065
--- /dev/null
+++ b/testsuites/kernel/sample/posix/mutex/smoke/It_posix_mutex_020.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_mutex.h"
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+/* pthread_mutex_init 2-1.c
+ * Test that pthread_mutex_init()
+ * Upon successful initialization, the state of the mutex becomes
+ * initialized and unlocked.
+ *
+ */
+static UINT32 Testcase(VOID)
+{
+ pthread_mutex_t mutex;
+ int rc;
+
+ /* Initialize a mutex object */
+ rc = pthread_mutex_init(&mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ /* Acquire the mutex object using pthread_mutex_lock */
+ rc = pthread_mutex_lock(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT1);
+
+ sleep(1);
+
+ /* Release the mutex object using pthread_mutex_unlock */
+ rc = pthread_mutex_unlock(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT2);
+
+ /* Destroy the mutex object */
+ rc = pthread_mutex_destroy(&mutex);
+ ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT1);
+
+ return LOS_OK;
+
+EXIT2:
+ pthread_mutex_unlock(&mutex);
+
+EXIT1:
+ pthread_mutex_destroy(&mutex);
+ return LOS_OK;
+}
+
+
+VOID ItPosixMux020(void)
+{
+ TEST_ADD_CASE("ItPosixMux020", Testcase, TEST_POSIX, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/It_posix_pthread.c b/testsuites/kernel/sample/posix/pthread/It_posix_pthread.c
new file mode 100644
index 0000000000000000000000000000000000000000..160b5a5f2bdf55155c9f90b79be1e96ec92b82a8
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/It_posix_pthread.c
@@ -0,0 +1,358 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+pthread_key_t g_key;
+pthread_key_t g_pthreadKeyTest[PTHREAD_KEY_NUM];
+pthread_t g_newTh;
+pthread_t g_newTh2;
+pthread_once_t g_onceControl = PTHREAD_ONCE_INIT;
+pthread_cond_t g_pthreadCondTest1 = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t g_pthreadMutexTest1 = PTHREAD_MUTEX_INITIALIZER;
+INT32 g_startNum = 0;
+INT32 g_wakenNum = 0;
+INT32 g_t1Start = 0;
+INT32 g_signaled = 0;
+INT32 g_wokenUp = -1;
+INT32 g_lowDone = -1;
+INT32 g_pthreadSem = 0; /* Manual semaphore */
+INT32 g_pthreadScopeValue = 0;
+INT32 g_pthreadSchedInherit = 0;
+INT32 g_pthreadSchedPolicy = 0;
+
+ScenarIo g_scenarii[] = {
+ CASE_POS(0, 0, 0, 0, 0, 0, 0, 0, "default"),
+ CASE_POS(1, 0, 0, 0, 0, 0, 0, 0, "detached"),
+ CASE_POS(0, 1, 0, 0, 0, 0, 0, 0, "Explicit sched"),
+ CASE_UNK(0, 0, 1, 0, 0, 0, 0, 0, "FIFO Policy"),
+ CASE_UNK(0, 0, 2, 0, 0, 0, 0, 0, "RR Policy"),
+ CASE_UNK(0, 0, 0, 1, 0, 0, 0, 0, "Max sched param"),
+ CASE_UNK(0, 0, 0, -1, 0, 0, 0, 0, "Min sched param"),
+ CASE_POS(0, 0, 0, 0, 1, 0, 0, 0, "Alternative contension scope"),
+ CASE_POS(0, 0, 0, 0, 0, 1, 0, 0, "Alternative stack"),
+ CASE_POS(0, 0, 0, 0, 0, 0, 1, 0, "No guard size"),
+ CASE_UNK(0, 0, 0, 0, 0, 0, 2, 0, "1p guard size"),
+ CASE_POS(0, 0, 0, 0, 0, 0, 0, 1, "Min stack size"),
+ /* Stack play */
+ CASE_POS(0, 0, 0, 0, 0, 0, 1, 1, "Min stack size, no guard"),
+ CASE_UNK(0, 0, 0, 0, 0, 0, 2, 1, "Min stack size, 1p guard"),
+ CASE_POS(1, 0, 0, 0, 0, 1, 0, 0, "Detached, Alternative stack"),
+ CASE_POS(1, 0, 0, 0, 0, 0, 1, 1, "Detached, Min stack size, no guard"),
+ CASE_UNK(1, 0, 0, 0, 0, 0, 2, 1, "Detached, Min stack size, 1p guard"),
+};
+
+pthread_t g_pthreadTestTh;
+
+VOID ScenarInit(VOID)
+{
+ INT32 ret;
+ UINT32 i;
+ INT32 old;
+ long pagesize, minstacksize;
+ long tsa, tss, tps;
+
+ pagesize = sysconf(_SC_PAGESIZE);
+ minstacksize = sysconf(_SC_THREAD_STACK_MIN);
+ tsa = sysconf(_SC_THREAD_ATTR_STACKADDR);
+ tss = sysconf(_SC_THREAD_ATTR_STACKSIZE);
+ tps = sysconf(_SC_THREAD_PRIORITY_SCHEDULING);
+
+ if (pagesize && minstacksize % pagesize) {
+ ICUNIT_ASSERT_EQUAL_VOID(1, 0, errno);
+ }
+
+ for (i = 0; i < NSCENAR; i++) {
+ ret = pthread_attr_init(&g_scenarii[i].ta);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, PTHREAD_NO_ERROR, ret);
+
+ if (g_scenarii[i].detached == 1) {
+ ret = pthread_attr_setdetachstate(&g_scenarii[i].ta, PTHREAD_CREATE_DETACHED);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_getdetachstate(&g_scenarii[i].ta, &old);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_TRACK_EQUAL(old, PTHREAD_CREATE_JOINABLE, old);
+ }
+
+ /* Sched related attributes */
+ /*
+ * This routine is dependent on the Thread Execution
+ * Scheduling option
+ */
+ if (tps > 0) {
+ if (g_scenarii[i].explicitsched == 1)
+ ret = pthread_attr_setinheritsched(&g_scenarii[i].ta, PTHREAD_EXPLICIT_SCHED);
+ else
+ ret = pthread_attr_setinheritsched(&g_scenarii[i].ta, PTHREAD_INHERIT_SCHED);
+
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ }
+
+ if (tps > 0) {
+ if (g_scenarii[i].schedpolicy == 1)
+ ret = pthread_attr_setschedpolicy(&g_scenarii[i].ta, SCHED_FIFO);
+ if (g_scenarii[i].schedpolicy == 2) // 2, set SCHED_RR as sched mode.
+ ret = pthread_attr_setschedpolicy(&g_scenarii[i].ta, SCHED_RR);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, PTHREAD_NO_ERROR, ret);
+
+ if (g_scenarii[i].schedparam != 0) {
+ struct sched_param sp;
+
+ ret = pthread_attr_getschedpolicy(&g_scenarii[i].ta, &old);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, PTHREAD_NO_ERROR, ret);
+
+ if (g_scenarii[i].schedparam == 1)
+ sp.sched_priority = sched_get_priority_max(old);
+ if (g_scenarii[i].schedparam == -1)
+ sp.sched_priority = sched_get_priority_min(old);
+
+ ret = pthread_attr_setschedparam(&g_scenarii[i].ta, &sp);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, PTHREAD_NO_ERROR, ret);
+ }
+
+ if (tps > 0) {
+ ret = pthread_attr_getscope(&g_scenarii[i].ta, &old);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, PTHREAD_NO_ERROR, ret);
+
+ if (g_scenarii[i].altscope != 0) {
+ if (old == PTHREAD_SCOPE_PROCESS)
+ old = PTHREAD_SCOPE_SYSTEM;
+ else
+ old = PTHREAD_SCOPE_PROCESS;
+
+ ret = pthread_attr_setscope(&g_scenarii[i].ta, old);
+ }
+ }
+
+ if ((tss > 0) && (tsa > 0)) {
+ if (g_scenarii[i].altstack != 0) {
+ g_scenarii[i].bottom = malloc(minstacksize + pagesize);
+ ICUNIT_TRACK_NOT_EQUAL(g_scenarii[i].bottom, NULL, g_scenarii[i].bottom);
+ }
+ }
+
+ if (tss > 0) {
+ if (g_scenarii[i].altsize != 0) {
+ ret = pthread_attr_setstacksize(&g_scenarii[i].ta, minstacksize);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, PTHREAD_NO_ERROR, ret);
+ }
+ }
+
+ ret = sem_init(&g_scenarii[i].sem, 0, 0);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, PTHREAD_NO_ERROR, ret);
+ }
+ }
+}
+/*
+ * This function will free all resources consumed
+ * in the scenar_init() routine
+ */
+VOID ScenarFini(VOID)
+{
+ INT32 ret;
+ UINT32 i;
+
+ for (i = 0; i < NSCENAR; i++) {
+ if (g_scenarii[i].bottom != NULL)
+ free(g_scenarii[i].bottom);
+
+ ret = sem_destroy(&g_scenarii[i].sem);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_destroy(&g_scenarii[i].ta);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, PTHREAD_NO_ERROR, ret);
+ }
+}
+
+/*
+ * return value of pthread_self() is 0 when
+ * pthread create from LOS_TaskCreate()
+ */
+pthread_t TestPthreadSelf(void)
+{
+ pthread_t tid = pthread_self();
+ if (tid == 0) {
+ tid = ((LosTaskCB *)(OsCurrTaskGet()))->taskID;
+ }
+ return tid;
+}
+
+VOID ItSuitePosixPthread()
+{
+#if defined(LOSCFG_TEST_SMOKE)
+ ItPosixPthread003();
+ ItPosixPthread004();
+ ItPosixPthread005();
+ ItPosixPthread006();
+ ItPosixPthread009();
+ ItPosixPthread018();
+ ItPosixPthread019();
+ ItPosixPthread021();
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+ ItPosixPthread001();
+ ItPosixPthread002();
+ ItPosixPthread007();
+ ItPosixPthread008();
+ ItPosixPthread010();
+ ItPosixPthread011();
+ ItPosixPthread013();
+ ItPosixPthread023();
+ ItPosixPthread028();
+ ItPosixPthread029();
+ ItPosixPthread030();
+ ItPosixPthread031();
+ ItPosixPthread032();
+ ItPosixPthread033();
+ ItPosixPthread034();
+ ItPosixPthread035();
+ ItPosixPthread039();
+ ItPosixPthread040();
+ ItPosixPthread041();
+ ItPosixPthread042();
+ ItPosixPthread044();
+ ItPosixPthread045();
+ ItPosixPthread046();
+#if (LOSCFG_KERNEL_SMP != YES)
+ ItPosixPthread047(); // pthread preemption, may not happen on smp
+#endif
+ ItPosixPthread048();
+ ItPosixPthread049();
+ ItPosixPthread050();
+ ItPosixPthread051();
+ ItPosixPthread056();
+ ItPosixPthread057();
+ ItPosixPthread058();
+ ItPosixPthread060();
+ ItPosixPthread066();
+ ItPosixPthread068();
+ ItPosixPthread069();
+ ItPosixPthread071();
+ ItPosixPthread072();
+ ItPosixPthread073();
+ ItPosixPthread074();
+ ItPosixPthread075();
+ ItPosixPthread078();
+ ItPosixPthread079();
+ ItPosixPthread080();
+ ItPosixPthread081();
+ ItPosixPthread082();
+ ItPosixPthread083();
+ ItPosixPthread084();
+ ItPosixPthread085();
+ ItPosixPthread087();
+ ItPosixPthread088();
+ ItPosixPthread089();
+ ItPosixPthread092();
+ ItPosixPthread095();
+ ItPosixPthread098();
+ ItPosixPthread101();
+ ItPosixPthread102();
+ ItPosixPthread103();
+ ItPosixPthread107();
+ ItPosixPthread108();
+ ItPosixPthread110();
+ ItPosixPthread112();
+ ItPosixPthread116();
+ ItPosixPthread121();
+ ItPosixPthread123();
+ ItPosixPthread124();
+ ItPosixPthread125();
+ ItPosixPthread127();
+ ItPosixPthread128();
+ ItPosixPthread129();
+ ItPosixPthread132();
+ ItPosixPthread133();
+ ItPosixPthread134();
+ ItPosixPthread136();
+ ItPosixPthread138();
+ ItPosixPthread141();
+ ItPosixPthread142();
+ ItPosixPthread144();
+ ItPosixPthread150();
+ ItPosixPthread152();
+ ItPosixPthread154();
+ ItPosixPthread166();
+ ItPosixPthread167();
+ ItPosixPthread173();
+ ItPosixPthread175();
+ ItPosixPthread176();
+ ItPosixPthread177();
+ ItPosixPthread182();
+ ItPosixPthread185();
+ ItPosixPthread186();
+ ItPosixPthread187();
+ ItPosixPthread188();
+ ItPosixPthread193();
+ ItPosixPthread194();
+ ItPosixPthread197();
+ ItPosixPthread198();
+ ItPosixPthread200();
+ ItPosixPthread204();
+ ItPosixPthread205();
+ ItPosixPthread206();
+ ItPosixPthread208();
+ ItPosixPthread209();
+ ItPosixPthread211();
+ ItPosixPthread213();
+ ItPosixPthread214();
+ ItPosixPthread215();
+ ItPosixPthread217();
+ ItPosixPthread218();
+ ItPosixPthread219();
+ ItPosixPthread221();
+ ItPosixPthread224();
+ ItPosixPthread226();
+ ItPosixPthread233();
+ ItPosixPthread237();
+ ItPosixPthread238();
+ ItPosixPthread239();
+ ItPosixPthread240();
+ ItPosixPthread241();
+ ItPosixPthread246();
+#endif
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/It_posix_pthread.h b/testsuites/kernel/sample/posix/pthread/It_posix_pthread.h
new file mode 100644
index 0000000000000000000000000000000000000000..d83b51f5401e55e7eb2c75c1be24b8fdbc979953
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/It_posix_pthread.h
@@ -0,0 +1,358 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IT_POSIX_PTHREAD_H
+#define IT_POSIX_PTHREAD_H
+
+#include "sched.h"
+#include "signal.h"
+#include "semaphore.h"
+#include "sched.h"
+#include "osTest.h"
+#include "pthread.h"
+#include "pprivate.h"
+#include "limits.h"
+#include "unistd.h"
+#include "mqueue.h"
+#include "signal.h"
+
+#ifndef VERBOSE
+#define VERBOSE 1
+#endif
+
+/* Some routines are part of the XSI Extensions */
+#ifndef WITHOUT_XOPEN
+#define _XOPEN_SOURCE 600
+#endif
+
+#define PTHREAD_NO_ERROR 0
+#define PTHREAD_IS_ERROR (-1)
+#define PTHREAD_SIGNAL_SUPPORT 0 /* 0 means that not support the signal */
+#define PTHREAD_PRIORITY_TEST 20
+#define PTHREAD_DEFAULT_STACK_SIZE (LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE)
+#define PTHREAD_KEY_NUM 10
+#define THREAD_NUM 3
+#define PTHREAD_TIMEOUT (THREAD_NUM * 2)
+#define PTHREAD_INTHREAD_TEST 0 /* Control going to or is already for Thread */
+#define PTHREAD_INMAIN_TEST 1 /* Control going to or is already for Main */
+#define INVALID_PSHARED_VALUE (-100)
+#define NUM_OF_CONDATTR 10
+#define RUNTIME 5
+#define PTHREAD_THREADS_NUM 3
+#define TCOUNT 5 // Number of single-threaded polling
+#define COUNT_LIMIT 7 // The number of times the signal is sent
+#define HIGH_PRIORITY 5
+#define LOW_PRIORITY 10
+#define PTHREAD_EXIT_VALUE ((void *)100) /* The return code of the thread when using pthread_exit(). */
+
+#define PTHREAD_EXISTED_NUM TASK_EXISTED_NUM
+#define PTHREAD_EXISTED_SEM_NUM SEM_EXISTED_NUM
+
+/* We are testing conformance to IEEE Std 1003.1, 2003 Edition */
+#define _POSIX_C_SOURCE 200112L
+
+#define PTHREAD_MUTEX_RECURSIVE 0
+#define PTHREAD_MUTEX_ERRORCHECK 0
+
+#define uart_printf_func dprintf
+
+#define PRIORITY_OTHER (-1)
+#define PRIORITY_FIFO 20
+#define PRIORITY_RR 20
+
+#define PTHREAD_TEST_BUG dprintf
+
+#define CASE(det, expl, scp, spa, sco, sta, gua, ssi, desc, res) \
+ { \
+ { 0 }, det, expl, scp, spa, sco, sta, gua, ssi, desc, NULL, res, \
+ { \
+ 0 \
+ } \
+ }
+#define CASE_POS(det, expl, scp, spa, sco, sta, gua, ssi, desc) CASE(det, expl, scp, spa, sco, sta, gua, ssi, desc, 0)
+#define CASE_NEG(det, expl, scp, spa, sco, sta, gua, ssi, desc) CASE(det, expl, scp, spa, sco, sta, gua, ssi, desc, 1)
+#define CASE_UNK(det, expl, scp, spa, sco, sta, gua, ssi, desc) CASE(det, expl, scp, spa, sco, sta, gua, ssi, desc, 2)
+
+struct params {
+ INT32 policy;
+ INT32 priority;
+ char *policy_label;
+ INT32 status;
+};
+
+typedef struct {
+ /*
+ * Object to hold the given configuration,
+ * and which will be used to create the threads
+ */
+ pthread_attr_t ta;
+
+ /* General parameters */
+ /* 0, joinable; 1, detached */
+ INT32 detached;
+
+ /* Scheduling parameters */
+ /*
+ * 0, sched policy is inherited;
+ * 1, sched policy from the attr param
+ */
+ INT32 explicitsched;
+ /* 0, default; 1, SCHED_FIFO; 2, SCHED_RR */
+ INT32 schedpolicy;
+ /*
+ * 0, default sched param;
+ * 1, max value for sched param;
+ * -1, min value for sched param
+ */
+ INT32 schedparam;
+ /*
+ * 0, default contension scope;
+ * 1, alternative contension scope
+ */
+ INT32 altscope;
+
+ /* Stack parameters */
+ /* 0, system manages the stack; 1, stack is provided */
+ INT32 altstack;
+ /*
+ * 0, default guardsize;
+ * 1, guardsize is 0;
+ * 2, guard is 1 page
+ * -- this setting only affect system stacks (not user's).
+ */
+ INT32 guard;
+ /*
+ * 0, default stack size;
+ * 1, stack size specified (min value)
+ * -- ignored when stack is provided
+ */
+ INT32 altsize;
+
+ /* Additionnal information */
+ /* object description */
+ char *descr;
+ /* Stores the stack start when an alternate stack is required */
+ void *bottom;
+ /*
+ * This thread creation is expected to:
+ * 0, succeed; 1, fail; 2, unknown
+ */
+ INT32 result;
+ /*
+ * This semaphore is used to signal the end of
+ * the detached threads execution
+ */
+ sem_t sem;
+} ScenarIo;
+
+#define NSCENAR 10 // (sizeof(g_scenarii)/sizeof(g_scenarii[0]))
+
+extern ScenarIo g_scenarii[];
+
+extern _pthread_data *pthread_get_self_data(void);
+extern _pthread_data *pthread_get_data(pthread_t id);
+extern pthread_key_t g_key;
+extern pthread_key_t g_pthreadKeyTest[PTHREAD_KEY_NUM];
+extern pthread_t g_newTh;
+extern pthread_t g_newTh2;
+extern UINT32 g_taskMaxNum;
+extern pthread_once_t g_onceControl;
+extern pthread_cond_t g_pthreadCondTest1;
+extern pthread_mutex_t g_pthreadMutexTest1;
+extern INT32 g_startNum;
+extern INT32 g_wakenNum;
+extern INT32 g_t1Start;
+extern INT32 g_signaled;
+extern INT32 g_wokenUp;
+extern INT32 g_lowDone;
+extern INT32 g_pthreadSem;
+extern INT32 g_pthreadScopeValue;
+extern INT32 g_pthreadSchedInherit;
+extern INT32 g_pthreadSchedPolicy;
+
+extern pthread_t g_pthreadTestTh;
+
+#ifdef LOSCFG_AARCH64
+#define PTHREAD_STACK_MIN_TEST (PTHREAD_STACK_MIN * 3)
+#else
+#define PTHREAD_STACK_MIN_TEST PTHREAD_STACK_MIN
+#endif
+
+static pthread_t g_testNewTh;
+
+static struct testdata {
+ pthread_mutex_t mutex;
+ pthread_cond_t cond;
+} g_td;
+
+extern unsigned int sleep(unsigned int seconds);
+extern unsigned int alarm(unsigned int seconds);
+
+extern long sysconf(int name);
+
+VOID ScenarInit(VOID);
+VOID ScenarFini(VOID);
+pthread_t TestPthreadSelf(void);
+
+extern UINT32 PosixPthreadInit(pthread_attr_t *attr, INT32 pri);
+
+#if defined(LOSCFG_TEST_SMOKE)
+VOID ItPosixPthread003(VOID);
+VOID ItPosixPthread004(VOID);
+VOID ItPosixPthread005(VOID);
+VOID ItPosixPthread006(VOID);
+VOID ItPosixPthread009(VOID);
+VOID ItPosixPthread018(VOID);
+VOID ItPosixPthread019(VOID);
+VOID ItPosixPthread021(VOID);
+#endif
+
+#if defined(LOSCFG_TEST_FULL)
+VOID ItPosixPthread001(VOID);
+VOID ItPosixPthread002(VOID);
+VOID ItPosixPthread007(VOID);
+VOID ItPosixPthread008(VOID);
+VOID ItPosixPthread010(VOID);
+VOID ItPosixPthread011(VOID);
+VOID ItPosixPthread013(VOID);
+VOID ItPosixPthread023(VOID);
+VOID ItPosixPthread028(VOID);
+VOID ItPosixPthread029(VOID);
+VOID ItPosixPthread030(VOID);
+VOID ItPosixPthread031(VOID);
+VOID ItPosixPthread032(VOID);
+VOID ItPosixPthread033(VOID);
+VOID ItPosixPthread034(VOID);
+VOID ItPosixPthread035(VOID);
+VOID ItPosixPthread039(VOID);
+VOID ItPosixPthread040(VOID);
+VOID ItPosixPthread041(VOID);
+VOID ItPosixPthread042(VOID);
+VOID ItPosixPthread044(VOID);
+VOID ItPosixPthread045(VOID);
+VOID ItPosixPthread046(VOID);
+VOID ItPosixPthread048(VOID);
+VOID ItPosixPthread049(VOID);
+VOID ItPosixPthread050(VOID);
+VOID ItPosixPthread051(VOID);
+VOID ItPosixPthread056(VOID);
+VOID ItPosixPthread057(VOID);
+VOID ItPosixPthread058(VOID);
+VOID ItPosixPthread060(VOID);
+VOID ItPosixPthread066(VOID);
+VOID ItPosixPthread068(VOID);
+VOID ItPosixPthread069(VOID);
+VOID ItPosixPthread071(VOID);
+VOID ItPosixPthread072(VOID);
+VOID ItPosixPthread073(VOID);
+VOID ItPosixPthread074(VOID);
+VOID ItPosixPthread075(VOID);
+VOID ItPosixPthread078(VOID);
+VOID ItPosixPthread079(VOID);
+VOID ItPosixPthread080(VOID);
+VOID ItPosixPthread081(VOID);
+VOID ItPosixPthread082(VOID);
+VOID ItPosixPthread083(VOID);
+VOID ItPosixPthread084(VOID);
+VOID ItPosixPthread085(VOID);
+VOID ItPosixPthread087(VOID);
+VOID ItPosixPthread088(VOID);
+VOID ItPosixPthread089(VOID);
+VOID ItPosixPthread092(VOID);
+VOID ItPosixPthread095(VOID);
+VOID ItPosixPthread098(VOID);
+VOID ItPosixPthread101(VOID);
+VOID ItPosixPthread102(VOID);
+VOID ItPosixPthread103(VOID);
+VOID ItPosixPthread107(VOID);
+VOID ItPosixPthread108(VOID);
+VOID ItPosixPthread110(VOID);
+VOID ItPosixPthread112(VOID);
+VOID ItPosixPthread116(VOID);
+VOID ItPosixPthread121(VOID);
+VOID ItPosixPthread123(VOID);
+VOID ItPosixPthread124(VOID);
+VOID ItPosixPthread125(VOID);
+VOID ItPosixPthread127(VOID);
+VOID ItPosixPthread128(VOID);
+VOID ItPosixPthread129(VOID);
+VOID ItPosixPthread132(VOID);
+VOID ItPosixPthread133(VOID);
+VOID ItPosixPthread134(VOID);
+VOID ItPosixPthread136(VOID);
+VOID ItPosixPthread138(VOID);
+VOID ItPosixPthread141(VOID);
+VOID ItPosixPthread142(VOID);
+VOID ItPosixPthread144(VOID);
+VOID ItPosixPthread150(VOID);
+VOID ItPosixPthread152(VOID);
+VOID ItPosixPthread154(VOID);
+VOID ItPosixPthread166(VOID);
+VOID ItPosixPthread167(VOID);
+VOID ItPosixPthread173(VOID);
+VOID ItPosixPthread175(VOID);
+VOID ItPosixPthread176(VOID);
+VOID ItPosixPthread177(VOID);
+VOID ItPosixPthread182(VOID);
+VOID ItPosixPthread185(VOID);
+VOID ItPosixPthread186(VOID);
+VOID ItPosixPthread187(VOID);
+VOID ItPosixPthread188(VOID);
+VOID ItPosixPthread193(VOID);
+VOID ItPosixPthread194(VOID);
+VOID ItPosixPthread197(VOID);
+VOID ItPosixPthread198(VOID);
+VOID ItPosixPthread200(VOID);
+VOID ItPosixPthread204(VOID);
+VOID ItPosixPthread205(VOID);
+VOID ItPosixPthread206(VOID);
+VOID ItPosixPthread208(VOID);
+VOID ItPosixPthread209(VOID);
+VOID ItPosixPthread211(VOID);
+VOID ItPosixPthread213(VOID);
+VOID ItPosixPthread214(VOID);
+VOID ItPosixPthread215(VOID);
+VOID ItPosixPthread217(VOID);
+VOID ItPosixPthread218(VOID);
+VOID ItPosixPthread219(VOID);
+VOID ItPosixPthread221(VOID);
+VOID ItPosixPthread224(VOID);
+VOID ItPosixPthread226(VOID);
+VOID ItPosixPthread233(VOID);
+VOID ItPosixPthread237(VOID);
+VOID ItPosixPthread238(VOID);
+VOID ItPosixPthread239(VOID);
+VOID ItPosixPthread240(VOID);
+VOID ItPosixPthread241(VOID);
+VOID ItPosixPthread246(VOID);
+#endif
+
+#endif /* IT_POSIX_PTHREAD_H */
diff --git a/testsuites/kernel/sample/posix/pthread/Makefile b/testsuites/kernel/sample/posix/pthread/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..041c2040a1a582d2dc5c5ed3d2ef301ccd80c597
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/Makefile
@@ -0,0 +1,36 @@
+
+include $(LITEOSTESTTOPDIR)/config.mk
+
+MODULE_NAME := pthreadtest
+
+LOCAL_INCLUDE := \
+ -I $(LITEOSTESTTOPDIR)/kernel/include \
+ -I $(LITEOSTOPDIR)/compat/posix/src \
+ -I $(LITEOSTESTTOPDIR)/kernel/sample/posix/pthread
+
+SRC_MODULES := .
+
+ifeq ($(LOSCFG_TEST_LLT), y)
+LLT_MODULES := llt
+endif
+
+ifeq ($(LOSCFG_TEST_PRESSURE), y)
+PRESSURE_MODULES := pressure
+endif
+
+ifeq ($(LOSCFG_TEST_SMOKE), y)
+SMOKE_MODULES := smoke
+endif
+
+ifeq ($(LOSCFG_TEST_FULL), y)
+FULL_MODULES := full
+endif
+
+LOCAL_MODULES := $(SRC_MODULES) $(LLT_MODULES) $(PRESSURE_MODULES) $(SMOKE_MODULES) $(FULL_MODULES)
+
+LOCAL_SRCS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.c))
+LOCAL_CHS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.h))
+
+LOCAL_FLAGS := $(LOCAL_INCLUDE) -Wno-error
+
+include $(MODULE)
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_001.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_001.c
new file mode 100644
index 0000000000000000000000000000000000000000..c2050a6343e0a21f32c8c5c2bb2ef2d653699ddf
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_001.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+#ifndef PTHREAD_CANCEL_ASYNCHRONOUS
+#error PTHREAD_CANCEL_ASYNCHRONOUS not defined
+#endif
+
+#ifndef PTHREAD_CANCEL_ENABLE
+#error PTHREAD_CANCEL_ENABLE not defined
+#endif
+
+#ifndef PTHREAD_CANCEL_DEFERRED
+#error PTHREAD_CANCEL_DEFERRED not defined
+#endif
+
+#ifndef PTHREAD_CANCEL_DISABLE
+#error PTHREAD_CANCEL_DISABLE not defined
+#endif
+
+#ifndef PTHREAD_CANCELED
+#error PTHREAD_CANCELED not defined
+#endif
+
+#ifndef PTHREAD_CREATE_DETACHED
+#error PTHREAD_CREATE_DETACHED not defined
+#endif
+
+#ifndef PTHREAD_CREATE_JOINABLE
+#error PTHREAD_CREATE_JOINABLE not defined
+#endif
+
+#ifndef PTHREAD_EXPLICIT_SCHED
+#error PTHREAD_EXPLICIT_SCHED not defined
+#endif
+
+#ifndef PTHREAD_INHERIT_SCHED
+#error PTHREAD_INHERIT_SCHED not defined
+#endif
+
+#ifndef PTHREAD_ONCE_INIT
+#error PTHREAD_ONCE_INIT not defined
+#endif
+
+#ifndef PTHREAD_PROCESS_SHARED
+#error PTHREAD_PROCESS_SHARED not defined
+#endif
+
+#ifndef PTHREAD_PROCESS_PRIVATE
+#error PTHREAD_PROCESS_PRIVATE not defined
+#endif
+
+#ifndef PTHREAD_COND_INITIALIZER
+#error PTHREAD_COND_INTIALIZER not defined
+#endif
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread001(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread001", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_002.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_002.c
new file mode 100644
index 0000000000000000000000000000000000000000..aac44f8d6b7c3648211afbf111803b62acad9a34
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_002.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_attr_t dummy1;
+ pthread_key_t dummy6;
+ pthread_mutex_t dummy7;
+ pthread_mutexattr_t dummy8;
+ pthread_once_t dummy9;
+ pthread_t dummy13;
+ pthread_once_t dummy;
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread002(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread002", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_007.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_007.c
new file mode 100644
index 0000000000000000000000000000000000000000..4bbb07c71c977ae071fb8a5679695fbd110d01fc
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_007.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+
+ return argument;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ pthread_attr_t attr;
+ UINT32 ret;
+ UINT32 uwint = 8;
+ char cc = 'a';
+ char str[5] = "abcd";
+ _pthread_data *joinee = NULL;
+ UINTPTR temp;
+
+ g_testCount = 0;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ /* Create a new thread. */
+ ret = pthread_create(NULL, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, (void *)&uwint);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(*((UINT32 *)temp), 8, *((UINT32 *)temp)); // 8, here assert the result.
+
+ ret = pthread_create(&newTh, &attr, NULL, (void *)8); // 8, test for invalid param.
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_create(&newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL((UINT32)temp, 0, (UINT32)temp);
+
+ ret = pthread_create(&newTh, &attr, PthreadF01, (void *)&cc);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, here assert the result.
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(*((char *)temp), 97, *((char *)temp)); // 97, here assert the result.
+
+ ret = pthread_create(&newTh, &attr, PthreadF01, (void *)str);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_STRING_EQUAL((char *)temp, "abcd", (char *)temp);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread007(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread007", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_008.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_008.c
new file mode 100644
index 0000000000000000000000000000000000000000..4fc0489fa67c2ec35ef2735a9d9d902ae1be9de8
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_008.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+
+ g_testCount = 0;
+
+ ret = pthread_attr_init(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_destroy(NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread008(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread008", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_010.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_010.c
new file mode 100644
index 0000000000000000000000000000000000000000..6f3a9f7646d5bb9e8020e8e9bd34573222fcaa53
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_010.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount = pthread_self();
+
+ pthread_exit((void *)8); // 8, here set value of the exit status.
+
+ return (void *)9; // 9, here set value of the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, newTh, g_testCount);
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 8, temp); // 8, here assert the result.
+
+ temp = TestPthreadSelf();
+ ret = pthread_equal(temp, g_testCount);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_equal(newTh, g_testCount);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_equal(0, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_equal(0, 1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread010(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread010", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_011.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_011.c
new file mode 100644
index 0000000000000000000000000000000000000000..fc827820c35aeb0cfbded5cf8af11ae2729c7e77
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_011.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_attr_t attr;
+ UINT32 ret;
+ int detachstate;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_setdetachstate(NULL, PTHREAD_CREATE_DETACHED);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE - 1);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_setdetachstate(&attr, 3); // 3, test the param of function.
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_getdetachstate(NULL, &detachstate);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_getdetachstate(&attr, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_getdetachstate(&attr, &detachstate);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(detachstate, PTHREAD_CREATE_DETACHED, detachstate);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread011(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread011", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_013.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_013.c
new file mode 100644
index 0000000000000000000000000000000000000000..447d8d23e8adf6e9fb425cb8787033ef3141c051
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_013.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_attr_t attr;
+ UINT32 ret;
+ int inherit;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_setinheritsched(NULL, PTHREAD_INHERIT_SCHED);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED - 1);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED + 1);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_getinheritsched(NULL, &inherit);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_getinheritsched(&attr, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_getinheritsched(&attr, &inherit);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(inherit, PTHREAD_EXPLICIT_SCHED, inherit);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread013(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread013", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_023.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_023.c
new file mode 100644
index 0000000000000000000000000000000000000000..1f024163ab733c5d2aedc815dcb30c69b820e32d
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_023.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void PthreadCleanF01(void *arg)
+{
+ ICUNIT_ASSERT_EQUAL_VOID((int)(intptr_t)arg, 8, (int)(intptr_t)arg); // 8, here assert the result.
+ g_testCount++;
+
+ return;
+}
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+
+ pthread_cleanup_push(PthreadCleanF01, (void *)8); // 8, here set value.
+ return (void *)8; // 8, here set value about the return status.
+ pthread_cleanup_pop(0)
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 8, temp); // 8, here assert the result.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread023(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread023", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_028.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_028.c
new file mode 100644
index 0000000000000000000000000000000000000000..01c5f57e8d58cef09a8ba56d655bdeda8320b9e9
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_028.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 9, temp); // 9, here assert the result.
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread028(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread028", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_029.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_029.c
new file mode 100644
index 0000000000000000000000000000000000000000..39c2e3e91e79e8de7b11ab061ba6dd1cc6f1cc71
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_029.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+
+ pthread_exit((void *)8); // 8, here set value about the exit status.
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 8, temp); // 8, here assert the result.
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread029(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread029", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_030.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_030.c
new file mode 100644
index 0000000000000000000000000000000000000000..d8b2dc7c9c49ad2d4beea9d314acc12f9b98198b
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_030.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ TestExtraTaskDelay(2); // 2, delay for Timing control.
+
+ pthread_testcancel();
+ g_testCount++;
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+
+VOID ItPosixPthread030(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread030", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_031.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_031.c
new file mode 100644
index 0000000000000000000000000000000000000000..7798190c2419220a90baf74cae59f23e5d6aa5d3
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_031.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = pthread_join(g_newTh, NULL);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&g_newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_join(g_newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 9, temp); // 9, here assert the result.
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread031(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread031", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_032.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_032.c
new file mode 100644
index 0000000000000000000000000000000000000000..2afbcb30893024d7a89af2baf94db4a24fb1866d
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_032.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static VOID *PthreadF02(void *argument)
+{
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ TestExtraTaskDelay(2); // 2, delay for Timing control.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ ret = pthread_join(g_newTh2, (void *)&temp);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(temp, 7, temp, EXIT); // 7, here assert the result.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+ g_testCount++;
+EXIT:
+ return (void *)8; // 8, here set value about the return status.
+}
+
+static VOID *PthreadF03(void *argument)
+{
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ TestExtraTaskDelay(4); // 4, delay for Timing control.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+ g_testCount++;
+
+ ret = pthread_join(g_newTh, (void *)&temp);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(temp, 9, temp, EXIT); // 9, here assert the result.
+
+EXIT:
+ return (void *)7; // 7, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ pthread_attr_t attr;
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr, 4); // 4, test for param of the function.
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskLock();
+
+ ret = pthread_create(&g_newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, &attr, PthreadF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&g_newTh2, &attr, PthreadF03, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskUnlock();
+
+ TestExtraTaskDelay(6); // 6, delay for Timing control.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 8, temp); // 8, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread032(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread032", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_033.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_033.c
new file mode 100644
index 0000000000000000000000000000000000000000..391f40cf770600ed87ceae4baccbabcd687328b8
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_033.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static VOID *PthreadF02(void *argument)
+{
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount++;
+
+ LOS_TaskDelay(5); // 5, delay for Timing control.
+ TestExtraTaskDelay(1);
+ ret = pthread_join(g_newTh, (void *)&temp);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+EXIT:
+ return (void *)8; // 8, here set value about the return status.
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&g_newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, NULL, PthreadF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_join(g_newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 9, temp); // 9, here assert the result.
+
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ ret = pthread_join(g_newTh, (void *)&temp);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 8, temp); // 8, here assert the result.
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread033(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread033", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_034.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_034.c
new file mode 100644
index 0000000000000000000000000000000000000000..88d3f65b98af3fa4bc86a97a80d10f0d39688dd8
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_034.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+
+#define LOOP_NUM 2000
+
+static VOID *PthreadF01(void *argument)
+{
+ UINT32 i, j;
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+
+ for (i = 0, j = 0; i < LOOP_NUM; i++) {
+ j++;
+ }
+
+ g_testCount++;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static VOID *PthreadF02(void *argument)
+{
+ UINT32 i, j;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ for (i = 0, j = 0; i < LOOP_NUM; i++) {
+ j++;
+ }
+
+ g_testCount++;
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+EXIT:
+ return (void *)8; // 8, here set value about the return status.
+}
+
+static VOID *PthreadF03(void *argument)
+{
+ UINT32 i, j;
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+
+ for (i = 0, j = 0; i < LOOP_NUM; i++) {
+ j++;
+ }
+
+ g_testCount++;
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+
+EXIT:
+ return (void *)7; // 7, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh, newTh2, newTh3;
+
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh2, NULL, PthreadF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh3, NULL, PthreadF03, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh2, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh3, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread034(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread034", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_035.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_035.c
new file mode 100644
index 0000000000000000000000000000000000000000..08bad1b722dc64d01b0149a434977a6b06bfae6f
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_035.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ UINT32 j = 0;
+ INT32 value;
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+ while (g_testCount != 3) { // 3, wait until g_testCount is equal to 3.
+ j++;
+ }
+ g_testCount++;
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static VOID *PthreadF02(void *argument)
+{
+ UINT32 j = 0;
+ INT32 value;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ while (g_testCount != 4) { // 4, wait until g_testCount is equal to 4.
+ j++;
+ }
+
+ g_testCount++;
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result.
+EXIT:
+ return (void *)8; // 8, here set value about the return status.
+}
+
+static VOID *PthreadF03(void *argument)
+{
+ UINT32 j = 0;
+ INT32 value;
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+ g_testCount++;
+
+ while (g_testCount != 5) { // 5, wait until g_testCount is equal to 5.
+ j++;
+ }
+
+ g_testCount++;
+ ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT); // 6, here assert the result.
+
+EXIT:
+ return (void *)7; // 7, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh, newTh2, newTh3;
+
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh2, NULL, PthreadF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh3, NULL, PthreadF03, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ while (g_testCount < 6) // 6, wait until g_testCount is equal to 6.
+ sleep(1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 6, g_testCount); // 6, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh2, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh3, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread035(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread035", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_039.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_039.c
new file mode 100644
index 0000000000000000000000000000000000000000..042fe0bc2ef17083be9bcb9543e13d1d9248a57e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_039.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ pthread_testcancel();
+ g_testCount++;
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 count = PTHREAD_EXISTED_NUM;
+ pthread_t newTh;
+ UINT32 ret;
+ UINT32 index;
+ UINT32 count1 = 0;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_detach(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ for (index = 0; index < LOSCFG_BASE_CORE_TSK_LIMIT; index++) {
+ if (g_taskCBArray[index].taskStatus == OS_TASK_STATUS_UNUSED) {
+ count1++;
+ }
+ }
+
+ ICUNIT_ASSERT_EQUAL(count1, g_taskMaxNum - count - 1, count1);
+
+ ret = pthread_create(&newTh, NULL, PthreadF01,
+ NULL); // the detach will release resources the next time when creates one pthread
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ for (count1 = 0, index = 0; index < LOSCFG_BASE_CORE_TSK_LIMIT; index++) {
+ if (g_taskCBArray[index].taskStatus == OS_TASK_STATUS_UNUSED) {
+ count1++;
+ }
+ }
+
+ ICUNIT_ASSERT_EQUAL(count1, g_taskMaxNum - count, count1);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread039(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread039", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_040.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_040.c
new file mode 100644
index 0000000000000000000000000000000000000000..5ae39d2830bf553008193b11c41871503b2fa149
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_040.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ g_testCount++;
+
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ INT32 count = PTHREAD_EXISTED_NUM;
+ pthread_t newTh;
+ UINT32 ret;
+ UINT32 index;
+ UINT32 count1 = 0;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_detach(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ for (index = 0; index < LOSCFG_BASE_CORE_TSK_LIMIT; index++) {
+ if (g_taskCBArray[index].taskStatus & OS_TASK_STATUS_UNUSED) {
+ count1++;
+ }
+ }
+
+ ICUNIT_ASSERT_EQUAL(count1, g_taskMaxNum - count, count1);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread040(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread040", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_041.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_041.c
new file mode 100644
index 0000000000000000000000000000000000000000..c75211507275a8de25d8192fba3ae65931f1bfc4
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_041.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 count = PTHREAD_EXISTED_NUM;
+ pthread_t newTh;
+ UINT32 ret;
+ UINT32 index;
+ UINT32 count1 = 0;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_detach(newTh);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(1);
+
+ for (index = 0; index < LOSCFG_BASE_CORE_TSK_LIMIT; index++) {
+ if (g_taskCBArray[index].taskStatus == OS_TASK_STATUS_UNUSED) {
+ count1++;
+ }
+ }
+
+ ICUNIT_ASSERT_EQUAL(count1, g_taskMaxNum - count, count1);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread041(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread041", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_042.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_042.c
new file mode 100644
index 0000000000000000000000000000000000000000..907c06808889d2f757050b20a24cf57a1a02d601
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_042.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ g_testCount++;
+
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ INT32 count = PTHREAD_EXISTED_NUM;
+ pthread_t newTh;
+ UINT32 ret;
+ UINT32 index;
+ UINT32 count1 = 0;
+ pthread_attr_t attr;
+ int detachstate;
+
+ g_testCount = 0;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_getdetachstate(&attr, &detachstate);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(detachstate, PTHREAD_CREATE_JOINABLE, detachstate);
+
+ ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_detach(newTh);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(3); // 3, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+ for (index = 0; index < LOSCFG_BASE_CORE_TSK_LIMIT; index++) {
+ if (g_taskCBArray[index].taskStatus & OS_TASK_STATUS_UNUSED) {
+ count1++;
+ }
+ }
+
+ ICUNIT_ASSERT_EQUAL(count1, g_taskMaxNum - count, count1);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_detach(newTh);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_getdetachstate(&attr, &detachstate);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(detachstate, PTHREAD_CREATE_DETACHED, detachstate);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread042(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread042", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_044.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_044.c
new file mode 100644
index 0000000000000000000000000000000000000000..0591b40c878b81549026fad334dde956d41d36dd
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_044.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF02(void *argument)
+{
+ _pthread_data *info = NULL;
+
+ TestExtraTaskDelay(2); // 2, delay for Timing control.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+ info = pthread_get_self_data();
+
+ // 3, here assert the result.
+ ICUNIT_GOTO_EQUAL(info->attr.schedparam.sched_priority, 3, info->attr.schedparam.sched_priority, EXIT);
+ ICUNIT_GOTO_EQUAL(info->attr.schedpolicy, SCHED_RR, info->attr.schedpolicy, EXIT);
+ ICUNIT_GOTO_EQUAL(info->attr.scope, PTHREAD_SCOPE_PROCESS, info->attr.scope, EXIT);
+ ICUNIT_GOTO_EQUAL(info->task->priority, 3, info->task->priority, EXIT); // 3, here assert the result.
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static VOID *PthreadF01(void *argument)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ pthread_attr_t attr;
+ struct sched_param param;
+ _pthread_data *info = NULL;
+
+ g_testCount++;
+
+ info = pthread_get_self_data();
+
+ // 4, here assert the result.
+ ICUNIT_GOTO_EQUAL(info->attr.schedparam.sched_priority, 4, info->attr.schedparam.sched_priority, EXIT);
+ ICUNIT_GOTO_EQUAL(info->attr.schedpolicy, SCHED_RR, info->attr.schedpolicy, EXIT);
+ ICUNIT_GOTO_EQUAL(info->attr.scope, PTHREAD_SCOPE_PROCESS, info->attr.scope, EXIT);
+ ICUNIT_GOTO_EQUAL(info->task->priority, 4, info->task->priority, EXIT); // 4, here assert the result.
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = pthread_create(&newTh, &attr, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ param.sched_priority = 3; // 3, set priority.
+ ret = pthread_setschedparam(newTh, SCHED_RR, ¶m);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = pthread_detach(newTh);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ TestExtraTaskDelay(4); // 4, delay for Timing control.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+ g_testCount++;
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ pthread_attr_t attr;
+ int inherit;
+ struct sched_param param;
+
+ g_testCount = 0;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_setschedpolicy(&attr, SCHED_RR); //
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ param.sched_priority = 4; // 4, set priority.
+ ret = pthread_attr_setschedparam(&attr, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ TestExtraTaskDelay(6); // 6, delay for Timing control.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_getinheritsched(&attr, &inherit);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(inherit, PTHREAD_EXPLICIT_SCHED, inherit);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread044(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread044", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_045.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_045.c
new file mode 100644
index 0000000000000000000000000000000000000000..c8520925233ab416dac8b3dbcd3a1074bd6908e2
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_045.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ _pthread_data *info = NULL;
+
+ g_testCount++;
+ dprintf("!!!!!!!!!\n");
+ dprintf("%x\n", TASK_STACK_SIZE_TEST);
+ info = pthread_get_self_data();
+
+ // 3, here assert the result.
+ ICUNIT_GOTO_EQUAL(info->attr.stacksize, (TASK_STACK_SIZE_TEST + 3) & ~3, info->attr.stacksize, EXIT); // failed
+ ICUNIT_GOTO_EQUAL(info->attr.stacksize_set, 1, info->attr.stacksize_set, EXIT);
+ // 3, here assert the result.
+ ICUNIT_GOTO_EQUAL(info->task->stackSize, (TASK_STACK_SIZE_TEST + 3) & ~3, info->task->stackSize, EXIT);
+
+ g_testCount++;
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ int ret;
+ pthread_attr_t attr;
+ size_t stacksize;
+ size_t stacksize2;
+
+ g_testCount = 0;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ stacksize = TASK_STACK_SIZE_TEST;
+ ret = pthread_attr_setstacksize(&attr, stacksize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+#ifdef TEST3559A_M7
+ ret = LOS_TaskDelay(10); // 10, delay for Timing control.
+#else
+ ret = LOS_TaskDelay(10); // 10, delay for Timing control.
+#endif
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_join(newTh, NULL);
+
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_getstacksize(&attr, &stacksize2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(stacksize2, TASK_STACK_SIZE_TEST, stacksize2);
+
+ attr.stacksize_set = 1;
+ attr.stacksize = LOS_TASK_MIN_STACK_SIZE - 2 * sizeof(UINTPTR); // 2, Set reasonable stack size.
+ ret = pthread_create(&newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread045(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread045", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_046.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_046.c
new file mode 100644
index 0000000000000000000000000000000000000000..5bd0327041cddbc7584cce9a22b548a7ad2139bf
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_046.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ _pthread_data *info = NULL;
+
+ g_testCount++;
+
+ info = pthread_get_self_data();
+
+ ICUNIT_GOTO_EQUAL(info->attr.stacksize,
+ // 2, here assert the result.
+ ((PTHREAD_STACK_MIN_TEST + 1 + (sizeof(UINTPTR) * 2 - 1)) & ~(sizeof(UINTPTR) * 2 - 1)), info->attr.stacksize,
+ EXIT);
+ ICUNIT_GOTO_EQUAL(info->attr.stacksize_set, 1, info->attr.stacksize_set, EXIT);
+
+ ICUNIT_GOTO_EQUAL(info->task->stackSize,
+ // 2, here assert the result.
+ ((PTHREAD_STACK_MIN_TEST + 1 + (sizeof(UINTPTR) * 2 - 1)) & ~(sizeof(UINTPTR) * 2 - 1)), info->task->stackSize,
+ EXIT);
+
+ g_testCount++;
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ pthread_attr_t attr;
+ size_t stacksize;
+ size_t stacksize2;
+
+ g_testCount = 0;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ stacksize = PTHREAD_STACK_MIN_TEST + 1;
+ ret = pthread_attr_setstacksize(&attr, stacksize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_getstacksize(&attr, &stacksize2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(stacksize2, PTHREAD_STACK_MIN_TEST + 1, stacksize2);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread046(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread046", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_047.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_047.c
new file mode 100644
index 0000000000000000000000000000000000000000..945df0388cdb827120eb46e4722b869e914306b7
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_047.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ UINT32 ret;
+ struct sched_param param;
+ int policy;
+
+ g_testCount++;
+
+ ret = pthread_getschedparam(g_newTh, &policy, ¶m);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT);
+ ICUNIT_GOTO_EQUAL(param.sched_priority, 4, param.sched_priority, EXIT); // 4, here assert the result.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ param.sched_priority = 26; // 26, set priority.
+ ret = pthread_setschedparam(g_newTh, SCHED_RR, ¶m);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+ g_testCount++;
+
+ ret = pthread_getschedparam(g_newTh, &policy, ¶m);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT);
+ ICUNIT_GOTO_EQUAL(param.sched_priority, 26, param.sched_priority, EXIT); // 26, here assert the result.
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_attr_t attr;
+ struct sched_param param;
+ int policy;
+
+ g_testCount = 0;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_setschedpolicy(&attr, SCHED_RR);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ param.sched_priority = 4; // 4, set priority.
+ ret = pthread_attr_setschedparam(&attr, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&g_newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_getschedparam(g_newTh, &policy, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(policy, SCHED_RR, policy);
+ ICUNIT_ASSERT_EQUAL(param.sched_priority, 26, param.sched_priority); // 26, here assert the result.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+ g_testCount++;
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = pthread_join(g_newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread047(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread047", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_048.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_048.c
new file mode 100644
index 0000000000000000000000000000000000000000..c2a17716c75ad71622fa500b71feb34c17e67d14
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_048.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID PthreadOnceF01(VOID)
+{
+ g_testCount++;
+}
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+
+ pthread_once(&g_onceControl, PthreadOnceF01);
+ g_testCount++;
+
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_onceControl = PTHREAD_ONCE_INIT;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = pthread_once(&g_onceControl, PthreadOnceF01);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread048(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread048", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_049.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_049.c
new file mode 100644
index 0000000000000000000000000000000000000000..2273f199621419f607953a2507c69cc636929d3f
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_049.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void PthreadOnceF01(void)
+{
+ g_testCount++;
+}
+
+static void PthreadOnceF02(void)
+{
+ g_testCount++;
+}
+static VOID *PthreadF01(void *argument)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = pthread_once(&g_onceControl, PthreadOnceF01);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_onceControl = PTHREAD_ONCE_INIT;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_once(&g_onceControl, PthreadOnceF02);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_once(&g_onceControl, PthreadOnceF01);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread049(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread049", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_050.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_050.c
new file mode 100644
index 0000000000000000000000000000000000000000..32983f617fc70a62f7a2389687bb019827c53414
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_050.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void PthreadOnceF01(void)
+{
+ g_testCount++;
+ pthread_exit((void *)8); // 8, here set value about the exit status.
+}
+
+static void PthreadOnceF02(void)
+{
+ g_testCount++;
+}
+static VOID *PthreadF01(void *argument)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = pthread_once(&g_onceControl, PthreadOnceF01);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ UINTPTR temp;
+
+ g_testCount = 0;
+ g_onceControl = PTHREAD_ONCE_INIT;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_once(&g_onceControl, PthreadOnceF02);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 8, temp); // 8, here assert the result.
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread050(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread050", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_051.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_051.c
new file mode 100644
index 0000000000000000000000000000000000000000..5ca251ec3dd21f9b2a9afe0ac906f94d424bc87c
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_051.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void PthreadOnceF01(void)
+{
+ g_testCount++;
+ pthread_testcancel();
+}
+
+static VOID *PthreadF01(void *argument)
+{
+ UINT32 ret;
+
+ g_testCount++;
+
+ TestExtraTaskDelay(2); // 2, delay for Timing control.
+
+ ret = pthread_once(&g_onceControl, PthreadOnceF01);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); // not reachable
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ UINTPTR temp;
+
+ g_testCount = 0;
+ g_onceControl = PTHREAD_ONCE_INIT;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(3); // 3, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_once(&g_onceControl, PthreadOnceF01);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread051(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread051", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_056.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_056.c
new file mode 100644
index 0000000000000000000000000000000000000000..3dc082ccb8383c227e827da83706b3c610eadf95
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_056.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ int oldstate;
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+ TestExtraTaskDelay(2); // 2, delay for Timing control.
+
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_ENABLE, oldstate, EXIT);
+
+ pthread_testcancel();
+
+ g_testCount++;
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DISABLE, oldstate, EXIT);
+
+ pthread_testcancel();
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); // not reachable
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(4); // 4, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread056(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread056", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_057.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_057.c
new file mode 100644
index 0000000000000000000000000000000000000000..66a77cb2bac7142ad36a60e51a22fa7e5061d052
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_057.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ UINT32 ret;
+ int oldstate;
+ UINT32 i, j;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DEFERRED, oldstate, EXIT);
+ while (1) {
+ };
+ g_testCount++;
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh, newTh2;
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 1;
+
+ ret = pthread_create(&newTh2, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(1);
+ TestExtraTaskDelay(10); // 10, delay for Timing control.
+
+ ret = pthread_cancel(newTh2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh2, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread057(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread057", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_058.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_058.c
new file mode 100644
index 0000000000000000000000000000000000000000..0becc53d5db4a414b536bb6a5fe6be55b81cf3cf
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_058.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ int oldstate;
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_ENABLE, oldstate, EXIT);
+
+ pthread_testcancel();
+
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DEFERRED, oldstate, EXIT);
+
+ g_testCount++;
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DISABLE, oldstate, EXIT);
+
+ pthread_testcancel();
+
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static VOID *PthreadF02(void *argument)
+{
+ int oldstate;
+ UINT32 ret;
+
+ g_testCount++;
+
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ /* asynchronous cancelled, needs more time */
+ LOS_TaskDelay(3); // 3, delay for Timing control.
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(1);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
+
+#if 1
+ ret = pthread_create(&newTh, NULL, PthreadF02, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, here assert the result.
+#endif
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread058(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread058", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_060.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_060.c
new file mode 100644
index 0000000000000000000000000000000000000000..59cf27259695edfa4ecfe17fb1fe20260040ef4c
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_060.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF02(void *argument)
+{
+ g_testCount++;
+ return (void *)8; // 8, here set value about the return status.
+}
+static VOID *PthreadF01(void *argument)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT);
+ g_testCount++;
+
+ TestExtraTaskDelay(1);
+
+ ret = pthread_create(&g_newTh, NULL, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = pthread_join(g_newTh, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ g_testCount++;
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ UINTPTR temp = 1;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(3); // 3, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
+
+ ret = pthread_join(g_newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 8, temp); // 8, here assert the result.
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread060(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread060", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_066.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_066.c
new file mode 100644
index 0000000000000000000000000000000000000000..a7e03f6c7f606e4c3bafa14b9fd841bf707375bd
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_066.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF02(void *argument)
+{
+ int oldstate;
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = pthread_cancel(g_newTh);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ g_testCount++;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static VOID *PthreadF01(void *argument)
+{
+ int oldstate;
+ UINT32 ret;
+ pthread_attr_t attr;
+ pthread_t newTh;
+
+ g_testCount++;
+
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DEFERRED, oldstate, EXIT);
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ attr.inheritsched = PTHREAD_EXPLICIT_SCHED;
+ attr.schedparam.sched_priority = 8; // 8, set priority.
+
+ ret = pthread_create(&g_newTh2, &attr, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ while (g_testCount < 2) { // 2, delay until g_testCount is equal to 2.
+ TestBusyTaskDelay(1);
+ }
+ TestExtraTaskDelay(1);
+#else
+ g_testCount++;
+
+ ret = pthread_join(g_newTh2, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ g_testCount++;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+#endif
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINTPTR temp = 1;
+ pthread_attr_t attr;
+
+ g_testCount = 0;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ attr.inheritsched = PTHREAD_EXPLICIT_SCHED;
+ attr.schedparam.sched_priority = 10; // 10, set priority.
+
+ ret = pthread_create(&g_newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ TestExtraTaskDelay(10); // 10, delay for Timing control.
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ ret = pthread_join(g_newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
+
+ ret = pthread_join(g_newTh2, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread066(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread066", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_068.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_068.c
new file mode 100644
index 0000000000000000000000000000000000000000..6ced64b9c5d1545f23b4b14a3eb814b41bb3d151
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_068.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF02(VOID *argument)
+{
+ UINT32 ret;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+
+ ret = pthread_cancel(g_newTh);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ g_testCount++;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+EXIT:
+ return NULL;
+}
+
+static VOID *PthreadF01(VOID *argument)
+{
+ int oldstate;
+ UINT32 ret;
+ pthread_attr_t attr;
+
+ g_testCount++;
+
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DEFERRED, oldstate, EXIT);
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ attr.inheritsched = PTHREAD_EXPLICIT_SCHED;
+ attr.schedparam.sched_priority = 8; // 8, set priority.
+
+ ret = pthread_create(&g_newTh2, &attr, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+#if (LOSCFG_KERNEL_SMP == YES)
+ while (g_testCount < 2) { // 2, delay until g_testCount is equal to 2.
+ TestBusyTaskDelay(1);
+ }
+ TestBusyTaskDelay(1);
+#else
+ g_testCount++;
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+#endif
+EXIT:
+ return NULL;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINTPTR temp = 1;
+ g_testCount = 0;
+
+ ret = pthread_create(&g_newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ TestExtraTaskDelay(10); // 10, delay for Timing control.
+
+ ret = pthread_join(g_newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+ ret = pthread_join(g_newTh2, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread068(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread068", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_069.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_069.c
new file mode 100644
index 0000000000000000000000000000000000000000..f2c258ba99b1a6f4f55411d92f734004ff5bd83e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_069.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_condattr_t condattr;
+ pthread_cond_t cond1;
+ pthread_cond_t cond2;
+ int rc;
+
+ rc = pthread_condattr_init(&condattr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_init(&cond1, &condattr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_init(&cond2, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_destroy(&cond1);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+ rc = pthread_cond_destroy(&cond2);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread069(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread069", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_071.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_071.c
new file mode 100644
index 0000000000000000000000000000000000000000..96577bada96e0a21f248c783eb55f52dbefec95a
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_071.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_condattr_t condattr;
+ int rc;
+ pthread_cond_t cond1, cond2;
+ pthread_cond_t cond3 = PTHREAD_COND_INITIALIZER;
+
+ /* Initialize a condition variable attribute object */
+ rc = pthread_condattr_init(&condattr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Initialize cond1 with the default condition variable attribute */
+ rc = pthread_cond_init(&cond1, &condattr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Initialize cond2 with NULL attributes */
+ rc = pthread_cond_init(&cond2, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Destroy the condition variable attribute object */
+ rc = pthread_condattr_destroy(&condattr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Destroy cond1 */
+ rc = pthread_cond_destroy(&cond1);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Destroy cond2 */
+ rc = pthread_cond_destroy(&cond2);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Destroy cond3 */
+ rc = pthread_cond_destroy(&cond3);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread071(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread071", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_072.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_072.c
new file mode 100644
index 0000000000000000000000000000000000000000..1de9885837e1ef4092e4a7e51f6e438bd589d01b
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_072.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *PthreadF01(void *tmp)
+{
+ int rc;
+ g_testCount++;
+
+ /* acquire the mutex */
+ rc = pthread_mutex_lock(&g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_testCount++;
+ /* Wait on the cond var. This will not return, as nobody signals */
+ rc = pthread_cond_wait(&g_pthreadCondTest1, &g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_testCount++;
+
+ rc = pthread_mutex_unlock(&g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_testCount++;
+EXIT:
+ return NULL;
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t lowId;
+ int rc;
+
+ g_pthreadMutexTest1 = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
+ g_pthreadCondTest1 = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
+ g_testCount = 0;
+
+ /* Create a new thread with default attributes */
+ rc = pthread_create(&lowId, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Let the other thread run */
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ /* Try to destroy the cond var. This should return an error */
+ rc = pthread_cond_destroy(&g_pthreadCondTest1);
+ ICUNIT_ASSERT_EQUAL(rc, EBUSY, rc);
+
+ rc = pthread_cond_broadcast(&g_pthreadCondTest1);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, here assert the result.
+
+ rc = pthread_cond_destroy(&g_pthreadCondTest1);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_join(lowId, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread072(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread072", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_073.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_073.c
new file mode 100644
index 0000000000000000000000000000000000000000..ba0a89ae0d961d5818c01e4d2ffd17369c551fc3
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_073.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_condattr_t condattr;
+ int rc;
+
+#ifdef PTHREAD_PROCESS_SHARED
+ int pshared;
+#endif
+ /* Initialize a cond attributes object */
+ rc = pthread_condattr_init(&condattr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+#ifdef PTHREAD_PROCESS_SHARED
+ /* If the symbol {PTHREAD_PROCESS_SHARED} is defined, the attribute
+ * process-shared should be provided and its default value should be
+ * PTHREAD_PROCESS_PRIVATE */
+ rc = pthread_condattr_getpshared(&condattr, &pshared);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ ICUNIT_ASSERT_EQUAL(pshared, PTHREAD_PROCESS_PRIVATE, pshared);
+
+#endif
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread073(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread073", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_074.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_074.c
new file mode 100644
index 0000000000000000000000000000000000000000..a239e2d13cd2a3276c602e296453518260118cab
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_074.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_condattr_t condattr;
+ int rc;
+
+ /* Initialize a condition variable attributes object */
+ rc = pthread_condattr_init(&condattr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Destroy the condition variable attributes object */
+ rc = pthread_condattr_destroy(&condattr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Initialize the condition variable attributes object again. This shouldn't result in an error. */
+ rc = pthread_condattr_init(&condattr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread074(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread074", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_075.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_075.c
new file mode 100644
index 0000000000000000000000000000000000000000..d07276220279da4a185f57a29740b28a09cf2d60
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_075.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_condattr_t *condattr = NULL;
+ int rc;
+
+ /* Initialize a condition variable attributes object */
+ rc = pthread_condattr_init(condattr);
+ ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
+
+ /* Destroy the condition variable attributes object */
+ rc = pthread_condattr_destroy(condattr);
+ ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread075(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread075", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_078.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_078.c
new file mode 100644
index 0000000000000000000000000000000000000000..7f3b3893101f49d3850b4916999900dd5446ce41
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_078.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_condattr_t attr;
+ int ret;
+
+ /* Initialize a cond attributes object */
+ ret = pthread_condattr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ /* Set 'pshared' to INVALID_PSHARED_VALUE. */
+ ret = pthread_condattr_setpshared(&attr, INVALID_PSHARED_VALUE);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ /* Destroy the cond attributes object */
+ ret = pthread_condattr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread078(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread078", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_079.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_079.c
new file mode 100644
index 0000000000000000000000000000000000000000..c6f17f00b6426414e45f862dbfc34756e330bd76
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_079.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_condattr_t attr;
+ int ret;
+ int pshared;
+
+ /* Initialize a cond attributes object */
+ ret = pthread_condattr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ /* Set 'pshared' to INVALID_PSHARED_VALUE. */
+ ret = pthread_condattr_getpshared(&attr, &pshared);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(pshared, PTHREAD_PROCESS_PRIVATE, pshared);
+
+ /* Destroy the cond attributes object */
+ ret = pthread_condattr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread079(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread079", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_080.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_080.c
new file mode 100644
index 0000000000000000000000000000000000000000..1abd1b91748d5ce52eb669ab53345f8d39dad8ac
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_080.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *PthreadF01(void *arg)
+{
+ int rc;
+
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_startNum++;
+
+ rc = pthread_cond_wait(&g_td.cond, &g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_wakenNum++;
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+EXIT:
+ return NULL;
+}
+static UINT32 Testcase(VOID)
+{
+ int i, rc;
+ g_startNum = 0;
+ g_wakenNum = 0;
+ pthread_t thread[THREAD_NUM];
+
+ rc = pthread_mutex_init(&g_td.mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_init(&g_td.cond, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ for (i = 0; i < THREAD_NUM; i++) {
+ rc = pthread_create(&thread[i], NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ while (g_startNum < THREAD_NUM)
+ usleep(100); // 100, delay for Timing control.
+
+ /*
+ * Acquire the mutex to make sure that all waiters are currently
+ * blocked on pthread_cond_wait
+ */
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* broadcast and check if all waiters are wakened */
+
+ rc = pthread_cond_broadcast(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ sleep(1);
+
+ ICUNIT_ASSERT_EQUAL(g_wakenNum, THREAD_NUM, g_wakenNum);
+
+ /* join all secondary threads */
+ for (i = 0; i < THREAD_NUM; i++) {
+ rc = pthread_join(thread[i], NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ rc = pthread_cond_destroy(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread080(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread080", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_081.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_081.c
new file mode 100644
index 0000000000000000000000000000000000000000..b7ee988c62d86c36b616a2f7f9a9f884aa9ab26d
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_081.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *PthreadF01(void *arg)
+{
+ int rc;
+
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_startNum++;
+
+ rc = pthread_cond_wait(&g_td.cond, &g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ rc = pthread_mutex_trylock(&g_td.mutex);
+ ICUNIT_GOTO_NOT_EQUAL(rc, 0, rc, EXIT);
+
+ g_wakenNum++;
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ int i, rc;
+ pthread_t thread[THREAD_NUM];
+
+ g_startNum = 0;
+ g_wakenNum = 0;
+
+ rc = pthread_mutex_init(&g_td.mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_init(&g_td.cond, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ for (i = 0; i < THREAD_NUM; i++) {
+ rc = pthread_create(&thread[i], NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ while (g_startNum < THREAD_NUM)
+ usleep(100); // 100, delay for Timing control.
+
+ /*
+ * Acquire the mutex to make sure that all waiters are currently
+ * blocked on pthread_cond_wait
+ */
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* broadcast and check if all waiters are wakened */
+
+ rc = pthread_cond_broadcast(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ sleep(1);
+
+ ICUNIT_ASSERT_EQUAL(g_wakenNum, THREAD_NUM, g_wakenNum);
+
+ /* join all secondary threads */
+ for (i = 0; i < THREAD_NUM; i++) {
+ rc = pthread_join(thread[i], NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ rc = pthread_cond_destroy(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread081(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread081", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_082.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_082.c
new file mode 100644
index 0000000000000000000000000000000000000000..6a30d5715cc8de36aad73126be9a34e1d4b41be5
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_082.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *PthreadF01(void *arg)
+{
+ int rc;
+ struct timespec timeout;
+ struct timeval curtime;
+
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_startNum++;
+
+ rc = gettimeofday(&curtime, NULL);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ timeout.tv_sec = curtime.tv_sec + PTHREAD_TIMEOUT;
+ timeout.tv_nsec = curtime.tv_usec * 1000; // 1000, us transfer to ns.
+
+ rc = pthread_cond_timedwait(&g_td.cond, &g_td.mutex, &timeout);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ rc = pthread_mutex_trylock(&g_td.mutex);
+ ICUNIT_GOTO_NOT_EQUAL(rc, 0, rc, EXIT);
+
+ g_wakenNum++;
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+EXIT:
+ return NULL;
+}
+static UINT32 Testcase(VOID)
+{
+ int i, rc;
+ pthread_t thread[THREAD_NUM];
+
+ g_startNum = 0;
+ g_wakenNum = 0;
+
+ rc = pthread_mutex_init(&g_td.mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_init(&g_td.cond, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ for (i = 0; i < THREAD_NUM; i++) {
+ rc = pthread_create(&thread[i], NULL, PthreadF01, NULL); //
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ while (g_startNum < THREAD_NUM)
+ usleep(100); // 100, delay for Timing control.
+
+ /*
+ * Acquire the mutex to make sure that all waiters are currently
+ * blocked on pthread_cond_wait
+ */
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* broadcast and check if all waiters are wakened */
+
+ ICUNIT_ASSERT_EQUAL(g_wakenNum, 0, g_wakenNum);
+
+ rc = pthread_cond_broadcast(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ sleep(1);
+
+ ICUNIT_ASSERT_EQUAL(g_wakenNum, THREAD_NUM, g_wakenNum);
+
+ /* join all secondary threads */
+ for (i = 0; i < THREAD_NUM; i++) {
+ rc = pthread_join(thread[i], NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ rc = pthread_cond_destroy(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread082(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread082", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_083.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_083.c
new file mode 100644
index 0000000000000000000000000000000000000000..4398444a811419a48cda862b882511aeed0e504f
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_083.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *PthreadF01(void *arg)
+{
+ int rc;
+
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_startNum++;
+
+ rc = pthread_cond_wait(&g_td.cond, &g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_wakenNum++;
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+EXIT:
+ return NULL;
+}
+static UINT32 Testcase(VOID)
+{
+ int i, rc;
+ pthread_t thread[THREAD_NUM];
+
+ g_startNum = 0;
+ g_wakenNum = 0;
+
+ rc = pthread_mutex_init(&g_td.mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_init(&g_td.cond, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ for (i = 0; i < THREAD_NUM; i++) {
+ rc = pthread_create(&thread[i], NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ while (g_startNum < THREAD_NUM)
+ usleep(100); // 100, delay for Timing control.
+
+ /*
+ * Acquire the mutex to make sure that all waiters are currently
+ * blocked on pthread_cond_wait
+ */
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* broadcast and check if all waiters are wakened */
+
+ ICUNIT_ASSERT_EQUAL(g_wakenNum, 0, g_wakenNum);
+
+ rc = pthread_cond_signal(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ sleep(1);
+
+ ICUNIT_ASSERT_EQUAL(g_wakenNum, 1, g_wakenNum);
+
+ rc = pthread_cond_signal(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_signal(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_signal(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ sleep(1);
+
+ ICUNIT_ASSERT_EQUAL(g_wakenNum, THREAD_NUM, g_wakenNum);
+
+ /* join all secondary threads */
+ for (i = 0; i < THREAD_NUM; i++) {
+ rc = pthread_join(thread[i], NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ rc = pthread_cond_destroy(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread083(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread083", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_084.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_084.c
new file mode 100644
index 0000000000000000000000000000000000000000..0f54d29801e6e1f5dfc88c33d9a9a15f9ea2b9e5
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_084.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *PthreadF01(void *arg)
+{
+ int rc;
+
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_startNum++;
+
+ rc = pthread_cond_wait(&g_td.cond, &g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ rc = pthread_mutex_trylock(&g_td.mutex);
+ ICUNIT_GOTO_NOT_EQUAL(rc, 0, rc, EXIT);
+
+ g_wakenNum++;
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+EXIT:
+ return NULL;
+}
+static UINT32 Testcase(VOID)
+{
+ int i, rc;
+ pthread_t thread[THREAD_NUM];
+
+ g_startNum = 0;
+ g_wakenNum = 0;
+
+ rc = pthread_mutex_init(&g_td.mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_init(&g_td.cond, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ for (i = 0; i < THREAD_NUM; i++) {
+ rc = pthread_create(&thread[i], NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ while (g_startNum < THREAD_NUM)
+ usleep(100); // 100, delay for Timing control.
+
+ /*
+ * Acquire the mutex to make sure that all waiters are currently
+ * blocked on pthread_cond_wait
+ */
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* broadcast and check if all waiters are wakened */
+
+ rc = pthread_cond_signal(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ sleep(1);
+
+ ICUNIT_ASSERT_EQUAL(g_wakenNum, 1, g_wakenNum);
+
+ rc = pthread_cond_signal(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_signal(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_signal(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ sleep(1);
+
+ ICUNIT_ASSERT_EQUAL(g_wakenNum, THREAD_NUM, g_wakenNum);
+
+ /* join all secondary threads */
+ for (i = 0; i < THREAD_NUM; i++) {
+ rc = pthread_join(thread[i], NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ rc = pthread_cond_destroy(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread084(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread084", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_085.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_085.c
new file mode 100644
index 0000000000000000000000000000000000000000..1e2136f96fa2fa5c7a85da8a571cecb687fb08ea
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_085.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *PthreadF01(void *arg)
+{
+ int rc;
+
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_t1Start = 1; /* let main thread continue */
+
+ rc = pthread_cond_wait(&g_td.cond, &g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ ICUNIT_GOTO_NOT_EQUAL(g_signaled, 0, g_signaled, EXIT);
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_t1Start = 2; // 2, init.
+EXIT:
+ return NULL;
+}
+static UINT32 Testcase(VOID)
+{
+ struct sigaction act;
+ int rc;
+ pthread_t thread1;
+
+ g_t1Start = 0;
+
+ rc = pthread_mutex_init(&g_td.mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_init(&g_td.cond, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_create(&thread1, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ while (!g_t1Start) /* wait for thread1 started */
+ usleep(100); // 100, delay for Timing control.
+
+ /* acquire the mutex released by pthread_cond_wait() within thread 1 */
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ sleep(1);
+
+ fprintf(stderr, "Time to wake up thread1 by signaling a condition\n");
+ g_signaled = 1;
+ rc = pthread_cond_signal(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_join(thread1, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ ICUNIT_ASSERT_EQUAL(g_t1Start, 2, g_t1Start); // 2, here assert the result.
+ g_signaled = 0;
+
+ rc = pthread_cond_destroy(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread085(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread085", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_087.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_087.c
new file mode 100644
index 0000000000000000000000000000000000000000..bda1e4e0b2a29fde07074851169b294ed68d1f8c
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_087.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *PthreadF01(void *arg)
+{
+ int rc;
+ struct timespec timeout;
+ struct timeval curtime;
+
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_t1Start = 1; /* let main thread continue */
+
+ timeout.tv_sec = PTHREAD_TIMEOUT;
+ timeout.tv_nsec = 0;
+
+ rc = pthread_cond_timedwait(&g_td.cond, &g_td.mutex, &timeout);
+ ICUNIT_GOTO_EQUAL(rc, ETIMEDOUT, rc, EXIT);
+
+ rc = pthread_mutex_trylock(&g_td.mutex);
+ ICUNIT_GOTO_NOT_EQUAL(rc, 0, rc, EXIT);
+ ICUNIT_GOTO_EQUAL(g_signaled, 1, g_signaled, EXIT);
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+EXIT:
+ pthread_exit((void *)5); // 5, here set value of the exit status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ struct sigaction act;
+ int rc;
+ pthread_t thread1;
+ void *thRet = NULL;
+
+ g_t1Start = 0;
+
+ rc = pthread_mutex_init(&g_td.mutex, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_init(&g_td.cond, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_create(&thread1, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ while (!g_t1Start) { /* wait for thread1 started */
+ usleep(100); // 100, delay for Timing control.
+ }
+
+ /* acquire the mutex released by pthread_cond_wait() within thread 1 */
+ rc = pthread_mutex_lock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_mutex_unlock(&g_td.mutex);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ sleep(1);
+ g_signaled = 1;
+ rc = pthread_join(thread1, &thRet);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ ICUNIT_ASSERT_EQUAL((long)(intptr_t)thRet, 5, (long)(intptr_t)thRet); // 5, here assert the result.
+ g_signaled = 0;
+
+ rc = pthread_cond_destroy(&g_td.cond);
+ ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread087(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread087", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_088.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_088.c
new file mode 100644
index 0000000000000000000000000000000000000000..50870b067f6639ede0cdcbc9c07ce04719892306
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_088.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void PthreadSignalHandlerF01(int sig)
+{
+ int rc;
+
+ rc = pthread_cond_signal(&g_pthreadCondTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(rc, 0, rc);
+}
+
+/* Utility function to find difference between two time values */
+static float PthreadTimeF01(struct timespec t2, struct timespec t1)
+{
+ float diff = t2.tv_sec - t1.tv_sec;
+ diff += (t2.tv_nsec - t1.tv_nsec) / 1000000000.0; // 1000000000.0, ns to s.
+ return diff;
+}
+
+static void *PthreadF01(void *tmp)
+{
+ struct sched_param param;
+ int policy;
+ int rc;
+
+ param.sched_priority = HIGH_PRIORITY;
+
+ rc = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ rc = pthread_getschedparam(pthread_self(), &policy, ¶m);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT);
+ ICUNIT_GOTO_EQUAL(param.sched_priority, HIGH_PRIORITY, param.sched_priority, EXIT);
+
+ /* acquire the mutex */
+ rc = pthread_mutex_lock(&g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ /* Block, to be woken up by the signal handler */
+ rc = pthread_cond_wait(&g_pthreadCondTest1, &g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ /* This variable is unprotected because the scheduling removes
+ * the contention
+ */
+ if (g_lowDone != 1)
+ g_wokenUp = 1;
+
+ rc = pthread_mutex_unlock(&g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+EXIT:
+ return NULL;
+}
+
+static void *PthreadF02(void *tmp)
+{
+ struct timespec startTime, currentTime;
+ struct sched_param param;
+ int policy;
+ int rc;
+
+ param.sched_priority = LOW_PRIORITY;
+
+ rc = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ rc = pthread_getschedparam(pthread_self(), &policy, ¶m);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT);
+ ICUNIT_GOTO_EQUAL(param.sched_priority, LOW_PRIORITY, param.sched_priority, EXIT);
+
+ PthreadSignalHandlerF01(SIGALRM);
+
+ /* grab the start time and busy loop for 5 seconds */
+ clock_gettime(CLOCK_REALTIME, &startTime);
+ while (1) {
+ clock_gettime(CLOCK_REALTIME, ¤tTime);
+ if (PthreadTimeF01(currentTime, startTime) > RUNTIME)
+ break;
+ }
+ g_lowDone = 1;
+EXIT:
+ return NULL;
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t highId, lowId;
+ pthread_attr_t highAttr, lowAttr;
+ struct sched_param param;
+ int rc;
+
+ g_pthreadMutexTest1 = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
+ g_pthreadCondTest1 = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
+ /* Create the higher priority thread */
+ rc = pthread_attr_init(&highAttr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_attr_setschedpolicy(&highAttr, SCHED_RR); //
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ highAttr.inheritsched = PTHREAD_EXPLICIT_SCHED;
+
+ param.sched_priority = HIGH_PRIORITY;
+ rc = pthread_attr_setschedparam(&highAttr, ¶m);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_create(&highId, &highAttr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Create the low priority thread */
+ rc = pthread_attr_init(&lowAttr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_attr_setschedpolicy(&lowAttr, SCHED_RR); //
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ lowAttr.inheritsched = PTHREAD_EXPLICIT_SCHED;
+
+ param.sched_priority = LOW_PRIORITY;
+ rc = pthread_attr_setschedparam(&lowAttr, ¶m);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_create(&lowId, &lowAttr, PthreadF02, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Wait for the threads to exit */
+ rc = pthread_join(highId, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_join(lowId, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_destroy(&g_pthreadCondTest1);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Check the result */
+ ICUNIT_ASSERT_EQUAL(g_wokenUp, 1, g_wokenUp);
+ ICUNIT_ASSERT_EQUAL(g_lowDone, 1, g_lowDone);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread088(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread088", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_089.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_089.c
new file mode 100644
index 0000000000000000000000000000000000000000..7b4f6460f09648df5cace19832f259df82f4dd0d
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_089.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void PthreadSignalHandlerF01(int sig)
+{
+ int rc;
+ rc = pthread_cond_broadcast(&g_pthreadCondTest1);
+ ICUNIT_ASSERT_EQUAL_VOID(rc, 0, rc);
+}
+
+/* Utility function to find difference between two time values */
+static float PthreadTimeF01(struct timespec t2, struct timespec t1)
+{
+ float diff = t2.tv_sec - t1.tv_sec;
+ diff += (t2.tv_nsec - t1.tv_nsec) / 1000000000.0; // 1000000000.0, ns to s.
+ return diff;
+}
+
+static void *PthreadF01(void *tmp)
+{
+ struct sched_param param;
+ int policy;
+ int rc;
+
+ param.sched_priority = HIGH_PRIORITY;
+
+ rc = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ rc = pthread_getschedparam(pthread_self(), &policy, ¶m);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT);
+ ICUNIT_GOTO_EQUAL(param.sched_priority, HIGH_PRIORITY, param.sched_priority, EXIT);
+
+ /* acquire the mutex */
+ rc = pthread_mutex_lock(&g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ /* Block, to be woken up by the signal handler */
+ rc = pthread_cond_wait(&g_pthreadCondTest1, &g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ /* This variable is unprotected because the scheduling removes
+ * the contention
+ */
+ if (g_lowDone != 1)
+ g_wokenUp = 1;
+
+ rc = pthread_mutex_unlock(&g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+EXIT:
+ return NULL;
+}
+
+static void *PthreadF02(void *tmp)
+{
+ struct timespec startTime, currentTime;
+ struct sched_param param;
+ int policy;
+ int rc;
+
+ ICUNIT_GOTO_EQUAL(g_wokenUp, -1, g_wokenUp, EXIT);
+
+ param.sched_priority = LOW_PRIORITY;
+
+ rc = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ rc = pthread_getschedparam(pthread_self(), &policy, ¶m);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT);
+ ICUNIT_GOTO_EQUAL(param.sched_priority, LOW_PRIORITY, param.sched_priority, EXIT);
+
+ PthreadSignalHandlerF01(SIGALRM);
+
+ /* grab the start time and busy loop for 5 seconds */
+ clock_gettime(CLOCK_REALTIME, &startTime);
+ while (1) {
+ clock_gettime(CLOCK_REALTIME, ¤tTime);
+ if (PthreadTimeF01(currentTime, startTime) > RUNTIME)
+ break;
+ }
+ g_lowDone = 1;
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t highId, lowId;
+ pthread_attr_t highAttr, lowAttr;
+ struct sched_param param;
+ int rc;
+
+ g_wokenUp = -1;
+ g_lowDone = -1;
+
+ g_pthreadMutexTest1 = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
+ g_pthreadCondTest1 = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
+ /* Create the higher priority thread */
+ rc = pthread_attr_init(&highAttr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_attr_setschedpolicy(&highAttr, SCHED_RR);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ highAttr.inheritsched = PTHREAD_EXPLICIT_SCHED;
+
+ param.sched_priority = HIGH_PRIORITY;
+ rc = pthread_attr_setschedparam(&highAttr, ¶m);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_create(&highId, &highAttr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Create the low priority thread */
+ rc = pthread_attr_init(&lowAttr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_attr_setschedpolicy(&lowAttr, SCHED_RR);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ param.sched_priority = LOW_PRIORITY;
+ rc = pthread_attr_setschedparam(&lowAttr, ¶m);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_create(&lowId, &lowAttr, PthreadF02, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Wait for the threads to exit */
+ rc = pthread_join(highId, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_join(lowId, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_cond_destroy(&g_pthreadCondTest1);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Check the result */
+ ICUNIT_ASSERT_EQUAL(g_wokenUp, 1, g_wokenUp);
+ ICUNIT_ASSERT_EQUAL(g_lowDone, 1, g_lowDone);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread089(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread089", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_092.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_092.c
new file mode 100644
index 0000000000000000000000000000000000000000..6002f9beb9cfc6e0ff99a97d305a220b969c43e1
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_092.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF02(void *argument)
+{
+ int oldstate;
+ UINT32 ret;
+ int i;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+ g_testCount++;
+
+ ret = pthread_cancel(g_newTh);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+ g_testCount++;
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static VOID *PthreadF01(void *argument)
+{
+ int oldstate;
+ UINT32 ret;
+ pthread_attr_t attr;
+
+ TestExtraTaskDelay(1);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DEFERRED, oldstate, EXIT);
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ attr.inheritsched = PTHREAD_EXPLICIT_SCHED;
+ attr.schedparam.sched_priority = 8; // 8, set priority.
+
+ ret = pthread_create(&g_newTh2, &attr, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ /* cannot preempt on smp */
+ TestExtraTaskDelay(10); // 10, delay for Timing control.
+
+ ICUNIT_GOTO_EQUAL(g_testCount, -1, g_testCount, EXIT);
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINTPTR wtemp = 1;
+
+ int i;
+ g_testCount = 0;
+
+ ret = pthread_create(&g_newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+ g_testCount++;
+
+ ret = pthread_join(g_newTh, (void *)&wtemp);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+ g_testCount++;
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(wtemp, (UINTPTR)PTHREAD_CANCELED, wtemp);
+
+ ret = pthread_join(g_newTh2, NULL);
+
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result.
+ g_testCount++;
+
+EXIT:
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread092(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread092", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_095.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_095.c
new file mode 100644
index 0000000000000000000000000000000000000000..b40b2698fb0f389f57542c28f214b0bf5c98ea3e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_095.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static int g_testCnt;
+
+static VOID *PthreadF02(void *argument)
+{
+ int oldstate;
+ UINT32 ret;
+ int i;
+
+ ICUNIT_GOTO_EQUAL(g_testCnt, 2, g_testCnt, EXIT); // 2, here assert the result.
+ g_testCnt++;
+
+ ret = pthread_cancel(g_newTh);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ ICUNIT_GOTO_EQUAL(g_testCnt, 5, g_testCnt, EXIT); // 5, here assert the result.
+ g_testCnt++;
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static VOID *PthreadF01(void *argument)
+{
+ int oldstate;
+ UINT32 ret;
+ pthread_attr_t attr;
+
+ TestExtraTaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCnt, 1, g_testCnt, EXIT);
+ g_testCnt++;
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DEFERRED, oldstate, EXIT);
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ attr.inheritsched = PTHREAD_EXPLICIT_SCHED;
+ attr.schedparam.sched_priority = 26; // 26, set priority.
+
+ ret = pthread_create(&g_newTh2, &attr, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ LOS_TaskDelay(LOS_MS2Tick(1000)); // 1000, delay for Timing control.
+
+ ICUNIT_GOTO_EQUAL(g_testCnt, -1, g_testCnt, EXIT);
+ g_testCnt++;
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ UINTPTR wtemp = 1;
+
+ int i;
+ g_testCnt = 0;
+
+ ret = pthread_create(&g_newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCnt, 0, g_testCnt);
+ g_testCnt++;
+
+ ret = pthread_join(g_newTh, (void *)&wtemp);
+
+ ICUNIT_GOTO_EQUAL(g_testCnt, 3, g_testCnt, EXIT); // 3, here assert the result.
+ g_testCnt++;
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(wtemp, (UINTPTR)PTHREAD_CANCELED, wtemp);
+
+ ICUNIT_GOTO_EQUAL(g_testCnt, 4, g_testCnt, EXIT); // 4, here assert the result.
+ g_testCnt++;
+
+ ret = pthread_join(g_newTh2, NULL);
+
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_GOTO_EQUAL(g_testCnt, 6, g_testCnt, EXIT); // 6, here assert the result.
+ g_testCnt++;
+
+EXIT:
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread095(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread095", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_098.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_098.c
new file mode 100644
index 0000000000000000000000000000000000000000..aa079c07c4e8e94f03c709611d0d4b37203da295
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_098.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ _pthread_data *self = NULL;
+ g_testCount++;
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+
+ pthread_testcancel();
+ g_testCount++;
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ pthread_attr_t attr;
+ UINTPTR temp = 1;
+ _pthread_data *f = NULL;
+ _pthread_data *f1 = NULL;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ f = pthread_get_data(newTh);
+ ICUNIT_ASSERT_NOT_EQUAL(f, NULL, f);
+
+ f->id += 1;
+ f1 = pthread_get_data(newTh);
+ ICUNIT_ASSERT_EQUAL(f1, NULL, f1);
+
+ f->id -= 1;
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread098(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread098", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_101.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_101.c
new file mode 100644
index 0000000000000000000000000000000000000000..d41b131846349445d6acf39b220a87b64bb5aca6
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_101.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ UINT32 ret;
+ int oldstate;
+ UINT32 i, j;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DEFERRED, oldstate, EXIT);
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh, newTh2;
+ UINT32 ret;
+ pthread_attr_t attr;
+
+ pthread_attr_init(&attr);
+ attr.detachstate = PTHREAD_CREATE_DETACHED;
+
+ g_testCount = 1;
+
+ ret = pthread_create(&newTh2, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+
+ ret = pthread_cancel(newTh2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread101(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread101", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_102.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_102.c
new file mode 100644
index 0000000000000000000000000000000000000000..d6e187449c79a4c78751e7bec254e681d9958be2
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_102.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void PthreadOnceF01(VOID)
+{
+ g_testCount++;
+}
+
+static VOID HwiF01(int irq, void *dev)
+{
+ UINT32 ret;
+ struct sched_param param;
+ TEST_HwiClear(HWI_NUM_TEST);
+ g_testCount += 1;
+
+ ret = pthread_once(&g_onceControl, PthreadOnceF01);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, EINTR, ret);
+ ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result.
+
+ g_testCount += 1;
+
+ return;
+}
+
+static VOID *PthreadF01(void *argument)
+{
+ UINT32 ret;
+ g_testCount++;
+
+EXIT:
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+
+ g_testCount = 0;
+ g_onceControl = PTHREAD_ONCE_INIT;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return PTHREAD_NO_ERROR;
+EXIT:
+ return LOS_NOK;
+}
+
+VOID ItPosixPthread102(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread102", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_103.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_103.c
new file mode 100644
index 0000000000000000000000000000000000000000..88aa0bc82c8382d8b6d419998a725f91a2e542d2
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_103.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+ pthread_exit((void *)8); // 8, here set value about the exit status.
+
+ return argument;
+}
+
+static VOID HwiF01(int irq, void *dev)
+{
+ UINT32 ret;
+ int policy;
+ struct sched_param param = { 31 };
+ struct sched_param param2 = { 2 };
+ TEST_HwiClear(HWI_NUM_TEST);
+ g_testCount += 1;
+
+ ret = pthread_setschedparam(g_testNewTh, SCHED_RR, ¶m);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, EINTR, ret);
+
+ g_testCount += 1;
+ ret = pthread_getschedparam(g_testNewTh, &policy, ¶m2);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, EINTR, ret);
+ g_testCount += 1;
+
+ return;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ unsigned long flags;
+ UINTPTR temp;
+ g_testCount = 0;
+
+ ret = pthread_create(&g_testNewTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ TestHwiTrigger(HWI_NUM_TEST);
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+
+ ret = pthread_join(g_testNewTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 8, temp); // 8, here assert the result.
+
+ TEST_HwiDelete(HWI_NUM_TEST);
+
+ return PTHREAD_NO_ERROR;
+
+EXIT:
+ return LOS_NOK;
+}
+
+VOID ItPosixPthread103(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread103", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_107.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_107.c
new file mode 100644
index 0000000000000000000000000000000000000000..932984ee7597b63bea5755bd1c0f212b166595b3
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_107.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define LOOP_NUM 2
+
+static VOID *PthreadF01(void *t)
+{
+ int rc;
+
+ rc = pthread_mutex_lock(&g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ g_testCount++;
+ LOS_TaskDelay(1);
+ ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
+ g_testCount++;
+
+ rc = pthread_cond_wait(&g_pthreadCondTest1, &g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result.
+ rc = pthread_mutex_unlock(&g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+EXIT:
+ return NULL;
+}
+
+static VOID *PthreadF02(void *t)
+{
+ int i;
+ int rc;
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
+ g_testCount++;
+ rc = pthread_mutex_lock(&g_pthreadMutexTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
+ g_testCount++;
+ rc = pthread_cond_signal(&g_pthreadCondTest1);
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+
+ ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
+ g_testCount++;
+
+ rc = pthread_mutex_unlock(&g_pthreadMutexTest1); /* Increase latency for thread polling mutex */
+ ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+
+EXIT:
+ pthread_exit(NULL);
+}
+static UINT32 Testcase(VOID)
+{
+ int i;
+ long t1 = 1;
+ long t2 = 2; // 2, init
+ int rc;
+ pthread_t threads[3]; // 3, need 3 pthread for test.
+ pthread_attr_t attr; /* Initializes mutex and conditional variable objects */
+
+ g_testCount = 0;
+ pthread_mutex_init(&g_pthreadMutexTest1, NULL);
+ /* When creating thread, it is set to connectable state, which is easy to transplant */
+ pthread_cond_init(&g_pthreadCondTest1, NULL);
+ pthread_attr_init(&attr);
+
+ rc = pthread_create(&threads[0], &attr, PthreadF01, (void *)t1);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_create(&threads[1], &attr, PthreadF02, (void *)t2);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ /* Wait for all threads to complete */
+ for (i = 0; i < LOOP_NUM; i++) {
+ rc = pthread_join(threads[i], NULL);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ }
+
+ /* Clear and exit */
+ rc = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ rc = pthread_mutex_destroy(&g_pthreadMutexTest1);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ rc = pthread_cond_destroy(&g_pthreadCondTest1);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread107(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread107", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_108.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_108.c
new file mode 100644
index 0000000000000000000000000000000000000000..272053309b82bdff934c7f6f512be071a9a5684f
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_108.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_condattr_t condattr;
+ pthread_cond_t cond1;
+ pthread_cond_t cond2;
+ int pshared;
+ int rc;
+
+ rc = pthread_condattr_getpshared(NULL, &pshared);
+ ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
+
+ rc = pthread_condattr_getpshared(&condattr, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
+
+ rc = pthread_condattr_getpshared(NULL, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
+
+ rc = pthread_condattr_getpshared(&condattr, &pshared);
+ ICUNIT_ASSERT_EQUAL(rc, 0, rc);
+ ICUNIT_ASSERT_EQUAL(pshared, PTHREAD_PROCESS_PRIVATE, pshared);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread108(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread108", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_110.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_110.c
new file mode 100644
index 0000000000000000000000000000000000000000..45fa878d57f85d01a9d17de546fb09b36e9cc10f
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_110.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ int rc;
+
+ rc = pthread_cond_init(NULL, NULL);
+ ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread110(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread110", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_112.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_112.c
new file mode 100644
index 0000000000000000000000000000000000000000..0475dd850244cb117bd19d2d7bc7fc072d1a3fc2
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_112.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ int rc;
+
+ rc = pthread_cond_signal(NULL);
+ ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
+
+ rc = pthread_cond_broadcast(NULL);
+ ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread112(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread112", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_116.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_116.c
new file mode 100644
index 0000000000000000000000000000000000000000..3683c91cb896f2acc0b2bc7969cedc8d539b45e6
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_116.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static pthread_t g_th1;
+static pthread_mutex_t g_mutx = PTHREAD_MUTEX_INITIALIZER;
+static int g_cnt = 0;
+#define PRI 9
+
+static VOID *PthreadF01(VOID *arg)
+{
+ struct sched_param schParam;
+ UINT32 priority;
+ UINT32 sched = SCHED_RR;
+ int ret;
+
+ g_cnt++;
+ ICUNIT_GOTO_EQUAL(g_cnt, 1, g_cnt, EXIT);
+ pthread_mutex_lock(&g_mutx);
+ LOS_TaskDelay(10); // 10, delay for Timing control.
+
+ pthread_getschedparam(g_th1, &sched, &schParam);
+ ICUNIT_GOTO_EQUAL(schParam.sched_priority, PRI, schParam.sched_priority, EXIT);
+
+ priority = schParam.sched_priority - 4; // 4, Set reasonable priority
+ schParam.sched_priority = priority;
+ ret = pthread_setschedparam(g_th1, sched, &schParam);
+ g_cnt++;
+ ICUNIT_GOTO_EQUAL(g_cnt, 3, g_cnt, EXIT); // 3, here assert the result.
+ pthread_mutex_unlock(&g_mutx);
+ pthread_getschedparam(g_th1, &sched, &schParam);
+ ICUNIT_GOTO_EQUAL(schParam.sched_priority, priority, schParam.sched_priority, EXIT);
+EXIT:
+ return NULL;
+}
+
+static VOID *PthreadF02(VOID *arg)
+{
+ g_cnt++;
+ ICUNIT_GOTO_EQUAL(g_cnt, 2, g_cnt, EXIT); // 2, here assert the result.
+ pthread_mutex_lock(&g_mutx);
+
+ g_cnt++;
+ ICUNIT_GOTO_EQUAL(g_cnt, 4, g_cnt, EXIT); // 4, here assert the result.
+ pthread_mutex_unlock(&g_mutx);
+
+ return NULL;
+EXIT:
+ pthread_mutex_unlock(&g_mutx);
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ pthread_attr_t attr;
+ struct sched_param schParam;
+ UINT32 priority;
+ UINT32 sched = SCHED_RR;
+ g_cnt = 0;
+
+ pthread_attr_init(&attr);
+ attr.schedparam.sched_priority = PRI;
+ attr.inheritsched = PTHREAD_EXPLICIT_SCHED;
+ attr.detachstate = PTHREAD_CREATE_DETACHED;
+
+ ret = pthread_create(&g_th1, &attr, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ pthread_attr_init(&attr);
+ attr.schedparam.sched_priority = PRI - 1;
+ attr.inheritsched = PTHREAD_EXPLICIT_SCHED;
+
+ ret = pthread_create(&newTh, &attr, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ pthread_getschedparam(g_th1, &sched, &schParam);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(g_cnt, 4, g_cnt, EXIT); // 4, here assert the result.
+
+ return PTHREAD_NO_ERROR;
+
+EXIT:
+ pthread_detach(g_th1);
+ pthread_detach(newTh);
+ return LOS_NOK;
+}
+
+VOID ItPosixPthread116(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread116", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_121.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_121.c
new file mode 100644
index 0000000000000000000000000000000000000000..d81b342248ba39c2aa5bdfa84f1c85b0fd67960d
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_121.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *arg)
+{
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ /* Create a new thread. The default attribute should be that
+ * it is joinable. */
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ /* The new thread should be able to be joined. */
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ /* The new thread should be able to be detached. */
+ ret = pthread_detach(newTh);
+ ICUNIT_GOTO_EQUAL(ret, ESRCH, ret, EXIT);
+
+ return PTHREAD_NO_ERROR;
+EXIT:
+ pthread_join(newTh, NULL);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread121(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread121", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_123.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_123.c
new file mode 100644
index 0000000000000000000000000000000000000000..7d6c1e53865f47c6f5f13a6310ad1ee754e874ac
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_123.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ g_pthreadTestTh = pthread_self();
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ /* Create a new thread */
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ /* Wait for the thread function to return to make sure we got
+ * the thread ID value from pthread_self(). */
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ /* If the value of pthread_self() and the return value from
+ * pthread_create() is equal, then the test passes. */
+ ret = pthread_equal(newTh, g_pthreadTestTh);
+ ICUNIT_GOTO_NOT_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+ return PTHREAD_NO_ERROR;
+EXIT:
+ pthread_detach(newTh);
+ return PTHREAD_NO_ERROR;
+}
+
+
+VOID ItPosixPthread123(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread123", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_124.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_124.c
new file mode 100644
index 0000000000000000000000000000000000000000..f59b562ad994fdd2d64f399f586a8a15a61f8aa6
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_124.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static int g_testCnt;
+
+static VOID *PthreadF01(VOID *num)
+{
+ intptr_t i = (intptr_t)num;
+ PRINTK("Passed argument for thread: %d, g_testCnt = %d\n", (int)i, g_testCnt);
+ ICUNIT_TRACK_EQUAL(g_testCnt, i, g_testCnt);
+ g_testCnt++;
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ long i;
+ INT32 ret;
+
+ g_testCnt = 1;
+
+ for (i = 1; i < PTHREAD_THREADS_NUM + 1; i++) {
+ ret = pthread_create(&newTh, NULL, PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ /* Wait for thread to end execution */
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+ }
+
+ return PTHREAD_NO_ERROR;
+EXIT:
+ pthread_detach(newTh);
+ return PTHREAD_NO_ERROR;
+}
+
+
+VOID ItPosixPthread124(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread124", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_125.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_125.c
new file mode 100644
index 0000000000000000000000000000000000000000..a218a403cc1945acfe063fbaad4bc4caeef35ff2
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_125.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *num)
+{
+ int *i, j;
+
+ i = (int *)num;
+
+ for (j = 0; j < PTHREAD_THREADS_NUM; j++) {
+ dprintf("Passed argument %d for thread\n", i[j]);
+ ICUNIT_TRACK_EQUAL(i[j], j + 1, i[j]);
+ }
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 i[PTHREAD_THREADS_NUM], j, ret;
+
+ for (j = 0; j < PTHREAD_THREADS_NUM; j++)
+ i[j] = j + 1;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, (void *)&i);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ /* Wait for thread to end execution */
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ return PTHREAD_NO_ERROR;
+EXIT:
+ pthread_detach(newTh);
+ return PTHREAD_NO_ERROR;
+}
+
+
+VOID ItPosixPthread125(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread125", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_127.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_127.c
new file mode 100644
index 0000000000000000000000000000000000000000..13ab83aeeb97661492cee8ecfb32e16553419354
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_127.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+typedef struct {
+ sigset_t mask;
+ sigset_t pending;
+} testdata_t;
+
+/* Thread function; which will check the signal mask and pending signals */
+static VOID *PthreadF01(VOID *arg)
+{
+ INT32 ret;
+ testdata_t *td = (testdata_t *)arg;
+
+ /* Obtain the signal mask of this thread. */
+ ret = pthread_sigmask(SIG_SETMASK, NULL, &(td->mask));
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* Obtain the pending signals of this thread. It should be empty. */
+ ret = sigpending(&(td->pending));
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* Signal we're done (especially in case of a detached thread) */
+ do {
+ ret = sem_post(&g_scenarii[g_testCount].sem);
+ } while ((ret == -1) && (errno == EINTR));
+ ICUNIT_TRACK_NOT_EQUAL(ret, -1, ret);
+
+ return arg;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ pthread_t child;
+ testdata_t tdParent, tdThread;
+
+ g_testCount = 0;
+
+#if PTHREAD_SIGNAL_SUPPORT == 1
+
+ /* Initialize thread attribute objects */
+ ScenarInit();
+
+ /* Initialize the signal state */
+ ret = sigemptyset(&(tdParent.mask));
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = sigemptyset(&(tdParent.pending));
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* Add SIGCONT, SIGUSR1 and SIGUSR2 to the set of blocked signals */
+ ret = sigaddset(&(tdParent.mask), SIGUSR1);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = sigaddset(&(tdParent.mask), SIGUSR2);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* Block those signals. */
+ ret = pthread_sigmask(SIG_SETMASK, &(tdParent.mask), NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* Raise those signals so they are now pending. */
+ ret = raise(SIGUSR1);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = raise(SIGUSR2);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* Do the testing for each thread */
+ for (g_testCount = 0; g_testCount < NSCENAR; g_testCount++) {
+ /* (re)initialize thread signal sets */
+ ret = sigemptyset(&(tdThread.mask));
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = sigemptyset(&(tdThread.pending));
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_create(&child, &g_scenarii[g_testCount].ta, PthreadF01, &tdThread);
+ switch (g_scenarii[g_testCount].result) {
+ case 0: /* Operation was expected to succeed */
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ break;
+
+ case 1: /* Operation was expected to fail */
+ ICUNIT_ASSERT_NOT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ break;
+
+ case 2: /* 2, We did not know the expected result */
+ default:
+ break;
+ }
+ if (ret == 0) { /* The new thread is running */
+ if (g_scenarii[g_testCount].detached == 0) {
+ ret = pthread_join(child, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ } else {
+ /* Just wait for the thread to terminate */
+ do {
+ ret = sem_wait(&g_scenarii[g_testCount].sem);
+ } while ((ret == -1) && (errno == EINTR));
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ }
+
+ /* The thread has terminated its work, so we can now control */
+ ret = sigismember(&(tdThread.mask), SIGUSR1);
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+
+ ret = sigismember(&(tdThread.mask), SIGUSR2);
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+
+ ret = sigismember(&(tdThread.pending), SIGUSR1);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = sigismember(&(tdThread.pending), SIGUSR2);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ }
+ }
+
+ ScenarFini();
+
+#endif
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread127(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread127", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_128.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_128.c
new file mode 100644
index 0000000000000000000000000000000000000000..c73a24a46107b896e66ceec17ea2ce5589f472f9
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_128.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ clockid_t cpuclock;
+ INT32 ret;
+ struct timespec ts = {
+ .tv_sec = 1,
+ .tv_nsec = 1
+ };
+
+ cpuclock = CLOCK_MONOTONIC;
+
+ ret = clock_gettime(cpuclock, &ts);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ ret = sysconf(_SC_THREAD_CPUTIME);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_IS_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, errno);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, errno);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread128(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread128", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_129.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_129.c
new file mode 100644
index 0000000000000000000000000000000000000000..e9a0befde1a79665e9cf3665bcb9715edbfffb07
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_129.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, errno, EXIT);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, errno, EXIT);
+
+ return PTHREAD_NO_ERROR;
+
+EXIT:
+ pthread_join(newTh, NULL);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread129(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread129", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_132.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_132.c
new file mode 100644
index 0000000000000000000000000000000000000000..14a76158688ff9ba21515bd8d2548146b612cbd2
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_132.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ g_newTh = pthread_self();
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh1;
+ INT32 ret;
+
+ ret = pthread_create(&newTh1, NULL, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ ret = pthread_join(newTh1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ ret = pthread_equal(newTh1, g_newTh);
+ ICUNIT_GOTO_EQUAL(ret, 1, errno, EXIT);
+
+ ret = pthread_equal(newTh1, TestPthreadSelf());
+ ICUNIT_GOTO_EQUAL(ret, PTHREAD_NO_ERROR, ret, EXIT);
+
+ return PTHREAD_NO_ERROR;
+EXIT:
+ pthread_detach(g_newTh);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread132(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread132", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_133.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_133.c
new file mode 100644
index 0000000000000000000000000000000000000000..5f7aa3ff07dfb1fe69ddf8d14272db69c4aa641e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_133.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_equal(newTh, newTh);
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+
+VOID ItPosixPthread133(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread133", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_134.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_134.c
new file mode 100644
index 0000000000000000000000000000000000000000..676892e9747ca73683ba0b677c4b6bdec78c1dd1
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_134.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh1, newTh2;
+ INT32 ret;
+
+ ret = pthread_create(&newTh1, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_create(&newTh2, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_equal(newTh1, newTh2);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh1, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newTh2, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread134(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread134", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_136.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_136.c
new file mode 100644
index 0000000000000000000000000000000000000000..1299ba7d3611de7f992297a61c775e248e9c77fb
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_136.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define LOOP_NUM 4
+
+static VOID *PthreadF01(VOID *argument)
+{
+ INT32 i;
+
+ dprintf("Wait for 3 seconds for thread to finish execution:\n");
+ for (i = 1; i < LOOP_NUM; i++) {
+ dprintf("Waited (%d) second\n", i);
+ sleep(1);
+ }
+
+ g_testCount = 1;
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread136(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread136", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_138.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_138.c
new file mode 100644
index 0000000000000000000000000000000000000000..7c0009ea2a026e0c53f56659aea309faefa268a3
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_138.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ g_pthreadSem = PTHREAD_INMAIN_TEST;
+ pthread_exit(PTHREAD_EXIT_VALUE);
+ return NULL;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ VOID *valuePtr;
+ INT32 ret;
+
+ valuePtr = 0;
+ g_pthreadSem = PTHREAD_INTHREAD_TEST;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* Make sure the thread was created before we join it. */
+ while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
+ sleep(1);
+
+ ret = pthread_join(newTh, &valuePtr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /*
+ * Check to make sure that 'value_ptr' that was passed to
+ * pthread_join() and the pthread_exit() return code that
+ * was used in the thread funciton are the same.
+ */
+ ICUNIT_ASSERT_EQUAL(valuePtr, PTHREAD_EXIT_VALUE, errno);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread138(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread138", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_141.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_141.c
new file mode 100644
index 0000000000000000000000000000000000000000..698b748210602ed798fd74d73b6a542b20e4af5e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_141.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread141(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread141", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_142.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_142.c
new file mode 100644
index 0000000000000000000000000000000000000000..c0dc054004c1251efa6b045e307cfdd69f3c26d8
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_142.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread142(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread142", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_144.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_144.c
new file mode 100644
index 0000000000000000000000000000000000000000..b6bcf63a36d3aa06a6c49be13306d25b0f7d4b2f
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_144.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ INT32 ret;
+
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ LOS_TaskDelay(3); // 3, delay for Timing control.
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_attr_t newAttr;
+ pthread_t newTh;
+ _pthread_data *pthreadData = NULL;
+ INT32 ret;
+
+ ret = pthread_attr_init(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_setdetachstate(&newAttr, PTHREAD_CREATE_JOINABLE);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_create(&newTh, &newAttr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_detach(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ pthreadData = pthread_get_data(newTh);
+ ICUNIT_ASSERT_EQUAL(pthreadData->state, PTHREAD_STATE_DETACHED, pthreadData->state);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = LOS_TaskDelay(2); // 2, delay for Timing control.
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread144(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread144", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_150.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_150.c
new file mode 100644
index 0000000000000000000000000000000000000000..37f1a74a2d1e6ad46529e4045bd5b03f9c0130a7
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_150.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ _pthread_data *pthreadData;
+ INT32 ret;
+
+ pthreadData = pthread_get_data(newTh);
+ ICUNIT_ASSERT_EQUAL(pthreadData, NULL, pthreadData);
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ pthreadData = pthread_get_data(newTh);
+ ICUNIT_ASSERT_EQUAL(pthreadData->state, PTHREAD_STATE_RUNNING, pthreadData->state);
+
+ /* Wait 'till the thread returns.
+ * The thread could have ended by the time we try to join, so
+ * don't worry about it, just so long as other errors don't
+ * occur. The point is to make sure the thread has ended execution. */
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ pthreadData = pthread_get_data(newTh);
+ ICUNIT_ASSERT_EQUAL(pthreadData, NULL, pthreadData);
+
+ /* Detach the non-existant thread. */
+ ret = pthread_detach(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ pthreadData = pthread_get_data(newTh);
+ ICUNIT_ASSERT_EQUAL(pthreadData, NULL, pthreadData);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ /* Cleanup and cancel the thread */
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread150(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread150", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_152.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_152.c
new file mode 100644
index 0000000000000000000000000000000000000000..f61f3054041628511ba5b4b8e10fbed2ae7efd8d
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_152.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_attr_t newAttr;
+ INT32 detachState, ret;
+
+ /* Initialize attribute */
+ ret = pthread_attr_init(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* The test passes if the attribute object has a detachstate of
+ * PTHREAD_CREATE_JOINABLE, which is the default value for this
+ * attribute. */
+ ret = pthread_attr_getdetachstate(&newAttr, &detachState);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(detachState, PTHREAD_CREATE_JOINABLE, detachState);
+
+ ret = pthread_attr_destroy(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return LOS_OK;
+}
+
+VOID ItPosixPthread152(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread152", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_154.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_154.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d113accdd2185c07ffd9c4444c3f2c32ba457d9
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_154.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ pthread_exit(NULL);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newThreads[PTHREAD_THREADS_NUM];
+ pthread_attr_t newAttr;
+ INT32 i, ret;
+
+ ret = pthread_attr_init(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ for (i = 0; i < PTHREAD_THREADS_NUM; i++) {
+ ret = pthread_create(&newThreads[i], &newAttr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ }
+
+ for (i = 0; i < PTHREAD_THREADS_NUM; i++) {
+ ret = pthread_join(newThreads[i], NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ }
+
+ for (i = 0; i < PTHREAD_THREADS_NUM; i++) {
+ }
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread154(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread154", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_166.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_166.c
new file mode 100644
index 0000000000000000000000000000000000000000..56d11b03beb290fd0570513bbe32893f04db9d15
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_166.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ pthread_exit(0);
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ pthread_attr_t newAttr;
+ _pthread_data *pthreadData = NULL;
+ INT32 ret;
+
+ /* Initialize attribute */
+ ret = pthread_attr_init(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* Destroy attribute */
+ ret = pthread_attr_destroy(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* Creating a thread, passing to it the destroyed attribute, should
+ * result in an error value of EINVAL (invalid 'attr' value). */
+ ret = pthread_create(&newTh, &newAttr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ sleep(1);
+
+ /* The new_th is delelted in Here */
+ pthreadData = pthread_get_data(newTh);
+ ICUNIT_ASSERT_EQUAL(pthreadData, NULL, pthreadData);
+
+ /* Cleanup and cancel the thread */
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread166(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread166", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_167.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_167.c
new file mode 100644
index 0000000000000000000000000000000000000000..58706dab95e5eb46f94358d5e41309a501619e7d
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_167.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_attr_t newAttr;
+ INT32 ret;
+
+ ret = pthread_attr_init(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_destroy(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_init(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_destroy(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread167(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread167", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_173.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_173.c
new file mode 100644
index 0000000000000000000000000000000000000000..413004bdb2ba758c565e7ffe35b94db411efd9a5
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_173.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_attr_t newAttr;
+ INT32 detachState, ret;
+
+ /* Initialize attribute */
+ ret = pthread_attr_init(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* The test passes if pthread_attr_getdetachstate gets the attribute
+ * of PTHREAD_CREATE_JOINABLE from the attribute object. */
+ ret = pthread_attr_getdetachstate(&newAttr, &detachState);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(detachState, PTHREAD_CREATE_JOINABLE, detachState);
+
+ ret = pthread_attr_destroy(&newAttr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread173(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread173", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_175.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_175.c
new file mode 100644
index 0000000000000000000000000000000000000000..0e719cf9f43e2e0ba36169912f2fabe813a45d62
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_175.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ pthread_exit(PTHREAD_EXIT_VALUE);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ pthread_attr_t attr;
+ INT32 cscope;
+ INT32 ret;
+
+ g_pthreadScopeValue = PTHREAD_SCOPE_PROCESS;
+
+ /* Initialize attr */
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, errno);
+
+ ret = pthread_attr_setscope(&attr, g_pthreadScopeValue);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, errno);
+
+ ret = pthread_create(&newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, errno);
+
+ ret = pthread_attr_getscope(&attr, &cscope);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, errno);
+ ICUNIT_ASSERT_EQUAL(cscope, g_pthreadScopeValue, cscope);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, errno);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, errno);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread175(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread175", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_176.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_176.c
new file mode 100644
index 0000000000000000000000000000000000000000..1ab0316d3807fab76382e33f039f4eb668e35b6e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_176.c
@@ -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.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ pthread_attr_t attr;
+
+ g_pthreadScopeValue = 999; // 999, init
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_setscope(&attr, g_pthreadScopeValue);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, errno);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread176(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread176", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_177.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_177.c
new file mode 100644
index 0000000000000000000000000000000000000000..b004ff7351b9e831c8776ac5ad928fc6f1a0a17b
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_177.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 rc2;
+ pthread_attr_t attr;
+ INT32 scope;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_getscope(&attr, &scope);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(scope, PTHREAD_SCOPE_PROCESS, scope);
+
+ g_pthreadScopeValue = PTHREAD_SCOPE_PROCESS;
+ ret = pthread_attr_setscope(&attr, g_pthreadScopeValue);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_getscope(&attr, &scope);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(scope, PTHREAD_SCOPE_PROCESS, scope);
+
+ g_pthreadScopeValue = PTHREAD_SCOPE_SYSTEM;
+ ret = pthread_attr_setscope(&attr, g_pthreadScopeValue);
+ ICUNIT_ASSERT_EQUAL(ret, ENOTSUP, ret);
+
+ ret = pthread_attr_getscope(&attr, &scope);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(scope, PTHREAD_SCOPE_PROCESS, scope);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread177(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread177", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_182.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_182.c
new file mode 100644
index 0000000000000000000000000000000000000000..ccf6a8d275575cb37f565b3d5d6e70867c408422
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_182.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *tmp)
+{
+ struct sched_param param;
+ INT32 policy;
+ INT32 ret;
+
+ TestExtraTaskDelay(2); // 2, delay for Timing control.
+ LOS_TaskDelay(1);
+
+ ret = pthread_getschedparam(pthread_self(), &policy, ¶m);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ if (policy == g_pthreadSchedPolicy) {
+ g_testCount = 1;
+ }
+ if (param.sched_priority == PTHREAD_PRIORITY_TEST) {
+ g_testCount--;
+ }
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_attr_t attr;
+ pthread_t threadId;
+ struct sched_param param;
+ INT32 ret;
+
+ g_pthreadSchedPolicy = SCHED_RR;
+ g_pthreadSchedInherit = PTHREAD_INHERIT_SCHED;
+ g_testCount = 0;
+
+ param.sched_priority = PTHREAD_PRIORITY_TEST;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_create(&threadId, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_setschedparam(threadId, g_pthreadSchedPolicy, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(threadId, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread182(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread182", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_185.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_185.c
new file mode 100644
index 0000000000000000000000000000000000000000..f7bc7966c8d741d99471132c059989330b0577f6
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_185.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 inheritsched;
+ pthread_attr_t attr;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedInherit = PTHREAD_INHERIT_SCHED;
+ ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_getinheritsched(&attr, &inheritsched);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(inheritsched, g_pthreadSchedInherit, inheritsched);
+
+ g_pthreadSchedInherit = PTHREAD_EXPLICIT_SCHED;
+ ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_getinheritsched(&attr, &inheritsched);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(inheritsched, g_pthreadSchedInherit, inheritsched);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread185(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread185", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_186.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_186.c
new file mode 100644
index 0000000000000000000000000000000000000000..3d0bcad5f1de2398b26f22a0388db086b34742eb
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_186.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *data)
+{
+ pthread_t self;
+ struct sched_param schedparam;
+ struct params *paramTest = data;
+ INT32 policy;
+ INT32 ret;
+
+ self = pthread_self();
+ ret = pthread_getschedparam(self, &policy, &schedparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_TRACK_EQUAL(policy, paramTest->policy, policy);
+ ICUNIT_TRACK_EQUAL(paramTest->priority, PRIORITY_OTHER, paramTest->priority);
+ dprintf("sched_priority=:%d\n", schedparam.sched_priority);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ struct params paramTest;
+ pthread_t thread;
+ pthread_attr_t attr;
+ VOID *status = NULL;
+ _pthread_data *pthreadData = NULL;
+ struct sched_param schedparam;
+
+ paramTest.policy = SCHED_OTHER;
+ paramTest.priority = PRIORITY_OTHER;
+ paramTest.policy_label = "SCHED_OTHER";
+ paramTest.status = PTHREAD_NO_ERROR;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedPolicy = SCHED_OTHER;
+ ret = pthread_attr_setschedpolicy(&attr, g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ g_pthreadSchedInherit = PTHREAD_EXPLICIT_SCHED;
+ ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ schedparam.sched_priority = paramTest.priority;
+ ret = pthread_attr_setschedparam(&attr, &schedparam);
+ ICUNIT_ASSERT_EQUAL(ret, ENOTSUP, ret);
+
+ attr.schedparam.sched_priority = paramTest.priority;
+ ret = pthread_create(&thread, &attr, PthreadF01, ¶mTest);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ pthreadData = pthread_get_data(thread);
+ ICUNIT_ASSERT_EQUAL(pthreadData, NULL, pthreadData);
+
+ ret = pthread_join(thread, &status);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread186(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread186", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_187.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_187.c
new file mode 100644
index 0000000000000000000000000000000000000000..e5449e5987dd2f6604658f37dd187a52adc01138
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_187.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *data)
+{
+ pthread_t self;
+ struct sched_param schedparam;
+ struct params *paramTest = data;
+ INT32 policy;
+ INT32 ret;
+
+ self = pthread_self();
+ ret = pthread_getschedparam(self, &policy, &schedparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ICUNIT_TRACK_EQUAL(paramTest->priority, PRIORITY_FIFO, paramTest->priority);
+ ICUNIT_TRACK_EQUAL(schedparam.sched_priority, paramTest->priority, schedparam.sched_priority);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ struct params paramTest;
+ pthread_t thread;
+ pthread_attr_t attr;
+ VOID *status = NULL;
+ _pthread_data *pthreadData = NULL;
+ struct sched_param schedparam;
+
+ paramTest.policy = SCHED_FIFO;
+ paramTest.priority = PRIORITY_FIFO;
+ paramTest.policy_label = "SCHED_FIFO";
+ paramTest.status = LOS_NOK;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedPolicy = SCHED_FIFO;
+ ret = pthread_attr_setschedpolicy(&attr, g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ g_pthreadSchedInherit = PTHREAD_EXPLICIT_SCHED;
+ ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ schedparam.sched_priority = paramTest.priority;
+ ret = pthread_attr_setschedparam(&attr, &schedparam);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_create(&thread, &attr, PthreadF01, ¶mTest);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ pthreadData = pthread_get_data(thread);
+ ICUNIT_ASSERT_EQUAL(pthreadData->state, PTHREAD_STATE_RUNNING, pthreadData->state);
+ ICUNIT_ASSERT_EQUAL(pthreadData->attr.schedparam.sched_priority, paramTest.priority,
+ pthreadData->attr.schedparam.sched_priority);
+
+ ret = pthread_join(thread, &status);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread187(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread187", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_188.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_188.c
new file mode 100644
index 0000000000000000000000000000000000000000..8b99b25776c4a1c37be2c48c9f157741afcb40d0
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_188.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *data)
+{
+ pthread_t self;
+ struct sched_param schedparam;
+ struct params *paramTest = data;
+ INT32 policy;
+ INT32 ret;
+
+ self = pthread_self();
+ ret = pthread_getschedparam(self, &policy, &schedparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_TRACK_EQUAL(policy, paramTest->policy, policy);
+ ICUNIT_TRACK_EQUAL(paramTest->priority, PRIORITY_RR, paramTest->priority);
+ ICUNIT_TRACK_EQUAL(schedparam.sched_priority, paramTest->priority, schedparam.sched_priority);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ struct params paramTest;
+ pthread_t thread;
+ pthread_attr_t attr;
+ VOID *status = NULL;
+ _pthread_data *pthreadData = NULL;
+ struct sched_param schedparam;
+
+ paramTest.policy = SCHED_RR;
+ paramTest.priority = PRIORITY_RR;
+ paramTest.policy_label = "SCHED_RR";
+ paramTest.status = PTHREAD_NO_ERROR;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedPolicy = SCHED_OTHER;
+ ret = pthread_attr_setschedpolicy(&attr, g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ g_pthreadSchedPolicy = SCHED_RR;
+ ret = pthread_attr_setschedpolicy(&attr, g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedInherit = PTHREAD_EXPLICIT_SCHED;
+ ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ schedparam.sched_priority = paramTest.priority;
+ if (paramTest.priority != PRIORITY_OTHER) {
+ ret = pthread_attr_setschedparam(&attr, &schedparam);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ }
+
+ ret = pthread_create(&thread, &attr, PthreadF01, ¶mTest);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ pthreadData = pthread_get_data(thread);
+ ICUNIT_ASSERT_EQUAL(pthreadData->state, PTHREAD_STATE_RUNNING, pthreadData->state);
+
+ ret = pthread_join(thread, &status);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread188(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread188", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_193.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_193.c
new file mode 100644
index 0000000000000000000000000000000000000000..a37307e69d73c1f6a13185b542d7ec96dc0d57f1
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_193.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ TestExtraTaskDelay(1);
+ LOS_TaskDelay(1);
+
+ g_testCount = 1;
+
+ pthread_exit(PTHREAD_NO_ERROR);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t thread;
+ pthread_attr_t attr;
+ INT32 ret;
+ struct sched_param param;
+ INT32 priority;
+ _pthread_data *pthreadData = NULL;
+
+ g_testCount = 0;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedPolicy = SCHED_FIFO;
+ ret = pthread_attr_setschedpolicy(&attr, g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ priority = sched_get_priority_max(g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_EQUAL(priority, -1, priority);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ param.sched_priority = priority;
+ ret = pthread_attr_setschedparam(&attr, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, ENOTSUP, ret);
+
+ ret = pthread_create(&thread, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ pthreadData = pthread_get_data(thread);
+ ICUNIT_ASSERT_EQUAL(pthreadData->state, PTHREAD_STATE_RUNNING, pthreadData->state);
+ ICUNIT_ASSERT_EQUAL(pthreadData->attr.schedparam.sched_priority, TASK_PRIO_TEST,
+ pthreadData->attr.schedparam.sched_priority);
+
+ ret = pthread_join(thread, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread193(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread193", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_194.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_194.c
new file mode 100644
index 0000000000000000000000000000000000000000..fce9ab86c5f28b44161fd997f6a4ab5dc6bebcd8
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_194.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ g_testCount = 1;
+
+ pthread_exit(PTHREAD_NO_ERROR);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t thread;
+ pthread_attr_t attr;
+ INT32 ret;
+ struct sched_param param;
+ INT32 priority;
+ _pthread_data *pthreadData = NULL;
+
+ g_testCount = 0;
+
+ /* use delay to reset timelsice to prevent created task get
+ to run before expected */
+ LOS_TaskDelay(1);
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedPolicy = SCHED_RR;
+ ret = pthread_attr_setschedpolicy(&attr, g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ priority = sched_get_priority_max(g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_NOT_EQUAL(priority, -1, priority);
+
+ param.sched_priority = priority;
+ ret = pthread_attr_setschedparam(&attr, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_create(&thread, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ pthreadData = pthread_get_data(thread);
+ ICUNIT_ASSERT_EQUAL(pthreadData->state, PTHREAD_STATE_RUNNING, pthreadData->state);
+ ICUNIT_ASSERT_EQUAL(pthreadData->attr.schedparam.sched_priority, TASK_PRIO_TEST,
+ pthreadData->attr.schedparam.sched_priority);
+
+ ret = pthread_join(thread, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread194(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread194", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_197.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_197.c
new file mode 100644
index 0000000000000000000000000000000000000000..1fcc4b1d77f32243a9274e4e41e19369e236f92c
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_197.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_attr_t attr;
+ INT32 ret;
+ struct sched_param param;
+ INT32 priority;
+ INT32 offset = 0xff;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedPolicy = SCHED_FIFO;
+ ret = pthread_attr_setschedpolicy(&attr, g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ priority = sched_get_priority_max(g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_EQUAL(priority, PTHREAD_IS_ERROR, priority);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ param.sched_priority = priority + offset;
+ ret = pthread_attr_setschedparam(&attr, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, ENOTSUP, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread197(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread197", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_198.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_198.c
new file mode 100644
index 0000000000000000000000000000000000000000..cf48513ac63e77c84471306f9ae6e83c113da792
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_198.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_attr_t attr;
+ INT32 ret;
+ struct sched_param param;
+ INT32 priority;
+ INT32 offset = 0xff;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedPolicy = SCHED_RR;
+ ret = pthread_attr_setschedpolicy(&attr, g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ priority = sched_get_priority_min(g_pthreadSchedPolicy);
+ ICUNIT_ASSERT_EQUAL(priority, PTHREAD_NO_ERROR, priority);
+
+ param.sched_priority = priority + offset;
+ ret = pthread_attr_setschedparam(&attr, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, ENOTSUP, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread198(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread198", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_200.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_200.c
new file mode 100644
index 0000000000000000000000000000000000000000..3c8c94391215f1b1db369073963a6926d3c80b81
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_200.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *arg)
+{
+ pthread_exit(PTHREAD_NO_ERROR);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ pthread_attr_t attr;
+ size_t stackSize = PTHREAD_STACK_MIN;
+ size_t ssize;
+ INT32 ret;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_getstacksize(&attr, &ssize);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(ssize, PTHREAD_DEFAULT_STACK_SIZE, ssize);
+
+ ret = pthread_attr_setstacksize(&attr, stackSize);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_getstacksize(&attr, &ssize);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(ssize, stackSize, ssize);
+
+ ret = pthread_create(&newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread200(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread200", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_204.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_204.c
new file mode 100644
index 0000000000000000000000000000000000000000..a011386e095a4fe17177958ecc0cdd77c82d4423
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_204.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ struct sched_param sparam;
+ INT32 priority, policy;
+ INT32 ret;
+
+ g_pthreadSchedPolicy = SCHED_RR;
+
+#ifdef LOSCFG_KERNEL_TICKLESS
+ priority = sched_get_priority_max(g_pthreadSchedPolicy) - 1;
+#else
+ priority = sched_get_priority_max(g_pthreadSchedPolicy);
+#endif
+
+ sparam.sched_priority = priority;
+
+ ret = pthread_setschedparam(pthread_self(), g_pthreadSchedPolicy, &sparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_getschedparam(pthread_self(), &policy, &sparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_TRACK_EQUAL(policy, g_pthreadSchedPolicy, policy);
+ ICUNIT_TRACK_EQUAL(sparam.sched_priority, priority, sparam.sched_priority);
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread204(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread204", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_205.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_205.c
new file mode 100644
index 0000000000000000000000000000000000000000..b1b4c4318c090612fc36ee9c222acac5d409a891
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_205.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *arg)
+{
+ INT32 ret;
+ INT32 policy;
+ INT32 priority;
+ struct sched_param schedparam;
+
+ LOS_TaskDelay(2); // 2, delay for Timing control.
+
+#ifdef LOSCFG_KERNEL_TICKLESS
+ priority = sched_get_priority_max(SCHED_RR) - 1;
+#else
+ priority = sched_get_priority_max(SCHED_RR);
+#endif
+
+ ret = pthread_getschedparam(pthread_self(), &policy, &schedparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_TRACK_EQUAL(policy, SCHED_RR, policy);
+ ICUNIT_TRACK_EQUAL(schedparam.sched_priority, priority, schedparam.sched_priority);
+
+ return NULL;
+}
+
+static VOID *PthreadF02(VOID *arg)
+{
+ INT32 ret;
+ struct sched_param schedparam;
+#ifdef LOSCFG_KERNEL_TICKLESS
+ schedparam.sched_priority = sched_get_priority_max(SCHED_RR) - 1;
+ ICUNIT_TRACK_EQUAL(schedparam.sched_priority, OS_TASK_PRIORITY_LOWEST - 1, schedparam.sched_priority);
+#else
+ schedparam.sched_priority = sched_get_priority_max(SCHED_RR);
+ ICUNIT_TRACK_EQUAL(schedparam.sched_priority, OS_TASK_PRIORITY_LOWEST, schedparam.sched_priority);
+#endif
+
+ ret = pthread_setschedparam(*(pthread_t *)arg, SCHED_RR, &schedparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr;
+ INT32 bar;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedInherit = PTHREAD_EXPLICIT_SCHED;
+ ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ LOS_TaskLock();
+
+ ret = pthread_create(&newTh1, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_create(&newTh2, &attr, PthreadF02, &newTh1);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ LOS_TaskUnlock();
+
+ ret = pthread_join(newTh2, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh1, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread205(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread205", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_206.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_206.c
new file mode 100644
index 0000000000000000000000000000000000000000..2e6b2fe571cbcbe0a16d6810901d32c2a1487fc8
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_206.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *PthreadF01(void *arg)
+{
+ INT32 ret;
+ INT32 policy;
+ struct sched_param schedparam;
+ struct sched_param schedparam1;
+
+ g_pthreadSchedPolicy = SCHED_RR;
+
+ schedparam.sched_priority = sched_get_priority_min(g_pthreadSchedPolicy);
+
+ ret = pthread_setschedparam(pthread_self(), g_pthreadSchedPolicy, &schedparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ policy = SCHED_RR;
+ ret = pthread_getschedparam(pthread_self(), &policy, &schedparam1);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_TRACK_EQUAL(policy, g_pthreadSchedPolicy, policy);
+ ICUNIT_TRACK_EQUAL(schedparam1.sched_priority, schedparam.sched_priority, schedparam1.sched_priority);
+
+ /* Now set the priority to an invalid value. */
+ schedparam.sched_priority++;
+
+ ret = pthread_setschedparam(pthread_self(), SCHED_RR, &schedparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ policy = SCHED_RR;
+ ret = pthread_getschedparam(pthread_self(), &policy, &schedparam1);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_TRACK_EQUAL(policy, g_pthreadSchedPolicy, policy);
+ ICUNIT_TRACK_EQUAL(schedparam1.sched_priority, schedparam.sched_priority, schedparam1.sched_priority);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ pthread_attr_t attr;
+ pthread_t newTh1;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedInherit = PTHREAD_EXPLICIT_SCHED;
+ ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_create(&newTh1, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh1, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread206(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread206", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_208.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_208.c
new file mode 100644
index 0000000000000000000000000000000000000000..1f3ade88d772d01a7734718a6804ef1b5c69710e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_208.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ struct sched_param sparam;
+ INT32 policy;
+ INT32 ret;
+
+ ret = pthread_getschedparam(pthread_self(), &policy, &sparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_TRACK_EQUAL(policy, g_pthreadSchedPolicy, policy);
+ ICUNIT_TRACK_EQUAL(sparam.sched_priority, TASK_PRIO_TEST, sparam.sched_priority);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ g_pthreadSchedPolicy = SCHED_RR;
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread208(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread208", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_209.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_209.c
new file mode 100644
index 0000000000000000000000000000000000000000..45ed7642cd71689b4e2c3ecb397a940ec7083964
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_209.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ struct sched_param sparam;
+ INT32 policy, priority;
+ INT32 ret;
+
+ g_pthreadSchedPolicy = SCHED_RR;
+
+#ifdef LOSCFG_KERNEL_TICKLESS
+ priority = sched_get_priority_max(g_pthreadSchedPolicy) - 1;
+#else
+ priority = sched_get_priority_max(g_pthreadSchedPolicy);
+#endif
+
+ sparam.sched_priority = priority;
+
+ ret = pthread_setschedparam(pthread_self(), g_pthreadSchedPolicy, &sparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_getschedparam(pthread_self(), &policy, &sparam);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_TRACK_EQUAL(policy, g_pthreadSchedPolicy, policy);
+
+#ifdef LOSCFG_KERNEL_TICKLESS
+ ICUNIT_TRACK_EQUAL(sparam.sched_priority, OS_TASK_PRIORITY_LOWEST - 1, sparam.sched_priority);
+#else
+ ICUNIT_TRACK_EQUAL(sparam.sched_priority, OS_TASK_PRIORITY_LOWEST, sparam.sched_priority);
+#endif
+
+ return NULL;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ pthread_attr_t attr;
+ INT32 ret;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSchedInherit = PTHREAD_EXPLICIT_SCHED;
+ ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_create(&newTh, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread209(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread209", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_211.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_211.c
new file mode 100644
index 0000000000000000000000000000000000000000..c15264edaafa2bd4d35eb5be1bde25f8040739ab
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_211.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+/* The init function that pthread_once calls */
+static VOID PthreadF01(VOID)
+{
+ g_testCount++;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+
+ pthread_once_t onceControl = PTHREAD_ONCE_INIT;
+
+ g_testCount = 0;
+
+ ret = pthread_once(&onceControl, PthreadF01);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(onceControl, 1, onceControl);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_once(&onceControl, PthreadF01);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(onceControl, 1, onceControl);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread211(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread211", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_213.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_213.c
new file mode 100644
index 0000000000000000000000000000000000000000..cf1a104f8140ea9423a2922cbf569323b79a4b4f
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_213.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID PthreadF02(VOID)
+{
+ INT32 ret;
+ ret = pthread_mutex_lock(&g_pthreadMutexTest1);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_testCount++;
+
+ ret = pthread_mutex_unlock(&g_pthreadMutexTest1);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return;
+}
+
+static VOID *PthreadF01(VOID *arg)
+{
+ INT32 ret;
+
+ ret = pthread_once(arg, PthreadF02);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return NULL;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, i;
+
+ pthread_once_t myctl[PTHREAD_THREADS_NUM] = {PTHREAD_ONCE_INIT, };
+
+ pthread_t th[PTHREAD_THREADS_NUM];
+
+ g_pthreadMutexTest1 = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;
+
+ g_testCount = 0;
+
+ for (i = 0; i < PTHREAD_THREADS_NUM; i++) {
+ ret = pthread_create(&th[i], NULL, PthreadF01, &myctl[i]);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ }
+
+ for (i = 0; i < PTHREAD_THREADS_NUM; i++) {
+ ret = pthread_join(th[i], NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ }
+
+ ret = pthread_mutex_lock(&g_pthreadMutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3, here assert the result.
+
+ ret = pthread_mutex_unlock(&g_pthreadMutexTest1);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread213(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread213", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_214.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_214.c
new file mode 100644
index 0000000000000000000000000000000000000000..7ffdae7cfcd02c4d2a3eda70df9bb058e5f97edd
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_214.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID PthreadF01(VOID)
+{
+ sleep(1);
+
+ g_testCount = 1;
+
+ return;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+
+ pthread_once_t onceControl = PTHREAD_ONCE_INIT;
+
+ g_testCount = 0;
+
+ ret = pthread_once(&onceControl, PthreadF01);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(onceControl, 1, onceControl);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread214(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread214", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_215.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_215.c
new file mode 100644
index 0000000000000000000000000000000000000000..aa768427f929514cbb7dfcfd4f74a161d435c362
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_215.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID PthreadF02(VOID)
+{
+ g_testCount = 1;
+
+ sleep(10); // 10, delay for Timing control.
+
+ g_testCount = -1;
+}
+
+static VOID *PthreadF01(VOID *arg)
+{
+ INT32 ret;
+
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_once(&g_onceControl, (VOID *)PthreadF02);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return NULL;
+}
+
+static VOID *PthreadF03(VOID)
+{
+ g_testCount = 1;
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ g_testCount = 0;
+ INT32 ret;
+
+ g_onceControl = PTHREAD_ONCE_INIT;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ while (g_testCount == 0)
+ sleep(1);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ g_testCount = 0;
+
+ ret = pthread_once(&g_onceControl, (VOID *)PthreadF03);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(g_onceControl, 1, g_onceControl);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread215(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread215", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_217.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_217.c
new file mode 100644
index 0000000000000000000000000000000000000000..2035e5064d19bffa6d7e998b89e79f6347aeb687
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_217.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ INT32 i, ret;
+ const INT32 keyValue = 0;
+ VOID *specific = NULL;
+
+ for (i = 0; i < PTHREAD_KEY_NUM; i++) {
+ ret = pthread_key_create(&g_pthreadKeyTest[i], NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ret = pthread_setspecific(g_pthreadKeyTest[i], (VOID *)(long)(i + keyValue));
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ }
+
+ for (i = 0; i < PTHREAD_KEY_NUM; ++i) {
+ specific = pthread_getspecific(g_pthreadKeyTest[i]);
+ ICUNIT_ASSERT_EQUAL(specific, NULL, specific);
+ }
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread217(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread217", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_218.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_218.c
new file mode 100644
index 0000000000000000000000000000000000000000..1bc637b9989ad452d1797a88c0cb0ab051c7e4ef
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_218.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ INT32 ret;
+ const INT32 keyValue = 1000;
+
+ ret = pthread_setspecific(g_pthreadKeyTest[g_testCount], (const void *)(keyValue));
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ VOID *valuePtr = NULL;
+ INT32 ret;
+
+ g_testCount = 0;
+
+ for (g_testCount = 0; g_testCount < PTHREAD_KEY_NUM; g_testCount++) {
+ ret = pthread_key_create(&g_pthreadKeyTest[g_testCount], NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ }
+
+ for (g_testCount = 0; g_testCount < PTHREAD_KEY_NUM; g_testCount++) {
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, &valuePtr);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(valuePtr, 0, valuePtr);
+ }
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread218(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread218", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_219.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_219.c
new file mode 100644
index 0000000000000000000000000000000000000000..963720e48585bb2f9d7cb69e2d52209407d13f09
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_219.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ pthread_key_t g_key;
+ VOID *specific;
+ INT32 ret;
+
+ specific = pthread_getspecific(g_key);
+ ICUNIT_ASSERT_EQUAL(specific, NULL, specific);
+
+ ret = pthread_key_create(&g_key, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ specific = pthread_getspecific(g_key);
+ ICUNIT_ASSERT_EQUAL(specific, NULL, specific);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread219(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread219", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_221.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_221.c
new file mode 100644
index 0000000000000000000000000000000000000000..daf1bebbb9e118ee15d588b4b42ce16064a85604
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_221.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ INT32 i, ret;
+ pthread_key_t keysMax[PTHREAD_KEYS_MAX];
+
+ for (i = 0; i <= PTHREAD_KEYS_MAX; i++) {
+ ret = pthread_key_create(&keysMax[i], NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ }
+
+ for (i = 0; i <= PTHREAD_KEYS_MAX; i++) {
+ }
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread221(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread221", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_224.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_224.c
new file mode 100644
index 0000000000000000000000000000000000000000..f0f6dcd3334bfcb9ca247d177633f00579457036
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_224.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID PthreadF02(VOID *p)
+{
+ INT32 ret;
+
+ g_testCount++;
+}
+
+static VOID *PthreadF01(VOID *argument)
+{
+ INT32 ret;
+ const INT32 keyValue = 1000;
+
+ ret = pthread_setspecific(g_key, (void *)(keyValue));
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ g_testCount = 0;
+
+ ret = pthread_key_create(&g_key, PthreadF02);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread224(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread224", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_226.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_226.c
new file mode 100644
index 0000000000000000000000000000000000000000..6558d3aa0835141c4dc688d76f85d4400d236c2a
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_226.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static const INT32 g_keyValue1 = 100;
+static const INT32 g_keyValue2 = 200;
+
+static VOID *g_specific1;
+static VOID *g_specific2;
+
+static VOID *PthreadF01(VOID *argument)
+{
+ INT32 ret;
+
+ /* Bind a value to g_key for this thread (this will be different from the value
+ * that we bind for the main thread) */
+ ret = pthread_setspecific(g_key, (void *)(g_keyValue2));
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ /* Get the bound value of the g_key that we just set. */
+ g_specific2 = pthread_getspecific(g_key);
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ ret = pthread_key_create(&g_key, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_setspecific(g_key, (void *)(g_keyValue1));
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_specific1 = pthread_getspecific(g_key);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread226(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread226", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_233.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_233.c
new file mode 100644
index 0000000000000000000000000000000000000000..fb2ea6d94b3f51bf41f7aea8f352aa3185365b95
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_233.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID PthreadF02(VOID *tmp)
+{
+ g_testCount = 1;
+}
+
+static VOID *PthreadF01(VOID *tmp)
+{
+ pthread_key_t g_key;
+ INT32 value = 1;
+ INT32 ret;
+
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_key_create(&g_key, PthreadF02);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_setspecific(g_key, &value);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSem = 1;
+
+ while (1) {
+ sleep(5); // 5, delay for Timing control.
+ }
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ g_testCount = 0;
+ g_pthreadSem = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ while (g_pthreadSem == 0)
+ sleep(1);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread233(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread233", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_237.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_237.c
new file mode 100644
index 0000000000000000000000000000000000000000..450bd8259f64b3f238d6fbe0546c2da0cea858d4
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_237.c
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ pthread_exit(0);
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+VOID ItPosixPthread237(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread237", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_238.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_238.c
new file mode 100644
index 0000000000000000000000000000000000000000..61bcc22682a7d3a2583afe7c9305ad1fb6cf3d38
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_238.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ INT32 ret;
+
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_testCount = 1;
+
+ g_pthreadSem = PTHREAD_INMAIN_TEST;
+
+ while (g_pthreadSem == PTHREAD_INMAIN_TEST)
+ sleep(1);
+
+ pthread_testcancel();
+
+ g_testCount = -1;
+ pthread_exit(0);
+ return NULL;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ g_pthreadSem = PTHREAD_INTHREAD_TEST;
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
+ sleep(1);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSem = PTHREAD_INTHREAD_TEST;
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread238(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread238", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_239.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_239.c
new file mode 100644
index 0000000000000000000000000000000000000000..ecfa59f82937e395a78ad4a329a523f2a37cb32e
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_239.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ INT32 ret;
+
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_testCount = -1;
+
+ g_pthreadSem = PTHREAD_INMAIN_TEST;
+
+ while (g_pthreadSem == PTHREAD_INMAIN_TEST)
+ sleep(1);
+
+ pthread_testcancel();
+
+ g_testCount = 1;
+ pthread_exit(0);
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ g_pthreadSem = PTHREAD_INTHREAD_TEST;
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
+ sleep(1);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSem = PTHREAD_INTHREAD_TEST;
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread239(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread239", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_240.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_240.c
new file mode 100644
index 0000000000000000000000000000000000000000..683149432192fb9c816d45e2525b29660e41d697
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_240.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ INT32 ret;
+
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_testCount = 1;
+
+ g_pthreadSem = PTHREAD_INMAIN_TEST;
+
+ while (g_pthreadSem == PTHREAD_INMAIN_TEST)
+ sleep(1);
+
+ pthread_testcancel();
+
+ g_testCount = -1;
+
+ pthread_exit(0);
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ g_pthreadSem = PTHREAD_INTHREAD_TEST;
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
+ sleep(1);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSem = PTHREAD_INTHREAD_TEST;
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread240(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread240", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_241.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_241.c
new file mode 100644
index 0000000000000000000000000000000000000000..ed838a09a025f497d3a3b73d73bbf1cc9a3738b9
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_241.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ INT32 ret;
+
+ g_testCount++;
+
+ ret = pthread_setcancelstate(-100, NULL); // -100, test for invaild param.
+ ICUNIT_TRACK_EQUAL(ret, EINVAL, ret);
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread241(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread241", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_246.c b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_246.c
new file mode 100644
index 0000000000000000000000000000000000000000..abb30a2b84eb426e8941f3313d932b9681e995dd
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/full/It_posix_pthread_246.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(VOID *argument)
+{
+ INT32 ret;
+
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+ ICUNIT_TRACK_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_testCount = -1;
+
+ g_pthreadSem = PTHREAD_INMAIN_TEST;
+
+ while (g_pthreadSem == PTHREAD_INMAIN_TEST)
+ sleep(1);
+
+ pthread_testcancel();
+
+ g_testCount = 1;
+
+ pthread_exit(0);
+
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ INT32 ret;
+
+ g_pthreadSem = PTHREAD_INTHREAD_TEST;
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ while (g_pthreadSem == PTHREAD_INTHREAD_TEST)
+ sleep(1);
+
+ ret = pthread_cancel(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+
+ g_pthreadSem = PTHREAD_INTHREAD_TEST;
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, PTHREAD_NO_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread246(VOID)
+{
+ TEST_ADD_CASE("ItPosixPthread246", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_003.c b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_003.c
new file mode 100644
index 0000000000000000000000000000000000000000..7a577c6858d563b279a315d1390da64a29396cb3
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_003.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *ThreadF01(void *arg)
+{
+ pthread_exit(NULL);
+ return NULL;
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t aThread;
+ pthread_t ptid;
+ pthread_t a = 0;
+ pthread_t b = 0;
+ int tmp;
+ pthread_attr_t aa = { 0 };
+ int detachstate;
+ pthread_mutex_t c;
+ UINT32 ret;
+
+ ptid = pthread_self();
+ pthread_create(&aThread, NULL, ThreadF01, NULL);
+
+ tmp = pthread_equal(a, b);
+
+ pthread_attr_init(&aa);
+
+ pthread_attr_getdetachstate(&aa, &detachstate);
+
+ pthread_attr_setdetachstate(&aa, PTHREAD_CREATE_DETACHED);
+
+ pthread_attr_destroy(&aa);
+
+ ret = pthread_join(aThread, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread003(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread003", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_004.c b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_004.c
new file mode 100644
index 0000000000000000000000000000000000000000..5963b9bdd3421993b2f417a54c3eee39cdaa135b
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_004.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *ThreadF01(void *arg)
+{
+ pthread_exit((void *)2); // 2, here set value of the exit status.
+ return NULL;
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t mainTh, newTh;
+ UINT32 ret;
+ UINTPTR temp;
+
+ if (pthread_create(&newTh, NULL, ThreadF01, NULL) != 0) {
+ uart_printf_func("Error creating thread\n");
+ ICUNIT_ASSERT_EQUAL(1, 0, errno);
+ }
+
+ LOS_TaskDelay(1);
+ /* Obtain the thread ID of this main function */
+ mainTh = TestPthreadSelf();
+ /* Compare the thread ID of the new thread to the main thread.
+ * They should be different. If not, the test fails. */
+ if (pthread_equal(newTh, mainTh) != 0) {
+ dprintf("Test FAILED: A new thread wasn't created\n");
+ ICUNIT_ASSERT_EQUAL(1, 0, errno);
+ }
+
+ TestExtraTaskDelay(1);
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 2, temp); // 2, here assert the result.
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread004(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread004", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_005.c b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_005.c
new file mode 100644
index 0000000000000000000000000000000000000000..6b592005f392a55e87a753dd17996eb022a38c6a
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_005.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *ThreadF01(void *arg)
+{
+ sleep(1);
+
+ /* Shouldn't reach here. If we do, then the pthread_cancel()
+ * function did not succeed. */
+
+ pthread_exit((void *)0);
+ return NULL;
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ UINTPTR temp;
+
+ if (pthread_create(&newTh, NULL, ThreadF01, NULL) < 0) {
+ uart_printf_func("Error creating thread\n");
+ ICUNIT_ASSERT_EQUAL(1, 0, errno);
+ }
+
+ LOS_TaskDelay(1);
+ /* Try to cancel the newly created thread. If an error is returned,
+ * then the thread wasn't created successfully. */
+ if (pthread_cancel(newTh) != 0) {
+ dprintf("Test FAILED: A new thread wasn't created\n");
+ ICUNIT_ASSERT_EQUAL(1, 0, errno);
+ }
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread005(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread005", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_006.c b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_006.c
new file mode 100644
index 0000000000000000000000000000000000000000..34cc2c6bf2a9e56bd067b574f80919c454ca3266
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_006.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static void *ThreadF01(void *arg)
+{
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+
+ sleep(1);
+
+ pthread_exit((void *)0);
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ void *temp = NULL;
+ pthread_t a;
+
+ /* SIGALRM will be sent in 5 seconds. */
+
+ /* Create a new thread. */
+ if (pthread_create(&a, NULL, ThreadF01, NULL) != 0) {
+ uart_printf_func("Error creating thread\n");
+ ICUNIT_ASSERT_EQUAL(1, 0, errno);
+ }
+
+ LOS_TaskDelay(1);
+ pthread_cancel(a);
+ /* If 'main' has reached here, then the test passed because it means
+ * that the thread is truly asynchronise, and main isn't waiting for
+ * it to return in order to move on. */
+
+ ret = pthread_join(a, &temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread006(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread006", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_009.c b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_009.c
new file mode 100644
index 0000000000000000000000000000000000000000..ddb49ababf1df20487593dff79559655cd3f03d9
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_009.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+
+ pthread_exit(NULL);
+
+ return (void *)9; // 9, here set value about the return status.
+}
+
+static UINT32 Testcase(VOID)
+{
+ pthread_t newTh;
+ UINT32 ret;
+ UINTPTR temp = 1;
+ _pthread_data *joinee = NULL;
+
+ g_testCount = 0;
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_join(g_taskMaxNum, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 1, temp);
+
+ ret = pthread_join(LOSCFG_BASE_CORE_TSK_CONFIG + 1, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 1, temp);
+
+ ret = pthread_detach(g_taskMaxNum);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ sleep(1);
+ ret = pthread_detach(newTh);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ ret = pthread_join(newTh, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread009(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread009", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_018.c b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_018.c
new file mode 100644
index 0000000000000000000000000000000000000000..50424c9fab1cc6466f192b70dac904a4531d907a
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_018.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID *PthreadF01(void *argument)
+{
+ g_testCount++;
+
+ return argument;
+}
+static UINT32 Testcase(VOID)
+{
+ pthread_attr_t attr;
+ pthread_t newTh;
+ UINT32 ret;
+ UINTPTR temp;
+ int policy;
+ struct sched_param param;
+ struct sched_param param2 = { 2 }; // 2, init
+
+ g_testCount = 0;
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newTh, NULL, PthreadF01, (void *)9); // 9, test param of the function.
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ LOS_TaskDelay(1);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_setschedparam(newTh, 0, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_setschedparam(newTh, 4, ¶m); // 4, test for invaild param.
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_setschedparam(newTh, SCHED_RR, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ param.sched_priority = 0;
+ ret = pthread_setschedparam(newTh, SCHED_RR, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ param.sched_priority = 31; // 31, init
+ ret = pthread_setschedparam(newTh, SCHED_RR, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ param.sched_priority = 32; // 32, init
+ ret = pthread_setschedparam(newTh, SCHED_RR, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_getschedparam(newTh, NULL, ¶m2);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+ ICUNIT_ASSERT_EQUAL(param2.sched_priority, 2, param2.sched_priority); // 2, here assert the result.
+
+ ret = pthread_getschedparam(newTh, &policy, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_getschedparam(newTh, &policy, ¶m2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(param2.sched_priority, 31, param2.sched_priority); // 31, here assert the result.
+
+ ret = pthread_join(newTh, (void *)&temp);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(temp, 9, temp); // 9, here assert the result.
+
+ param.sched_priority = 4; // 4, init
+ ret = pthread_setschedparam(newTh, SCHED_RR, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ ret = pthread_setschedparam(newTh + 9, SCHED_RR, ¶m); // 9, test for invaild param.
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ ret = pthread_getschedparam(newTh, &policy, ¶m2);
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ ret = pthread_getschedparam(newTh + 8, &policy, ¶m2); // 8, test for invaild param.
+ ICUNIT_ASSERT_EQUAL(ret, ESRCH, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread018(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread018", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_019.c b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_019.c
new file mode 100644
index 0000000000000000000000000000000000000000..9d7c647816931173f314b242ac9e4af70ac421c4
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_019.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static VOID PthreadOnceF01(VOID)
+{
+ g_testCount++;
+}
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ pthread_once_t onceBlock;
+
+ g_testCount = 0;
+
+ ret = pthread_once(NULL, PthreadOnceF01);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ onceBlock = 1;
+ ret = pthread_once(&onceBlock, PthreadOnceF01);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 0, g_testCount);
+
+ onceBlock = PTHREAD_ONCE_INIT;
+ ret = pthread_once(&onceBlock, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_once(&onceBlock, PthreadOnceF01);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ ret = pthread_once(&onceBlock, PthreadOnceF01);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread019(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread019", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_021.c b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_021.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d83edfb2348477f131a55d110e14fd202193627
--- /dev/null
+++ b/testsuites/kernel/sample/posix/pthread/smoke/It_posix_pthread_021.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 "It_posix_pthread.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+static UINT32 Testcase(VOID)
+{
+ UINT32 ret;
+ int oldstate;
+ int oldstype;
+
+ ret = pthread_setcancelstate(2, &oldstate); // 2, test for invaild param.
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_setcancelstate(3, &oldstate); // 3, test for invaild param.
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(oldstate, PTHREAD_CANCEL_ENABLE, oldstate);
+
+ ret = pthread_setcanceltype(2, &oldstype); // 2, test for invaild param.
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_setcanceltype(3, &oldstype); // 3, test for invaild param.
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldstate);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(oldstate, PTHREAD_CANCEL_ASYNCHRONOUS, oldstate);
+
+ return PTHREAD_NO_ERROR;
+}
+
+VOID ItPosixPthread021(VOID) // IT_Layer_ModuleORFeature_No
+{
+ TEST_ADD_CASE("ItPosixPthread021", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
\ No newline at end of file
diff --git a/testsuites/kernel/src/iCunit.c b/testsuites/kernel/src/iCunit.c
new file mode 100644
index 0000000000000000000000000000000000000000..9b8b709aa23b6f9ec44e21c1fc54bc2b9888c744
--- /dev/null
+++ b/testsuites/kernel/src/iCunit.c
@@ -0,0 +1,662 @@
+/*
+ * 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 "iCunit.h"
+#include "iCunit.inc"
+#include "iCunit_config.h"
+#include "osTest.h"
+#if TEST_RESOURCELEAK_CHECK == YES
+#include "los_swtmr_pri.h"
+#include "los_sem_pri.h"
+#include "los_queue_pri.h"
+#include "los_task_pri.h"
+#include "los_mux_pri.h"
+#endif
+#include
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define ARRAY_SIZE 2
+
+#if (LOSCFG_KERNEL_SMP == YES)
+LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_testSuitSpin);
+#endif
+
+extern UINT32 g_failResult;
+extern UINT32 g_passResult;
+
+extern int atoi(const char *str);
+extern int strncmp(const char *s1, const char *s2, size_t n);
+
+char *g_strLayer[] = {"LOS", "POSIX", "LIB", "VFS", "EXTEND",
+ "PARTITION", "CPP", "SHELL", "LINUX", "USB",
+#if defined(LOSCFG_3RDPARTY_TEST)
+ "TEST_3RDPARTY",
+#endif
+ "DRIVER", "ALL"
+ };
+
+char *g_strModule[] = {"TASK", "MEM", "SEM", "MUX", "EVENT", "QUE", "SWTMR", "HWI", "MP", "ATO", "CPUP", "SCATTER", "RUNSTOP", "TIMER", "MMU",
+ "ROBIN", "LIBC", "WAIT", "VFAT", "JFFS", "RAMFS", "NFS", "PROC", "FS", "UART",
+ "PTHREAD", "COMP", "HWI_HALFBOTTOM", "WORKQ", "WAKELOCK", "TIMES",
+ "LIBM", "SUPPORT", "STL", "MAIL", "MSG", "CP", "SIGNAL", "SCHED", "MTDCHAR", "TIME", "WRITE", "READ", "DYNLOAD", "REGISTER",
+ "UNAME", "ERR", "CMD", "TICKLESS", "TRACE", "UNALIGNACCESS", "EXC", "REQULATOR", "DEVFREQ", "CPUFREQ", "TEST_MISC",
+#if defined(LOSCFG_3RDPARTY_TEST)
+ "THTTPD", "BIDIREFC", "CJSON", "CURL", "FFMPEG", "FREETYPE", "INIPARSER", "JSONCPP", "LIBICONV", "LIBJPEG", "LIBPNG", "OPENEXIF", "OPENSSL",
+ "OPUS", "SQLITE", "TINYXML", "XML2", "ZBAR", "HARFBUZZ",
+#endif
+ "TEST_DRIVERBASE", "ALL"
+ };
+UINT32 g_modelNum = sizeof(g_strModule) / sizeof(g_strModule[0]);
+
+#if TEST_MODULE_CHECK == YES
+
+UINT32 g_failModelResult[sizeof(g_strModule) / sizeof(g_strModule[0])] = {0};
+UINT32 g_passModelResult[sizeof(g_strModule) / sizeof(g_strModule[0])] = {0};
+UINT32 g_executModelNum[sizeof(g_strModule) / sizeof(g_strModule[0])] = {0};
+ICUNIT_CASE_S g_errorCase[50] = {0};
+
+#endif
+
+char *g_strLevel[] = {"LEVEL0", "LEVEL1", "LEVEL2", "LEVEL3", "LEVEL4", "ALL"};
+char *g_strType[] = {"FUNCTION", "PRESSURE", "PERFORMANCE", "ALL"};
+char *g_strSequence[] = {"SEQUENCE", "RANDOM"};
+
+
+u_long ICunitRand(void)
+{
+ static u_long randseed;
+ u_long t;
+ long x, hi, lo;
+ UINT32 high = 0;
+ UINT32 low = 0;
+
+ extern VOID LOS_GetCpuCycle(UINT32 * puwCntHi, UINT32 * puwCntLo);
+ LOS_GetCpuCycle(&high, &low);
+ randseed = ((u_long)(high << 30) + low); // 30, generate a seed.
+
+ /*
+ * Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1).
+ * From "Random number generators: good ones are hard to find",
+ * Park and Miller, Communications of the ACM, vol. 31, no. 10,
+ * October 1988, p. 1195.
+ */
+ x = randseed;
+ hi = x / 127773; // 127773, generate a seed.
+ lo = x % 127773; // 127773, generate a seed.
+ t = 16807 * lo - 2836 * hi; // 16807, 2836, generate a seed.
+ if (t <= 0)
+ t += 0x7fffffff;
+ randseed = t;
+ return (u_long)(t);
+}
+
+void ICunitSaveErr(iiUINT32 line, iiUINT32 retCode)
+{
+#if (LOSCFG_KERNEL_SMP == YES)
+ UINT32 intSave;
+ TESTSUIT_LOCK(intSave);
+#endif
+ g_iCunitErrCode = ((g_iCunitErrCode == 0) && (g_iCunitErrLineNo == 0)) ? (iiUINT32)retCode : g_iCunitErrCode;
+ g_iCunitErrLineNo = (g_iCunitErrLineNo == 0) ? line : g_iCunitErrLineNo;
+#if (LOSCFG_KERNEL_SMP == YES)
+ TESTSUIT_UNLOCK(intSave);
+#endif
+}
+
+#undef LOSCFG_TEST_LEVEL
+#define LOSCFG_TEST_LEVEL 0
+iUINT32 ICunitAddCase(const iCHAR *caseName, CASE_FUNCTION caseFunc, iUINT16 testcaseLayer, iUINT16 testcaseModule,
+ iUINT16 testcaseLevel, iUINT16 testcaseType)
+{
+ iUINT16 idx;
+
+ if (g_iCunitInitSuccess) {
+ return (iUINT32)ICUNIT_UNINIT;
+ }
+
+ /* Don't run Firstly with Python */
+ if (g_iCunitCaseRun == 0) {
+ return (iUINT32)ICUNIT_SUCCESS;
+ }
+
+#if defined(LITEOS_TESTSUIT_SHELL) || defined(LOSCFG_TEST_MUTIL)
+ idx = g_iCunitCaseCnt;
+#else
+ idx = 0;
+#endif
+ if (idx == ICUNIT_CASE_SIZE) {
+ g_iCunitErrLogAddCase++;
+ return (iUINT32)ICUNIT_CASE_FULL;
+ }
+
+ g_iCunitCaseArray[idx].pcCaseID = caseName;
+ g_iCunitCaseArray[idx].pstCaseFunc = caseFunc;
+ g_iCunitCaseArray[idx].testcase_layer = testcaseLayer;
+ g_iCunitCaseArray[idx].testcase_module = testcaseModule;
+ g_iCunitCaseArray[idx].testcase_level = testcaseLevel;
+ g_iCunitCaseArray[idx].testcase_type = testcaseType;
+
+#if defined(LITEOS_TESTSUIT_SHELL) || defined(LOSCFG_TEST_MUTIL)
+ g_iCunitCaseCnt++;
+#else
+ ICunitRunSingle(&g_iCunitCaseArray[idx]);
+#endif
+
+#if defined(LOSCFG_TEST_MUTIL)
+ ICunitRunSingle(&g_iCunitCaseArray[idx]);
+#endif
+
+ return (iUINT32)ICUNIT_SUCCESS;
+}
+UINT32 g_cunitInitFlag = 0;
+iUINT32 ICunitInit(void)
+{
+#if (LOSCFG_KERNEL_SMP == YES)
+ if (LOS_AtomicCmpXchg32bits(&g_cunitInitFlag, 1, 0)) {
+ PRINTK("other core already done iCunitInit\n");
+ return (iUINT32)ICUNIT_SUCCESS;
+ }
+#endif
+ g_iCunitInitSuccess = 0x0000;
+ g_iCunitCaseCnt = 0x0000;
+ g_iCunitCaseFailedCnt = 0;
+ g_iCunitErrLogAddCase = 0;
+ memset(g_iCunitCaseArray, 0, sizeof(g_iCunitCaseArray));
+ g_iCunitCaseRun = 1;
+
+ return (iUINT32)ICUNIT_SUCCESS;
+}
+
+iUINT32 ICunitRunSingle(ICUNIT_CASE_S *psubCase)
+{
+ if ((g_isSpinorInit == FALSE) && (psubCase->testcase_module == TEST_JFFS))
+ dprintf("****** Jffs is not support ! ****** \n");
+ else
+ ICunitRunF(psubCase);
+
+ return (iUINT32)ICUNIT_SUCCESS;
+}
+
+iUINT32 ICunitRunF(ICUNIT_CASE_S *psubCase)
+{
+ iUINT32 caseRet;
+ UINT32 curTestTaskID;
+ g_iCunitErrLineNo = 0;
+ g_iCunitErrCode = 0;
+
+#if TEST_RESOURCELEAK_CHECK == YES
+ extern UINT32 LOS_MemTotalUsedGet(VOID * pPool);
+ extern HwiHandleForm g_hwiForm[OS_HWI_MAX_NUM];
+ extern SWTMR_CTRL_S *g_swtmrCBArray;
+ static SWTMR_CTRL_S *swtmr;
+ iUINT32 i;
+ static UINT32 gAuwMemuse[ARRAY_SIZE];
+ static UINT32 gUwTskNum[ARRAY_SIZE];
+ static UINT32 gUwSwtNum[ARRAY_SIZE];
+ static UINT32 gUwHwiNum[ARRAY_SIZE];
+ static UINT32 gUwQueueNum[ARRAY_SIZE];
+ LosQueueCB *queueCB = NULL;
+ static UINT32 gUwSemNum[ARRAY_SIZE];
+ static LosSemCB *semNode;
+ UINT32 muxCnt[ARRAY_SIZE];
+
+ memset(gUwSwtNum, 0, sizeof(gUwSwtNum));
+ memset(gUwHwiNum, 0, sizeof(gUwHwiNum));
+ memset(gUwTskNum, 0, sizeof(gUwTskNum));
+ memset(gAuwMemuse, 0, sizeof(gAuwMemuse));
+ memset(gUwQueueNum, 0, sizeof(gUwQueueNum));
+ memset(gUwSemNum, 0, sizeof(gUwSemNum));
+
+ curTestTaskID = LOS_CurTaskIDGet();
+
+ // task
+ for (i = 0; i <= LOSCFG_BASE_CORE_TSK_LIMIT; i++) {
+ if (g_taskCBArray[i].taskStatus == OS_TASK_STATUS_UNUSED)
+ gUwTskNum[0]++;
+ }
+
+ // swtmr
+ swtmr = g_swtmrCBArray;
+ for (i = 0; i < LOSCFG_BASE_CORE_SWTMR_LIMIT; i++, swtmr++) {
+ if (swtmr->ucState == OS_SWTMR_STATUS_UNUSED)
+ gUwSwtNum[0]++;
+ }
+
+ // hwi
+ for (i = 0; i < OS_HWI_MAX_NUM; i++) {
+ if ((g_hwiForm[i].pfnHook == (HWI_PROC_FUNC)NULL) && (g_hwiForm[i].uwParam == 0))
+ gUwHwiNum[0]++;
+ }
+
+ // sem
+ for (i = 0; i < LOSCFG_BASE_IPC_SEM_LIMIT; i++) {
+ semNode = GET_SEM(i);
+ if (semNode->semStat == OS_SEM_UNUSED) {
+ gUwSemNum[0]++;
+ }
+ }
+
+ // queue
+ queueCB = g_allQueue;
+ for (i = 0; i < LOSCFG_BASE_IPC_QUEUE_LIMIT; i++, queueCB++) {
+ if (queueCB->queueState == OS_QUEUE_UNUSED) {
+ gUwQueueNum[0]++;
+ }
+ }
+
+ gAuwMemuse[0] = LOS_MemTotalUsedGet(OS_SYS_MEM_ADDR);
+
+ if (g_performanceStart <= 0) {
+ dprintf("# Enter:%s \n", psubCase->pcCaseID);
+ }
+ caseRet = psubCase->pstCaseFunc();
+
+ if (g_performanceStart <= 0) {
+ if ((strcmp(psubCase->pcCaseID, "LLT_PLAT_004") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_JFFS_MUTIPTHREAD_001") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_JFFS_PRESSURE_013") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_JFFS_PRESSURE_052") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_JFFS_026") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_PARTITION_JFFS_004") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_PARTITION_JFFS_009") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_PARTITION_JFFS_013") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_PARTITION_JFFS_017") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_PARTITION_JFFS_018") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_PARTITION_JFFS_039") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_FAT_VIRPART_PRESSURE_001") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_FAT_VIRPART_151") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_FAT_VIRPART_040") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_FAT_VIRPART_MULTIPTHREAD_000") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_FAT_VIRPART_MULTIPTHREAD_033") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_FAT_VIRPART_MULTIPTHREAD_034") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_FATVP_363") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_FAT_VIRPART_012") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_PARTITION_DISK_001") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_NFS_PRESSURE_013") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_PARTITION_Yaffs_019") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_PARTITION_Yaffs_017") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_PARTITION_Yaffs_013") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_PARTITION_Yaffs_009") == 0) ||
+ (strcmp(psubCase->pcCaseID, "LLT_VFS_FAT_002") == 0) ||
+ (strcmp(psubCase->pcCaseID, "IT_FS_FAT_363") == 0) || (strcmp(psubCase->pcCaseID, "LLT_FS_VFS_004") == 0) ||
+ (strcmp(psubCase->pcCaseID, "LLT_FS_RAMFS_003") == 0) ||
+ (strcmp(psubCase->pcCaseID, "LLT_FS_RAMFS_001") == 0)) {
+ dprintf(" [Case]-%s-%s-%s-%s-%s,unruning!!!\n", psubCase->pcCaseID, g_strLayer[psubCase->testcase_layer],
+ g_strModule[psubCase->testcase_module], g_strLevel[psubCase->testcase_level],
+ g_strType[psubCase->testcase_type]);
+ goto ENDING;
+ }
+
+ gAuwMemuse[1] = LOS_MemTotalUsedGet(OS_SYS_MEM_ADDR);
+
+ // task
+ for (i = 0; i <= LOSCFG_BASE_CORE_TSK_LIMIT; i++) {
+ if (g_taskCBArray[i].taskStatus == OS_TASK_STATUS_UNUSED)
+ gUwTskNum[1]++;
+ }
+
+ // swtmr
+ swtmr = g_swtmrCBArray;
+ for (i = 0; i < LOSCFG_BASE_CORE_SWTMR_LIMIT; i++, swtmr++) {
+ if (swtmr->ucState == OS_SWTMR_STATUS_UNUSED)
+ gUwSwtNum[1]++;
+ }
+
+ // hwi
+ for (i = 0; i < OS_HWI_MAX_NUM; i++) {
+ if ((g_hwiForm[i].pfnHook == (HWI_PROC_FUNC)NULL) && (g_hwiForm[i].uwParam == 0))
+ gUwHwiNum[1]++;
+ }
+
+ // sem
+ for (i = 0; i < LOSCFG_BASE_IPC_SEM_LIMIT; i++) {
+ semNode = GET_SEM(i);
+ if (semNode->semStat == OS_SEM_UNUSED) {
+ gUwSemNum[1]++;
+ }
+ }
+
+ // queue
+ queueCB = g_allQueue;
+ for (i = 0; i < LOSCFG_BASE_IPC_QUEUE_LIMIT; i++, queueCB++) {
+ if (queueCB->queueState == OS_QUEUE_UNUSED) {
+ gUwQueueNum[1]++;
+ }
+ }
+
+ if (gUwSemNum[1] != gUwSemNum[0]) {
+ dprintf("\n[Case Resource Leak Failed]------------------Sem used:%d Semleak:%d\n", gUwSemNum[1],
+ (gUwSemNum[1] - gUwSemNum[0]));
+ }
+
+ if (gUwQueueNum[1] != gUwQueueNum[0]) {
+ dprintf("\n[Case Resource Leak Failed]------------------Queue used:%d Queueleak:%d\n", gUwQueueNum[1],
+ (gUwQueueNum[1] - gUwQueueNum[0]));
+ }
+
+ if (gUwTskNum[1] != gUwTskNum[0]) {
+ dprintf("\n[Case Resource Leak Failed]------------------Task used:%d Taskleak:%d\n", gUwTskNum[1],
+ (gUwTskNum[1] - gUwTskNum[0]));
+ }
+
+ if (gUwSwtNum[1] != gUwSwtNum[0]) {
+ dprintf("\n[Case Resource Leak Failed]------------------Swtmr used:%d Swtmrleak:%d\n", gUwSwtNum[1],
+ (gUwSwtNum[1] - gUwSwtNum[0]));
+ }
+
+ if (gUwHwiNum[1] != gUwHwiNum[0]) {
+ dprintf("\n[Case Resource Leak Failed]------------------Hwi used:%d Hwileak:%d\n", gUwHwiNum[1],
+ (gUwHwiNum[1] - gUwHwiNum[0]));
+ }
+
+ if (gAuwMemuse[1] != gAuwMemuse[0]) {
+ dprintf("\n[Case Resource Leak Failed]------------------Mem used:%d Memleak:%d\n", gAuwMemuse[1],
+ (gAuwMemuse[1] - gAuwMemuse[0]));
+ }
+ }
+
+#else
+ if (g_performanceStart <= 0) {
+ curTestTaskID = LOS_CurTaskIDGet();
+ dprintf("# T:%d Enter:%s \n", curTestTaskID, psubCase->pcCaseID);
+ }
+ caseRet = psubCase->pstCaseFunc();
+#endif
+
+ psubCase->errLine = g_iCunitErrLineNo;
+ psubCase->retCode = (0 == g_iCunitErrLineNo) ? (caseRet) : (g_iCunitErrCode);
+
+#if TEST_MODULE_CHECK == YES
+ g_executModelNum[psubCase->testcase_module]++;
+#endif
+ENDING:
+ if (psubCase->errLine == 0 && caseRet == 0) {
+ g_passResult++;
+
+#if TEST_MODULE_CHECK == YES
+ g_passModelResult[psubCase->testcase_module]++;
+#endif
+
+ if (g_performanceStart <= 0) {
+ dprintf(" T:%d [Passed]-%s-%s-%s-%s-%s\n", curTestTaskID, psubCase->pcCaseID,
+ g_strLayer[psubCase->testcase_layer], g_strModule[psubCase->testcase_module],
+ g_strLevel[psubCase->testcase_level], g_strType[psubCase->testcase_type]);
+ }
+ } else {
+#if TEST_MODULE_CHECK == YES
+ if (g_failResult < 50) { // 50
+ g_errorCase[g_failResult] = *psubCase;
+ }
+ g_failModelResult[psubCase->testcase_module]++;
+#endif
+
+ g_iCunitCaseFailedCnt++;
+ g_failResult++;
+ dprintf(" T:%d [Failed]-%s-%s-%s-%s-%s-[Errline: %d RetCode:0x%04X%04X]\n", curTestTaskID, psubCase->pcCaseID,
+ g_strLayer[psubCase->testcase_layer], g_strModule[psubCase->testcase_module],
+ g_strLevel[psubCase->testcase_level], g_strType[psubCase->testcase_type], psubCase->errLine,
+ (iUINT16)((psubCase->retCode) >> 16), (iUINT16)(psubCase->retCode)); // 16
+
+#ifdef LOSCFG_SHELL
+ dprintf("\n\n ********************************************************** \n");
+ OsShellCmdSystemInfo(0, NULL);
+ dprintf("\n ********************************************************** \n");
+ const CHAR *taskAll = "-a";
+ OsShellCmdDumpTask(1, &taskAll);
+ dprintf(" ********************************************************** \n\n\n");
+#endif
+ }
+
+ return (iUINT32)ICUNIT_SUCCESS;
+}
+
+INT32 ICunitRunTestArray(const char *tcSequence, const char *tcNum, const char *tcLayer, const char *tcModule,
+ const char *tcLevel, const char *tcType)
+{
+ iUINT32 testcaseNum;
+ iUINT32 testcaseLayer = 0xFFFF;
+ iUINT32 testcaseModule = 0xFFFF;
+ iUINT32 testcaseLevel = 0xFFFF;
+ iUINT32 testcaseType = 0xFFFF;
+ iUINT32 ilayer;
+ iUINT32 imodule;
+ iUINT32 ilevel;
+ iUINT32 itype;
+
+ testcaseNum = atoi(tcNum);
+ if (testcaseNum > 0xFFFF) {
+ dprintf("[testcase_Num]-%u is too large \n", testcaseNum);
+
+ testcaseNum = 0xFFFF;
+ }
+
+ for (ilayer = 0; ilayer <= TEST_LAYER_ALL; ilayer++) {
+ if (strcmp(g_strLayer[ilayer], tcLayer) == 0) {
+ testcaseLayer = ilayer;
+ dprintf("[testcase_Layer]-%s \n", g_strLayer[ilayer]);
+
+ break;
+ }
+ }
+
+ if (testcaseLayer == 0xFFFF) {
+ dprintf("[testcase_Layer]-%s is invalid \n", tcLayer);
+
+ return (iUINT32)ICUNIT_SUCCESS;
+ }
+
+ for (imodule = 0; imodule <= TEST_MODULE_ALL; imodule++) {
+ if (strcmp(g_strModule[imodule], tcModule) == 0) {
+ testcaseModule = imodule;
+ dprintf("[testcase_Module]-%s \n", g_strModule[imodule]);
+
+ break;
+ }
+ }
+
+ if (testcaseModule == 0xFFFF) {
+ dprintf("[testcase_Module]-%s is invalid \n", tcModule);
+
+ return (iUINT32)ICUNIT_SUCCESS;
+ }
+
+ for (ilevel = 0; ilevel <= TEST_LEVEL_ALL; ilevel++) {
+ if (strcmp(g_strLevel[ilevel], tcLevel) == 0) {
+ testcaseLevel = ilevel;
+ dprintf("[testcase_Level]-%s \n", g_strLevel[ilevel]);
+
+ break;
+ }
+ }
+
+ if (testcaseLevel == 0xFFFF) {
+ dprintf("[testcase_Level]-%s is invalid \n", tcLevel);
+
+ return (iUINT32)ICUNIT_SUCCESS;
+ }
+
+ for (itype = 0; itype <= TEST_TYPE_ALL; itype++) {
+ if (strcmp(g_strType[itype], tcType) == 0) {
+ testcaseType = itype;
+ dprintf("[testcase_Type]-%s \n", g_strType[itype]);
+
+ break;
+ }
+ }
+
+ if (testcaseType == 0xFFFF) {
+ dprintf("[testcase_Type]-%s is invalid \n", tcType);
+
+ return (iUINT32)ICUNIT_SUCCESS;
+ }
+
+ if (0 == strncmp(tcSequence, "SEQUENCE", 8)) { // 8, "SEQUENCE" length
+ dprintf("[testcase_Sequence]-%s \n", tcSequence);
+
+ ICunitRunTestArraySequence(testcaseNum, testcaseLayer, testcaseModule, testcaseLevel, testcaseType);
+ } else if (0 == strncmp(tcSequence, "RANDOM", 6)) { // 6, "RANDOM" length
+ dprintf("[testcase_Random]-%s \n", tcSequence);
+
+ ICunitRunTestArrayRandom(testcaseNum, testcaseLayer, testcaseModule, testcaseLevel, testcaseType);
+ } else {
+ dprintf("[testcase_Sequence]-%s is invalid \n", tcSequence);
+ }
+
+ g_failResult = 0;
+ g_passResult = 0;
+
+ return (iUINT32)ICUNIT_SUCCESS;
+}
+
+iUINT32 ICunitRunTestArraySequence(iUINT32 testcaseNum, iUINT32 testcaseLayer, iUINT32 testcaseModule,
+ iUINT32 testcaseLevel, iUINT32 testcaseType)
+{
+ iUINT32 num;
+ iUINT32 idx;
+ iUINT32 idx1;
+ iUINT32 failedCount;
+ iUINT32 successCount;
+
+ idx1 = g_iCunitCaseCnt;
+
+ for (num = 0; num < testcaseNum; num++) {
+ failedCount = g_failResult;
+ successCount = g_passResult;
+
+ for (idx = 0; idx < idx1; idx++) {
+ ICunitRunTestcaseSatisfied(&(g_iCunitCaseArray[idx]), testcaseLayer, testcaseModule, testcaseLevel,
+ testcaseType);
+ }
+ }
+
+ return (iUINT32)ICUNIT_SUCCESS;
+}
+
+
+iUINT32 ICunitRunTestArrayRandom(iUINT32 testcaseNum, iUINT32 testcaseLayer, iUINT32 testcaseModule,
+ iUINT32 testcaseLevel, iUINT32 testcaseType)
+{
+ iUINT32 num;
+ iUINT32 idx;
+ iUINT32 idx1;
+ iUINT32 randIdx;
+ ICUNIT_CASE_S subCaseArrayTemp;
+ iUINT32 failedCount;
+ iUINT32 successCount;
+
+ memset(&subCaseArrayTemp, 0, sizeof(ICUNIT_CASE_S));
+
+ idx1 = g_iCunitCaseCnt;
+
+ for (num = 0; num < testcaseNum; num++) {
+ failedCount = g_failResult;
+ successCount = g_passResult;
+
+ for (idx = idx1 - 1; idx > 1; idx--) {
+ memset(&subCaseArrayTemp, 0, sizeof(ICUNIT_CASE_S));
+
+ randIdx = ICunitRand() % idx;
+ subCaseArrayTemp = g_iCunitCaseArray[randIdx];
+ g_iCunitCaseArray[randIdx] = g_iCunitCaseArray[idx];
+ g_iCunitCaseArray[idx] = subCaseArrayTemp;
+ ICunitRunTestcaseSatisfied(&(g_iCunitCaseArray[idx]), testcaseLayer, testcaseModule, testcaseLevel,
+ testcaseType);
+ }
+
+ ICunitRunTestcaseSatisfied(&(g_iCunitCaseArray[1]), testcaseLayer, testcaseModule, testcaseLevel, testcaseType);
+ ICunitRunTestcaseSatisfied(&(g_iCunitCaseArray[0]), testcaseLayer, testcaseModule, testcaseLevel, testcaseType);
+ }
+
+ return (iUINT32)ICUNIT_SUCCESS;
+}
+
+extern iUINT32 ICunitRunTestcaseOne(ICUNIT_CASE_S *testCase);
+
+iUINT32 ICunitRunTestOne(const char *tcId)
+{
+ iUINT32 idx;
+ iUINT32 idx1;
+ ICUNIT_CASE_S subCaseArrayTemp;
+
+ memset(&subCaseArrayTemp, 0, sizeof(ICUNIT_CASE_S));
+
+ idx1 = g_iCunitCaseCnt;
+
+ for (idx = 0; idx < idx1; idx++) {
+ memset(&subCaseArrayTemp, 0, sizeof(ICUNIT_CASE_S));
+ subCaseArrayTemp = g_iCunitCaseArray[idx];
+
+ if (strcmp(subCaseArrayTemp.pcCaseID, tcId) == 0) {
+ ICunitRunTestcaseOne(&g_iCunitCaseArray[idx]);
+ }
+ }
+
+ return (iUINT32)ICUNIT_SUCCESS;
+}
+
+iUINT32 ICunitRunTestcaseSatisfied(ICUNIT_CASE_S *testCase, iUINT32 testcaseLayer, iUINT32 testcaseModule,
+ iUINT32 testcaseLevel, iUINT32 testcaseType)
+{
+ /* reserve interface to extend */
+ if (((testCase->testcase_layer == testcaseLayer) || (testcaseLayer == TEST_LAYER_ALL)) &&
+ ((testCase->testcase_module == testcaseModule) || (testcaseModule == TEST_MODULE_ALL)) &&
+ ((testCase->testcase_level == testcaseLevel) || (testcaseLevel == TEST_LEVEL_ALL)) &&
+ ((testCase->testcase_type == testcaseType) || (testcaseType == TEST_TYPE_ALL))) {
+ ICunitRunSingle(testCase);
+ }
+
+ return (iUINT32)ICUNIT_SUCCESS;
+}
+
+iUINT32 ICunitRunTestcaseOne(ICUNIT_CASE_S *testCase)
+{
+ ICunitRunSingle(testCase);
+ return (iUINT32)ICUNIT_SUCCESS;
+}
+
+
+#ifndef TST_DRVPRINT
+iUINT32 PtSaveReport(iCHAR *iCunitReportName, iCHAR *name, iUINT32 value)
+{
+ return ICUNIT_SUCCESS;
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/src/osTest.c b/testsuites/kernel/src/osTest.c
new file mode 100644
index 0000000000000000000000000000000000000000..12d730d4fe77420c25ce3b832648335fd839b818
--- /dev/null
+++ b/testsuites/kernel/src/osTest.c
@@ -0,0 +1,542 @@
+/*
+ * 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 "securec.h"
+#ifdef LOSCFG_KERNEL_CPPSUPPORT
+#include "los_cppsupport.h"
+#endif
+#if defined(TEST3518E) || defined(TEST3516A) || defined(TEST3516EV200)
+#include "eth_drv.h"
+#endif
+#if !defined(LOSCFG_AARCH64) && !defined(TESTISP)
+#include "console.h"
+#else
+#include "los_config.h"
+#endif
+#include "los_sem_pri.h"
+#include "los_mux_pri.h"
+#include "los_queue_pri.h"
+#include "los_swtmr_pri.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+UINT32 g_shellTestQueueID;
+
+UINT32 g_testTskHandle;
+UINT32 volatile g_testCount;
+UINT32 g_flowcheck = 0;
+UINT32 g_failResult = 0;
+UINT32 g_passResult = 0;
+
+#ifdef TESTPBXA9
+int snprintf(char *str, unsigned int len, const char *fmt, ...) {}
+#endif
+
+#ifdef TEST1980
+UINT32 g_testhwiFlag;
+UINT32 g_testCpuMask;
+#endif
+
+SPIN_LOCK_S g_testSpin;
+UINT32 g_testCount1;
+UINT32 g_testCount2;
+UINT32 g_testCount3;
+UINT32 g_testTaskID01;
+UINT32 g_testTaskID02;
+UINT32 g_testTaskID03;
+UINT32 g_testTaskID04;
+UINT32 g_hwiNum1;
+UINT32 g_hwiNum2;
+UINT32 g_semID;
+UINT32 g_semID2;
+LosMux g_mutexkernelTest;
+UINT32 g_cpupTestCount;
+UINT32 g_waitTestCount;
+UINT32 g_testPeriod;
+
+UINT16 g_swTmrID;
+UINT32 g_testQueueID01;
+UINT32 g_testQueueID02;
+UINT32 g_testQueueID03;
+UINT32 g_leavingTaskNum;
+UINT32 g_getTickConsume = 0;
+EVENT_CB_S g_eventCB;
+EVENT_CB_S g_event;
+UINT32 g_testCircleCount = 0;
+INT32 g_performanceStart = -1;
+
+#define MOUNT_PATH NFS_MOUNT_DIR
+UINT32 g_fatFilesystem;
+UINT8 g_mIndex;
+UINT32 g_semID3[LOSCFG_BASE_IPC_SEM_CONFIG + 1];
+LOS_MEM_POOL_STATUS g_sysMemStatus = { 0 };
+
+#if TEST_MODULE_CHECK == YES
+
+extern UINT32 g_failModelResult[];
+extern UINT32 g_passModelResult[];
+extern UINT32 g_executModelNum[];
+extern ICUNIT_CASE_S g_errorCase[];
+#endif
+extern char *g_strLayer[];
+extern char *g_strLevel[];
+extern char *g_strType[];
+
+extern char *g_strModule[];
+extern UINT32 g_modelNum;
+
+#ifdef LOSCFG_TEST_FS_FAT
+#define TEST_FAT32 0x02
+#define TEST_EXFAT 0x04
+#endif
+
+BOOL g_isSpinorInit = FALSE;
+BOOL g_isSdInit = FALSE;
+BOOL g_isUartDevInit = FALSE;
+BOOL g_isTcpipInit = FALSE;
+BOOL g_isInitSerial = FALSE;
+UINT32 g_vfsCyclesCount = 0;
+INT32 g_serialInitFlag = -1;
+BOOL g_isAddArray = TRUE;
+BOOL g_isUsbInit = FALSE;
+BOOL g_isIpcGmacInit = FALSE;
+
+BOOL g_isDriversRandomInit = FALSE;
+
+BOOL g_isHisiEthSetPhyModeInit = FALSE;
+
+BOOL g_isVfsInit = FALSE;
+
+u_long TRandom(VOID)
+{
+ u_long t;
+ long x, hi, lo;
+ UINT64 cpuCycle;
+ UINT32 high, low;
+ extern VOID LOS_GetCpuCycle(UINT32 * puwCntHi, UINT32 * puwCntLo);
+ LOS_GetCpuCycle(&high, &low);
+ cpuCycle = (((UINT64)high << 30) + low); // 30, generate a seed.
+ x = cpuCycle;
+ hi = x / 127773; // 127773, generate a seed.
+ lo = x % 127773; // 127773, generate a seed.
+ t = 16807 * lo - 2836 * hi; // 16807, 2836, generate a seed.
+ if (t <= 0)
+ t += 0x7fffffff;
+ return (u_long)(t);
+}
+
+UINT32 LosMuxCreate(LosMux *mutex)
+{
+ return LOS_MuxInit(mutex, NULL);
+}
+
+UINT32 TaskCountGetTest(VOID)
+{
+ UINT32 loop;
+ UINT32 taskCnt = 0;
+ UINT32 intSave;
+ LosTaskCB *taskCB = (LosTaskCB *)NULL;
+
+ intSave = LOS_IntLock();
+ for (loop = 0; loop < g_taskMaxNum; loop++) {
+ taskCB = (((LosTaskCB *)g_taskCBArray) + loop);
+ if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
+ continue;
+ }
+ taskCnt++;
+ }
+ (VOID)LOS_IntRestore(intSave);
+ return taskCnt;
+}
+
+UINT32 SemCountGetTest(VOID)
+{
+ UINT32 loop;
+ UINT32 semCnt = 0;
+ UINT32 intSave;
+ LosSemCB *semNode = (LosSemCB *)NULL;
+
+ intSave = LOS_IntLock();
+ for (loop = 0; loop < LOSCFG_BASE_IPC_SEM_CONFIG; loop++) {
+ semNode = GET_SEM(loop);
+ if (semNode->semStat == OS_SEM_USED) {
+ semCnt++;
+ }
+ }
+ (VOID)LOS_IntRestore(intSave);
+ return semCnt;
+}
+
+UINT32 QueueCountGetTest(VOID)
+{
+ UINT32 loop;
+ UINT32 queueCnt = 0;
+ UINT32 intSave;
+ LosQueueCB *queueCB = (LosQueueCB *)NULL;
+
+ intSave = LOS_IntLock();
+ queueCB = g_allQueue;
+ for (loop = 0; loop < LOSCFG_BASE_IPC_QUEUE_CONFIG; loop++, queueCB++) {
+ if (queueCB->queueState == OS_QUEUE_INUSED) {
+ queueCnt++;
+ }
+ }
+ (VOID)LOS_IntRestore(intSave);
+ return queueCnt;
+}
+
+UINT32 SwtmrCountGetTest(VOID)
+{
+ UINT32 loop;
+ UINT32 swTmrCnt = 0;
+ UINT32 intSave;
+ SWTMR_CTRL_S *swTmrCB = (SWTMR_CTRL_S *)NULL;
+
+ intSave = LOS_IntLock();
+ swTmrCB = g_swtmrCBArray;
+ for (loop = 0; loop < LOSCFG_BASE_CORE_SWTMR_CONFIG; loop++, swTmrCB++) {
+ if (swTmrCB->ucState != OS_SWTMR_STATUS_UNUSED) {
+ swTmrCnt++;
+ }
+ }
+ (VOID)LOS_IntRestore(intSave);
+ return swTmrCnt;
+}
+#ifdef TEST1980
+VOID TestHwiTrigger(unsigned int irq)
+{
+ int i;
+ HalIrqSendIpi(g_testCpuMask, irq);
+ for (i = 0; i < 0xff; i++) {
+ }
+}
+#else
+void TestHwiTrigger(unsigned int irq)
+{
+ extern void Dsb(void);
+ extern void HalIrqPending(unsigned int vector);
+ extern VOID HalIrqUnmask(unsigned int vector);
+
+ HalIrqUnmask(irq);
+ HalIrqPending(irq);
+ Dsb();
+ Dsb();
+ Dsb();
+}
+#endif
+
+VOID TestExtraTaskDelay(UINT32 tick)
+{
+#if (LOSCFG_KERNEL_SMP == YES)
+ // trigger task schedule may occor on another core
+ // needs adding delay and checking status later
+ LOS_TaskDelay(tick);
+#else
+ // do nothing
+#endif
+}
+
+UINT64 TestTickCountGet(VOID)
+{
+ /* not use LOS_TickCountGet for now,
+ cause every timer is not match with others.
+ use cpu0 timer instead. */
+ return LOS_TickCountGet();
+}
+
+UINT64 TestTickCountByCurrCpuid(VOID)
+{
+ return LOS_TickCountGet();
+}
+
+/*
+ * different from calling LOS_TaskDelay,
+ * this func will not yeild this task to another one.
+ */
+VOID TestBusyTaskDelay(UINT32 tick)
+{
+ UINT64 runtime;
+
+ runtime = TestTickCountByCurrCpuid() + tick;
+ while (1) {
+ if (runtime <= TestTickCountByCurrCpuid()) {
+ break;
+ }
+ Wfi();
+ }
+}
+
+VOID TestAssertBusyTaskDelay(UINT32 timeout, UINT32 flag)
+{
+ UINT64 runtime;
+
+ runtime = TestTickCountGet() + timeout;
+ while (1) {
+ if ((runtime <= TestTickCountGet()) || (g_testCount == flag)) {
+ break;
+ }
+ Wfi();
+ }
+}
+
+VOID TestTestHwiDelete(unsigned int irq, VOID *devId)
+{
+ HwiIrqParam stuwIrqPara;
+
+ if (OS_INT_ACTIVE)
+ return;
+
+ stuwIrqPara.swIrq = irq;
+ stuwIrqPara.pDevId = devId;
+
+ (VOID)LOS_HwiDelete(irq, &stuwIrqPara);
+ return;
+}
+
+VOID TestDumpCpuid(VOID)
+{
+#if (LOSCFG_KERNEL_SMP == YES)
+ PRINT_DEBUG("%d,cpuid = %d\n", LOS_CurTaskIDGet(), ArchCurrCpuid());
+#endif
+ return;
+}
+
+#if defined(LOSCFG_COMPAT_POSIX)
+UINT32 PosixPthreadInit(pthread_attr_t *attr, int pri)
+{
+ UINT32 ret;
+ struct sched_param sp;
+
+ ret = pthread_attr_init(attr);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, NOK);
+
+ attr->inheritsched = PTHREAD_EXPLICIT_SCHED;
+
+ sp.sched_priority = pri;
+ ret = pthread_attr_setschedparam(attr, &sp);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, NOK);
+
+ ret = pthread_attr_setschedpolicy(attr, SCHED_RR);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, NOK);
+
+ return LOS_OK;
+NOK:
+ return LOS_NOK;
+}
+
+UINT32 PosixPthreadDestroy(pthread_attr_t *attr, pthread_t thread)
+{
+ UINT32 ret;
+
+ ret = pthread_join(thread, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, NOK);
+
+ ret = pthread_attr_destroy(attr);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, NOK);
+
+ return LOS_OK;
+NOK:
+ return LOS_NOK;
+}
+#endif
+
+
+VOID TestKernelBaseCore(VOID)
+{
+#if defined(LOSCFG_TEST_KERNEL_BASE_CORE)
+ ItSuiteLosTask();
+ ItSuiteLosSwtmr();
+ ItSuiteSmpHwi();
+ ItSuiteHwiNesting();
+#endif
+}
+
+VOID TestKernelBaseIpc(VOID)
+{
+#if defined(LOSCFG_TEST_KERNEL_BASE_IPC)
+ ItSuiteLosEvent();
+ ItSuiteLosMux();
+ ItSuiteLosSem();
+ ItSuiteLosQueue();
+#endif
+}
+
+VOID TestKernelBase(VOID)
+{
+
+#if defined(LOSCFG_TEST_KERNEL_BASE)
+ TestKernelBaseCore();
+ TestKernelBaseIpc();
+#endif
+}
+
+VOID TestPosixMutex(VOID)
+{
+#if defined(LOSCFG_TEST_POSIX_MUTEX)
+ ItSuitePosixMutex();
+#endif
+}
+
+VOID TestPosixPthread(VOID)
+{
+#if defined(LOSCFG_TEST_POSIX_PTHREAD)
+ ItSuitePosixPthread();
+#endif
+}
+
+VOID TestPosix(VOID)
+{
+#if defined(LOSCFG_TEST_POSIX)
+ TestPosixMutex();
+ TestPosixPthread();
+#endif
+}
+
+VOID TestKernelExtendCpup(VOID)
+{
+#if defined(LOSCFG_TEST_KERNEL_EXTEND_CPUP)
+ ItSuiteExtendCpup();
+#endif
+}
+
+VOID TestKernelExtend(VOID)
+{
+#if defined(LOSCFG_TEST_KERNEL_EXTEND)
+ TestKernelExtendCpup();
+#endif
+}
+
+VOID TestReset(VOID)
+{
+#if defined(TEST3559A) || defined(TEST3559A_M7) || defined(TEST3516EV200) || defined(LOSCFG_LLTREPORT) || \
+ defined(LITEOS_3RDPARTY_THTTPD_TEST) || defined(TESTISP)
+#else
+#ifdef LOSCFG_SHELL
+ extern VOID cmd_reset(VOID);
+ cmd_reset();
+#endif
+#endif
+}
+
+VOID TestTaskEntry(UINT32 param1, UINT32 param2, UINT32 param3, UINT32 param4)
+{
+ UINT32 i;
+
+ INT32 ret = LOS_SetProcessScheduler(LOS_GetCurrProcessID(), LOS_SCHED_RR, 20); // 20, set a reasonable priority.
+ if (ret != LOS_OK) {
+ dprintf("%s set test process schedule failed! %d\n", ret);
+ }
+
+ ret = LOS_SetTaskScheduler(LOS_CurTaskIDGet(), LOS_SCHED_RR, TASK_PRIO_TEST);
+ if (ret != LOS_OK) {
+ dprintf("%s set test task schedule failed! %d\n", ret);
+ }
+
+ g_testCircleCount = 0;
+ dprintf("\t\n --- Test start--- \n");
+
+#if (TEST_LESSER_MEM == YES)
+ UINT32 memusedfirst = 0x600000; // 6M for fs or 3M for kernel
+ LOS_MEM_POOL_STATUS status = { 0 };
+ LOS_MemInfoGet(OS_SYS_MEM_ADDR, &status);
+ LOS_MemAlloc(OS_SYS_MEM_ADDR, status.uwTotalFreeSize - memusedfirst);
+#endif
+
+#if defined(LOSCFG_TEST)
+ for (i = 0; i < 1; i++) {
+ g_testCircleCount++;
+ ICunitInit();
+
+ TestKernelExtend();
+ TestKernelBase();
+ TestPosix();
+
+#if (TEST_MODULE_CHECK == YES) && defined(LOSCFG_TEST)
+ for (int i = 0; i < g_modelNum - 1; i++) {
+ if (g_executModelNum[i] != 0) {
+ dprintf("\nExecuted Model: %s, Executed Model_Num: %d ,failed_count: %d , sucess_count :%d",
+ g_strModule[i], g_executModelNum[i], g_failModelResult[i], g_passModelResult[i]);
+ }
+ for (int j = 0; j < g_failResult && j < 50; j++) { // 50
+ if (i == g_errorCase[j].testcase_module) {
+ LOS_Msleep(200); // 200, delay.
+ dprintf(" \n [Failed]-%s-%s-%s-%s-%s-[Errline: %d RetCode:0x%04X%04X]", g_errorCase[j].pcCaseID,
+ g_strLayer[g_errorCase[j].testcase_layer], g_strModule[g_errorCase[j].testcase_module],
+ g_strLevel[g_errorCase[j].testcase_level], g_strType[g_errorCase[j].testcase_type],
+ g_errorCase[j].errLine, (iUINT16)((g_errorCase[j].retCode) >> 16), // 16
+ (iUINT16)(g_errorCase[j].retCode));
+ }
+ }
+ }
+ dprintf("\nNot Executed Model: ");
+ for (int i = 0; i < g_modelNum - 1; i++) {
+ if (g_executModelNum[i] == 0) {
+ LOS_Msleep(40); // 40, delay.
+ dprintf("%s ", g_strModule[i]);
+ }
+ }
+#endif
+ dprintf("\n\ntest_count: %d,failed count: %d, success count: %d\n", g_testCircleCount, g_failResult,
+ g_passResult);
+ }
+ LOS_Msleep(200); // 200, delay.
+#endif
+ dprintf("\t\n --- Test End--- \n");
+}
+
+void TestSystemInit(void)
+{
+ INT32 pid;
+ LosProcessCB *testProcess = NULL;
+
+ InitRebootHook();
+
+ pid = LOS_Fork(0, "IT_TST_INI", (TSK_ENTRY_FUNC)TestTaskEntry, 0x30000);
+ if (pid < 0) {
+ return;
+ }
+
+ testProcess = OS_PCB_FROM_PID(pid);
+ g_testTskHandle = testProcess->threadGroupID;
+#if (LOSCFG_KERNEL_SMP == YES)
+ ((LosTaskCB *)OS_TCB_FROM_TID(g_testTskHandle))->cpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
+#endif
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/testsuites/kernel/test.mk b/testsuites/kernel/test.mk
new file mode 100644
index 0000000000000000000000000000000000000000..dee9a0a76cd74112ee4243ea7de1210432ac5b7e
--- /dev/null
+++ b/testsuites/kernel/test.mk
@@ -0,0 +1,587 @@
+# 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.
+
+TESTLIB_SUBDIRS += kernel
+LITEOS_BASELIB += -lktest
+
+ifeq ($(LOSCFG_TESTSUIT_SHELL), y)
+LITEOS_CMACRO += -DLITEOS_TESTSUIT_SHELL
+else ifeq ($(LOSCFG_TEST), y)
+LITEOS_CMACRO += -DLITEOS_TEST_AUTO
+else ifeq ($(LOSCFG_TEST_MANUAL_TEST),y)
+LITEOS_CMACRO += -DLOSCFG_TEST_MANUAL_TEST
+endif
+
+
+SRC_MODULES :=
+LLT_MODULES :=
+SMOKE_MODULES :=
+PRESSURE_MODULES :=
+FULL_MODULES :=
+ifeq ($(LOSCFG_TEST_MUTIL), y)
+LITEOS_CMACRO += -DLOSCFG_TEST_MUTIL
+LOSCFG_TEST_MUTIL := y
+endif
+
+ifeq ($(LOSCFG_TEST_KERNEL_BASE), y)
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_BASE
+endif
+
+ifeq ($(LOSCFG_TEST_KERNEL_BASE_IPC), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_base/ipc
+LITEOS_BASELIB += -lipctest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_BASE_IPC
+endif
+
+ifeq ($(LOSCFG_TEST_KERNEL_BASE_CORE), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_base/core
+LITEOS_BASELIB += -lcoretest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_BASE_CORE
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_BASE_MP), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_base/mp
+LITEOS_BASELIB += -lmptest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_BASE_MP
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_BASE_MEM), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_base/mem
+LITEOS_BASELIB += -lmemtest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_BASE_MEM
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_BASE_VM), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_base/vm
+LITEOS_BASELIB += -lvmtest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_BASE_VM
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_BASE_MISC), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_base/misc
+LITEOS_BASELIB += -lmisctest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_BASE_MISC
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_BASE_OM), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_base/om
+LITEOS_BASELIB += -lomtest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_BASE_OM
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_BASE_ATOMIC), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_base/atomic
+LITEOS_BASELIB += -latomictest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_BASE_ATOMIC
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND), y)
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND_CPP), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_extend/cpp
+LITEOS_BASELIB += -lcpptest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND_CPP
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND_CPUP), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_extend/cpup
+LITEOS_BASELIB += -lcpuptest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND_CPUP
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND_EXC), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_extend/exc
+LITEOS_BASELIB += -lexctest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND_EXC
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND_UNALIGNACCESS), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_extend/unalignaccess
+LITEOS_BASELIB += -lunalignaccesstest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND_UNALIGNACCESS
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND_MMU), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_extend/mmu
+LITEOS_BASELIB += -lmmutest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND_MMU
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND_DYNLOAD), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_extend/dynload
+LITEOS_BASELIB += -ldynloadtest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND_DYNLOAD
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND_MPU), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_extend/mpu
+LITEOS_BASELIB += -lmputest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND_MPU
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND_RUNSTOP), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_extend/runstop
+LITEOS_BASELIB += -lrunstoptest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND_RUNSTOP
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND_SCATTER), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_extend/scatter
+LITEOS_BASELIB += -lscattertest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND_SCATTER
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND_TICKLESS), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_extend/tickless
+LITEOS_BASELIB += -lticklesstest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND_TICKLESS
+endif
+ifeq ($(LOSCFG_TEST_KERNEL_EXTEND_TRACE), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_extend/trace
+LITEOS_BASELIB += -ltracetest
+LITEOS_CMACRO += -DLOSCFG_TEST_KERNEL_EXTEND_TRACE
+endif
+
+ifeq ($(LOSCFG_TEST_POSIX), y)
+TESTLIB_SUBDIRS += kernel/sample/posix
+LITEOS_BASELIB += -lposixtest
+LITEOS_CMACRO += -DLOSCFG_TEST_POSIX
+endif
+ifeq ($(LOSCFG_TEST_POSIX_MEM), y)
+TESTLIB_SUBDIRS += kernel/sample/posix/mem
+LITEOS_BASELIB += -lmemtest
+LITEOS_CMACRO += -DLOSCFG_TEST_POSIX_MEM
+endif
+ifeq ($(LOSCFG_TEST_POSIX_MQUEUE), y)
+TESTLIB_SUBDIRS += kernel/sample/posix/mqueue
+LITEOS_BASELIB += -lmqueuetest
+LITEOS_CMACRO += -DLOSCFG_TEST_POSIX_MQUEUE
+endif
+ifeq ($(LOSCFG_TEST_POSIX_MUTEX), y)
+TESTLIB_SUBDIRS += kernel/sample/posix/mutex
+LITEOS_BASELIB += -lmutextest
+LITEOS_CMACRO += -DLOSCFG_TEST_POSIX_MUTEX
+endif
+ifeq ($(LOSCFG_TEST_POSIX_PTHREAD), y)
+TESTLIB_SUBDIRS += kernel/sample/posix/pthread
+LITEOS_BASELIB += -lpthreadtest
+LITEOS_CMACRO += -DLOSCFG_TEST_POSIX_PTHREAD
+endif
+ifeq ($(LOSCFG_TEST_POSIX_SCHED), y)
+TESTLIB_SUBDIRS += kernel/sample/posix/sched
+LITEOS_BASELIB += -lschedtest
+LITEOS_CMACRO += -DLOSCFG_TEST_POSIX_SCHED
+endif
+ifeq ($(LOSCFG_TEST_POSIX_SEM), y)
+TESTLIB_SUBDIRS += kernel/sample/posix/sem
+LITEOS_BASELIB += -lsemtest
+LITEOS_CMACRO += -DLOSCFG_TEST_POSIX_SEM
+endif
+ifeq ($(LOSCFG_TEST_POSIX_SWTMR), y)
+TESTLIB_SUBDIRS += kernel/sample/posix/swtmr
+LITEOS_BASELIB += -lswtmrtest
+LITEOS_CMACRO += -DLOSCFG_TEST_POSIX_SWTMR
+endif
+ifeq ($(LOSCFG_TEST_LINUX), y)
+TESTLIB_SUBDIRS += kernel/sample/linux
+LITEOS_BASELIB += -llinuxtest
+LITEOS_CMACRO += -DLOSCFG_TEST_LINUX
+endif
+ifeq ($(LOSCFG_TEST_LINUX_HRTIMER), y)
+TESTLIB_SUBDIRS += kernel/sample/linux/hrtimer
+LITEOS_BASELIB += -lhrtimertest
+LITEOS_CMACRO += -DLOSCFG_TEST_LINUX
+endif
+
+ifeq ($(LOSCFG_TEST_FS), y)
+LITEOS_CMACRO += -DLOSCFG_TEST_FS
+endif
+
+ifeq ($(LOSCFG_TEST_FS_VFS), y)
+TESTLIB_SUBDIRS += kernel/sample/fs/vfs
+LITEOS_BASELIB += -lvfstest
+LITEOS_CMACRO += -DLOSCFG_TEST_FS_VFS
+endif
+
+ifeq ($(LOSCFG_TEST_FS_JFFS), y)
+TESTLIB_SUBDIRS += kernel/sample/fs/jffs
+LITEOS_BASELIB += -ljffstest
+LITEOS_CMACRO += -DLOSCFG_TEST_FS_JFFS
+endif
+
+ifeq ($(LOSCFG_TEST_FS_FAT), y)
+TESTLIB_SUBDIRS += kernel/sample/fs/vfat
+LITEOS_BASELIB += -lvfattest
+LITEOS_CMACRO += -DLOSCFG_TEST_FS_FAT
+endif
+
+ifeq ($(LOSCFG_TEST_FS_FAT_FAT32), y)
+LITEOS_CMACRO += -DLOSCFG_TEST_FS_FAT_FAT32
+endif
+
+ifeq ($(LOSCFG_TEST_FAT32_FSCK), y)
+LITEOS_CMACRO += -DLOSCFG_TEST_FAT32_FSCK
+endif
+
+ifeq ($(LOSCFG_TEST_FS_VIRPART), y)
+TESTLIB_SUBDIRS += kernel/sample/fs/virpart
+LITEOS_BASELIB += -lvirparttest
+LITEOS_CMACRO += -DLOSCFG_TEST_FS_VIRPART
+endif
+
+ifeq ($(LOSCFG_TEST_FS_NFS), y)
+TESTLIB_SUBDIRS += kernel/sample/fs/nfs
+LITEOS_BASELIB += -lnfstest
+LITEOS_CMACRO += -DLOSCFG_TEST_FS_NFS
+endif
+
+ifeq ($(LOSCFG_TEST_FS_PROC), y)
+TESTLIB_SUBDIRS += kernel/sample/fs/proc
+LITEOS_BASELIB += -lproctest
+LITEOS_CMACRO += -DLOSCFG_TEST_FS_PROC
+endif
+
+ifeq ($(LOSCFG_TEST_FS_RAMFS), y)
+TESTLIB_SUBDIRS += kernel/sample/fs/ramfs
+LITEOS_BASELIB += -lramfstest
+LITEOS_CMACRO += -DLOSCFG_TEST_FS_RAMFS
+endif
+
+ifeq ($(LOSCFG_TEST_MTD_JFFS), y)
+TESTLIB_SUBDIRS += kernel/sample/mtd/spinor/
+LITEOS_BASELIB += -lspinortest
+LITEOS_CMACRO += -DLOSCFG_TEST_MTD_JFFS
+endif
+
+ifeq ($(LOSCFG_TEST_MTD_FAT), y)
+TESTLIB_SUBDIRS += kernel/sample/mtd/fat
+LITEOS_BASELIB += -lfattest
+LITEOS_CMACRO += -DLOSCFG_TEST_MTD_FAT
+endif
+
+ifeq ($(LOSCFG_TEST_MTD_DISK), y)
+TESTLIB_SUBDIRS += kernel/sample/mtd/disk
+LITEOS_BASELIB += -ldisktest
+LITEOS_CMACRO += -DLOSCFG_TEST_MTD_DISK
+endif
+
+ifeq ($(LOSCFG_TEST_MTD_FAT_VIRPART), y)
+TESTLIB_SUBDIRS += kernel/sample/mtd/dvirpart
+LITEOS_BASELIB += -ldvirparttest
+LITEOS_CMACRO += -DLOSCFG_TEST_MTD_FAT_VIRPART
+endif
+
+ifeq ($(LOSCFG_TEST_DRIVERBASE), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/base
+TESTLIB_SUBDIRS += kernel/sample/drivers/regulator
+TESTLIB_SUBDIRS += kernel/sample/drivers/cpufreq
+TESTLIB_SUBDIRS += kernel/sample/drivers/devfreq
+LITEOS_BASELIB += -lbasetest -lregulatortest -lcpufreqtest -ldevfreqtest
+LITEOS_CMACRO += -DLOSCFG_TEST_DRIVER_BASE
+endif
+
+ifeq ($(LOSCFG_TEST_LIBC), y)
+TESTLIB_SUBDIRS += kernel/sample/libc
+LITEOS_BASELIB += -llibctest
+LITEOS_CMACRO += -DLOSCFG_TEST_LIBC
+endif
+
+ifeq ($(LOSCFG_TEST_LIBM), y)
+TESTLIB_SUBDIRS += kernel/sample/libm
+LITEOS_BASELIB += -llibmtest
+LITEOS_CMACRO += -DLOSCFG_TEST_LIBM
+endif
+
+ifeq ($(LOSCFG_TEST_SHELL), y)
+TESTLIB_SUBDIRS += kernel/sample/shell
+LITEOS_BASELIB += -lshelltest
+LITEOS_CMACRO += -DLOSCFG_TEST_SHELL
+endif
+
+ifeq ($(LOSCFG_TEST_HOST_MASS_DEVICE), y)
+TESTLIB_SUBDIRS += kernel/sample/performance/usb
+LITEOS_BASELIB += -lusbtest
+LITEOS_CMACRO += -DLOSCFG_TEST_HOST_MASS_DEVICE
+endif
+
+ifeq ($(LOSCFG_TEST_MMC), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/mmc
+LITEOS_BASELIB += -lmmctest
+endif
+
+ifeq ($(LOSCFG_TEST_AUTO_USB), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/auto
+LITEOS_BASELIB += -lautotest
+endif
+
+ifeq ($(LOSCFG_TEST_DEVICE_MASS_GADGET), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/storage
+LITEOS_BASELIB += -lstoragetest
+LITEOS_CMACRO += -DLOSCFG_TEST_DEVICE_MASS_GADGET
+endif
+
+ifeq ($(LOSCFG_TEST_UVC_GADGET), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/uvc
+LITEOS_BASELIB += -luvctest
+LITEOS_CMACRO += -DLOSCFG_TEST_UVC_GADGET
+endif
+
+ifeq ($(LOSCFG_TEST_SMP_USB), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/usbsmp
+LITEOS_BASELIB += -lusbsmptest
+LITEOS_CMACRO += -DLOSCFG_TEST_SMP_USB
+endif
+
+ifeq ($(LOSCFG_TEST_UAC_GADGET), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/uac
+LITEOS_BASELIB += -luactest
+LITEOS_CMACRO += -DLOSCFG_TEST_UAC_GADGET
+endif
+
+ifeq ($(LOSCFG_TEST_CAMERA_GADGET), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/camera
+LITEOS_BASELIB += -lcameratest
+LITEOS_CMACRO += -DLOSCFG_TEST_CAMERA_GADGET
+endif
+
+ifeq ($(LOSCFG_TEST_HID_GADGET), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/hid
+LITEOS_BASELIB += -lhidtest
+LITEOS_CMACRO += -DLOSCFG_TEST_HID_GADGET
+endif
+
+ifeq ($(LOSCFG_TEST_HUB_GADGET), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/hub
+LITEOS_BASELIB += -lhubtest
+LITEOS_CMACRO += -DLOSCFG_TEST_HUB_GADGET
+endif
+
+ifeq ($(LOSCFG_TEST_SERIAL_GADGET), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/serial
+LITEOS_BASELIB += -lserialtest
+LITEOS_CMACRO += -DLOSCFG_TEST_SERIAL_GADGET
+endif
+
+ifeq ($(LOSCFG_TEST_DFU_GADGET), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/dfu
+LITEOS_BASELIB += -ldfutest
+LITEOS_CMACRO += -DLOSCFG_TEST_DFU_GADGET
+endif
+
+ifeq ($(LOSCFG_TEST_MUTILDEVICE_GADGET), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/multidevice
+LITEOS_BASELIB += -lmultidevicetest
+LITEOS_CMACRO += -DLOSCFG_TEST_MUTILDEVICE_GADGET
+endif
+
+ifeq ($(LOSCFG_DRIVERS_USB_ETHERNET_GADGET), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/rndis
+LITEOS_BASELIB += -lrndistest
+LITEOS_CMACRO += -DLOSCFG_DRIVERS_USB_ETHERNET_GADGET
+endif
+
+ifeq ($(LOSCFG_DRIVERS_USB_HOST_UVC), y)
+TESTLIB_SUBDIRS += kernel/sample/drivers/usb/video
+LITEOS_BASELIB += -lvideotest
+LITEOS_CMACRO += -DLOSCFG_DRIVERS_USB_HOST_UVC
+endif
+
+ifeq ($(LOSCFG_TEST_PERFORMANCE), y)
+TESTLIB_SUBDIRS += kernel/sample/performance/kernel
+LITEOS_BASELIB += -lperformancetest
+LITEOS_CMACRO += -DLOSCFG_TEST_PERFORMANCE
+ifeq ($(LOSCFG_TEST_PERFORMANCE_CORE), y)
+LITEOS_CMACRO += -DLOSCFG_TEST_PERFORMANCE_CORE
+endif
+ifeq ($(LOSCFG_TEST_PERFORMANCE_MEM), y)
+LITEOS_CMACRO += -DLOSCFG_TEST_PERFORMANCE_MEM
+endif
+ifeq ($(LOSCFG_TEST_PERFORMANCE_FS), y)
+LITEOS_CMACRO += -DLOSCFG_TEST_PERFORMANCE_FS
+endif
+ifeq ($(LOSCFG_TEST_PERFORMANCE_USB), y)
+LITEOS_CMACRO += -DLOSCFG_TEST_PERFORMANCE_USB
+endif
+ifeq ($(LOSCFG_TEST_PERFORMANCE_NET), y)
+LITEOS_CMACRO += -DLOSCFG_TEST_PERFORMANCE_NET
+endif
+endif
+
+ifeq ($(LOSCFG_TEST_NET), y)
+ LITEOS_CMACRO += -DTEST_NET
+ ifeq ($(LOSCFG_PLATFORM_HI3559)$(LOSCFG_ARCH_CORTEX_A17), yy)
+ LITEOS_BASELIB += -lipcm -lipcm_net
+ endif
+ LITEOS_BASELIB += -lnettest
+ TESTLIB_SUBDIRS += kernel/sample/net
+endif
+
+ifeq ($(LOSCFG_TEST_LWIP), y)
+ LITEOS_CMACRO += -DTEST_LWIP
+ LITEOS_BASELIB += -llwiptest
+ifeq ($(LOSCFG_NET_LWIP_SACK_2_0), y)
+ TESTLIB_SUBDIRS += kernel/sample/lwip-2.0
+else
+ TESTLIB_SUBDIRS += kernel/sample/lwip
+endif
+endif
+
+ifeq ($(LOSCFG_TEST_PLATFORM), y)
+TESTLIB_SUBDIRS += kernel/sample/platform
+LITEOS_BASELIB += -lplatformtest
+LITEOS_CMACRO += -DLOSCFG_TEST_PLATFORM
+endif
+
+ifeq ($(LOSCFG_FUZZ_DT), y)
+TESTLIB_SUBDIRS += kernel/sample/fuzz
+LITEOS_BASELIB += -lfuzzDTtest
+LITEOS_CMACRO += -DLOSCFG_FUZZ_DT
+endif
+
+ifeq ($(LOSCFG_TEST_MANUAL_TEST), y)
+TESTLIB_SUBDIRS += kernel/sample/kernel_base/ipc
+LITEOS_BASELIB += -lipctest
+LITEOS_CMACRO += -DLOSCFG_TEST_MANUAL_TEST
+endif
+
+ifeq ($(LOSCFG_3RDPARTY_TEST), y)
+ LITEOS_CMACRO += -DLOSCFG_3RDPARTY_TEST
+ ifeq ($(LOSCFG_3RDPARTY_TINYXML), y)
+ LITEOS_BASELIB += -ltinyxmltest
+ LITEOS_CMACRO += -DLOSCFG_3RDPARTY_TINYXML_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/tinyxml
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_INIPARSER), y)
+ LITEOS_BASELIB += -liniparsertest
+ LITEOS_CMACRO += -DLOSCFG_3RDPARTY_INIPARSER_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/iniparser
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_CJSON), y)
+ LITEOS_BASELIB += -lcJSONtest
+ LITEOS_CMACRO += -DLOSCFG_3RDPARTY_CJSON_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/cJSON
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_ICONV), y)
+ LITEOS_BASELIB += -liconvtest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_ICONV_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/iconv
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_OPENSSL), y)
+ LITEOS_BASELIB += -lopenssltest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_OPENSSL_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/openssl
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_OPUS), y)
+ LITEOS_BASELIB += -lopustest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_OPUS_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/opus
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_BIDIREFC), y)
+ LITEOS_BASELIB += -lbidirefctest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_BIDIREFC_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/bidirefc
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_FREETYPE), y)
+ LITEOS_BASELIB += -lfreetypetest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_FREETYPE_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/freetype
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_JSONCPP), y)
+ LITEOS_BASELIB += -ljsoncpptest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_JSONCPP_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/jsoncpp
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_THTTPD), y)
+ LITEOS_BASELIB += -lthttpdtest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_THTTPD_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/thttpd
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_SQLITE), y)
+ LITEOS_BASELIB += -lsqlitetest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_SQLITE_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/sqlite
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_FFMPEG), y)
+ LITEOS_BASELIB += -lffmpegtest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_FFMPEG_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/ffmpeg
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_LUA), y)
+ LITEOS_BASELIB += -lluatest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_LUA_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/lua
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_DIRECTFB), y)
+ LITEOS_BASELIB += -ldirectfbtest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_DIRECTFB_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/directfb
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_JPEG), y)
+ LITEOS_BASELIB += -ljpegtest
+ LITEOS_CMACRO += -DLOSCFG_3RDPARTY_JPEG_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/jpeg
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_PNG), y)
+ LITEOS_BASELIB += -lpngtest
+ LITEOS_CMACRO += -DLOSCFG_3RDPARTY_PNG_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/png
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_OPENEXIFJPEG), y)
+ LITEOS_BASELIB += -lOpenExifJpegtest
+ LITEOS_CMACRO += -DLOSCFG_3RDPARTY_OPENEXIFJPEG_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/OpenExifJpeg
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_XML2), y)
+ LITEOS_BASELIB += -lxml2test
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_XML2_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/xml2
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_ZBAR), y)
+ LITEOS_BASELIB += -lzbartest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_ZBAR_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/zbar
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_HARFBUZZ), y)
+ LITEOS_BASELIB += -lharfbuzztest
+ LITEOS_CMACRO += -DLOSCFG_3RDPARTY_HARFBUZZ_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/harfbuzz
+ endif
+
+ ifeq ($(LOSCFG_3RDPARTY_CURL), y)
+ LITEOS_LD_OPTS += -ucurl_shellcmd
+ LITEOS_BASELIB += -lcurltest
+ LITEOS_CMACRO += -DLITEOS_3RDPARTY_CURL_TEST
+ TESTLIB_SUBDIRS += kernel/sample/3rdParty/curl
+ endif
+endif
+
diff --git a/testsuites/unittest/BUILD.gn b/testsuites/unittest/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..1a2b7efde67443d560c06535a4558593cea0a041
--- /dev/null
+++ b/testsuites/unittest/BUILD.gn
@@ -0,0 +1,161 @@
+# 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.
+
+import("config.gni")
+
+local_flags = []
+if (board_name == "hispark_taurus") {
+ local_flags += [ "-DLOSCFG_USER_TEST_SMP" ]
+}
+if (LOSCFG_USER_TEST_SMOKE == true) {
+ local_flags += [ "-DLOSCFG_USER_TEST_SMOKE" ]
+}
+if (LOSCFG_USER_TEST_FULL == true) {
+ local_flags += [ "-DLOSCFG_USER_TEST_FULL" ]
+}
+if (LOSCFG_USER_TEST_PRESSURE == true) {
+ local_flags += [ "-DLOSCFG_USER_TEST_PRESSURE" ]
+}
+if (LOSCFG_USER_TEST_LLT == true) {
+ local_flags += [ "-DLOSCFG_USER_TEST_LLT" ]
+}
+
+config("public_config") {
+ cflags = [ "-fpermissive" ]
+ cflags += [
+ "-O2",
+ "-fbuiltin",
+ "-Wno-narrowing",
+ ]
+ cflags += local_flags
+ cflags_cc = cflags
+}
+
+group("unittest") {
+ deps = []
+ if (LOSCFG_USER_TEST_UTIL == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "util:liteos_a_util_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_TIME_TIMER == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "time/timer:liteos_a_time_timer_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_TIME_CLOCK == true &&
+ (LOSCFG_USER_TEST_SMOKE == true || LOSCFG_USER_TEST_FULL == true)) {
+ deps += [ "time/clock:liteos_a_time_clock_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_SYS == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "sys:liteos_a_sys_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_SIGNAL == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "signal:liteos_a_signal_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_SECURITY_REUGID == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "security/reugid:liteos_a_security_reugid_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_SECURITY_CAPABILITY == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "security/capability:liteos_a_security_capability_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_SECURITY_VID == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "security/vid:liteos_a_security_vid_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_MUTEX == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "process/mutex:liteos_a_mutex_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_PROCESS == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "process/process:liteos_a_process_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_PTHREAD == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "process/pthread:liteos_a_pthread_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_RWLOCK == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "process/rwlock:liteos_a_rwlock_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_SPINLOCK == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "process/spinlock:liteos_a_spinlock_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_POSIX_MEM == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "posix/mem:liteos_a_posix_mem_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_POSIX_MQUEUE == true &&
+ (LOSCFG_USER_TEST_SMOKE == true || LOSCFG_USER_TEST_FULL == true)) {
+ deps += [ "posix/mqueue:liteos_a_posix_mqueue_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_POSIX_PTHREAD == true &&
+ (LOSCFG_USER_TEST_SMOKE == true || LOSCFG_USER_TEST_FULL == true)) {
+ deps += [ "posix/pthread:liteos_a_posix_pthread_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_MISC == true &&
+ (LOSCFG_USER_TEST_SMOKE == true || LOSCFG_USER_TEST_FULL == true)) {
+ deps += [ "misc:liteos_a_misc_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_MEM_SHM == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "mem/shm:liteos_a_mem_shm_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_MEM_VM == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "mem/vm:liteos_a_mem_vm_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_IO == true && LOSCFG_USER_TEST_FULL == true) {
+ deps += [ "IO:liteos_a_io_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_EXC == true && LOSCFG_USER_TEST_FULL == true) {
+ deps += [ "exc:liteos_a_exc_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_DYNLOAD == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "dynload:liteos_a_dynload_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_DRIVERS_HID == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "drivers/hid:liteos_a_drivers_hid_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_DRIVERS_STORAGE == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "drivers/storage:liteos_a_drivers_storage_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_NET_NETDB == true && LOSCFG_USER_TEST_FULL == true) {
+ deps += [ "net/netdb:liteos_a_net_netdb_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_NET_RESOLV == true && LOSCFG_USER_TEST_FULL == true) {
+ deps += [ "net/resolv:liteos_a_net_resolv_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_NET_SOCKET == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "net/socket:liteos_a_net_socket_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_IPC == true && LOSCFG_USER_TEST_FULL == true) {
+ deps += [ "IPC:liteos_a_ipc_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_LITEIPC == true && LOSCFG_USER_TEST_SMOKE == true) {
+ deps += [ "liteipc:liteos_a_liteipc_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_FS_JFFS == true &&
+ (LOSCFG_USER_TEST_SMOKE == true || LOSCFG_USER_TEST_FULL == true || LOSCFG_USER_TEST_PRESSURE == true)) {
+ deps += [ "fs:liteos_a_fs_unittest" ]
+ }
+ if (LOSCFG_USER_TEST_FS_VFAT == true &&
+ (LOSCFG_USER_TEST_SMOKE == true || LOSCFG_USER_TEST_FULL == true || LOSCFG_USER_TEST_PRESSURE == true)) {
+ deps += [ "fs/vfat2:liteos_a_fs_vfat_unittest" ]
+ }
+}
diff --git a/testsuites/unittest/IO/BUILD.gn b/testsuites/unittest/IO/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..1eae54fe4feb51065ec43e804ed9a7e93606c2b5
--- /dev/null
+++ b/testsuites/unittest/IO/BUILD.gn
@@ -0,0 +1,89 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../config.gni")
+
+unittest("liteos_a_io_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../common/include",
+ "../IO",
+ ]
+ sources = [
+ "../common/osTest.cpp",
+ "io_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_FULL == true) {
+ sources_full = [
+ "full/IO_test_005.cpp",
+ "full/IO_test_008.cpp",
+ "full/IO_test_010.cpp",
+ "full/IO_test_013.cpp",
+ "full/IO_test_confstr_001.cpp",
+ "full/IO_test_dcgettext_001.cpp",
+ "full/IO_test_dcgettext_002.cpp",
+ "full/IO_test_dcngettext_001.cpp",
+ "full/IO_test_dcngettext_002.cpp",
+ "full/IO_test_dngettext_001.cpp",
+ "full/IO_test_dngettext_002.cpp",
+ "full/IO_test_duplocale_001.cpp",
+ "full/IO_test_locale_001.cpp",
+ "full/IO_test_locale_002.cpp",
+ "full/IO_test_ngettext_001.cpp",
+ "full/IO_test_nl_langinfo_001.cpp",
+ "full/IO_test_nl_langinfo_l_001.cpp",
+ "full/IO_test_strcasecmp_l_001.cpp",
+ "full/IO_test_strcasecmp_l_002.cpp",
+ "full/IO_test_strfmon_l_001.cpp",
+ "full/IO_test_strfmon_l_002.cpp",
+ "full/It_locale_localeconv_001.cpp",
+ "full/It_stdio_fputws_001.cpp",
+ "full/It_stdio_fwprintf_001.cpp",
+ "full/It_stdio_getc_unlocked_001.cpp",
+ "full/It_stdio_hasmntopt_001.cpp",
+ "full/It_stdio_mblen_001.cpp",
+ "full/It_stdio_mbrlen_001.cpp",
+ "full/It_stdio_putwc_001.cpp",
+ "full/It_stdio_readv_001.cpp",
+ "full/It_stdio_rindex_001.cpp",
+ "full/It_stdio_setlogmask_001.cpp",
+ "full/It_stdlib_gcvt_001.cpp",
+ "full/It_stdlib_poll_002.cpp",
+ "full/It_stdlib_poll_003.cpp",
+ "full/IO_test_gettext_001.cpp",
+ "full/IO_test_strncasecmp_l_001.cpp",
+ "full/IO_test_strncasecmp_l_002.cpp",
+ ]
+ sources += sources_full
+ }
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+ configs = [ "..:public_config" ]
+}
diff --git a/testsuites/unittest/IO/It_test_IO.h b/testsuites/unittest/IO/It_test_IO.h
new file mode 100644
index 0000000000000000000000000000000000000000..4e582afe63694004771df105044e1526c7844d85
--- /dev/null
+++ b/testsuites/unittest/IO/It_test_IO.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _IT_TEST_IO_H
+#define _IT_TEST_IO_H
+
+#include "osTest.h"
+#include "stdio.h"
+#include "stdlib.h"
+#include "unistd.h"
+#include "string.h"
+#include "termios.h"
+#include "sys/types.h"
+#include "sys/stat.h"
+#include "fcntl.h"
+#include "locale.h"
+#include "wctype.h"
+#include "wchar.h"
+#include "stdarg.h"
+#include "semaphore.h"
+#include "ftw.h"
+#include "aio.h"
+#include "shadow.h"
+#include "pty.h"
+#include "dirent.h"
+#include "poll.h"
+#include "grp.h"
+#include "pwd.h"
+#include "sys/uio.h"
+#include "syslog.h"
+
+extern int CloseRmAllFile(int fd[], char filePathName[][50], int cnt);
+extern char *g_ioTestPath;
+
+extern VOID ItTestIo001(VOID);
+extern VOID ItTestIo002(VOID);
+extern VOID ItTestIo003(VOID);
+extern VOID ItTestIo004(VOID);
+extern VOID ItTestIo005(VOID);
+extern VOID ItTestIo006(VOID);
+extern VOID ItTestIo007(VOID);
+extern VOID ItTestIo008(VOID);
+extern VOID ItTestIo009(VOID);
+extern VOID ItTestIo010(VOID);
+extern VOID ItTestIo011(VOID);
+extern VOID ItTestIo012(VOID);
+extern VOID ItTestIo013(VOID);
+
+extern VOID ItLocaleFreelocale001(void);
+extern VOID ItLocaleLocaleconv001(void);
+extern VOID ItStdioFputws001(void);
+extern VOID ItStdioFwprintf001(void);
+extern VOID ItStdioFtruncate001(void);
+extern VOID ItStdioFtw001(void);
+extern VOID ItStdlibOpenpty001(void);
+extern VOID ItStdlibPtsname001(void);
+extern VOID ItStdioGetcUnlocked001(void);
+extern VOID ItStdioGetcharUnlocked001(void);
+extern VOID ItStdioGetw001(void);
+extern VOID ItStdioGetwchar001(void);
+extern VOID ItStdioLioListio001(void); // linux erro
+extern VOID ItStdioMblen001(void);
+extern VOID ItStdioMbrlen001(void);
+extern VOID ItStdioMbstowcs001(void);
+extern VOID ItStdioMbsnrtowcs001(void);
+extern VOID ItStdioPutcUnlocked001(void);
+extern VOID ItStdioPutcharUnlocked001(void);
+extern VOID ItStdioPutgrent001(void);
+extern VOID ItStdioPutpwent001(void);
+extern VOID ItStdioPutspent001(void);
+extern VOID ItStdioPutwc001(void);
+extern VOID ItStdioPutwchar001(void);
+extern VOID ItStdioReadv001(void);
+extern VOID ItStdioRindex001(void);
+extern VOID ItStdioSelect002(void);
+extern VOID ItStdioSetgrent001(void);
+extern VOID ItStdioSetlogmask001(void);
+extern VOID ItStdioSetmntent001(void);
+extern VOID ItStdlibGcvt001(void);
+extern VOID ItStdlibOpenpty001(void);
+extern VOID ItStdlibPoll001(void);
+extern VOID ItStdlibPoll002(void);
+extern VOID ItStdlibPoll003(void);
+extern VOID ItStdlibPtsname001(void);
+extern VOID IT_STDIO_HASMNTOPT_001(void);
+extern VOID IO_TEST_NGETTEXT_001(void);
+extern VOID IO_TEST_EPOLL_001(void);
+extern VOID IO_TEST_LOCALE_001(void);
+extern VOID IO_TEST_LOCALE_002(void);
+extern VOID IO_TEST_CONFSTR_001(void);
+extern VOID IO_TEST_NL_LANGINFO_001(VOID);
+extern VOID IO_TEST_STRCASECMP_L_001(VOID);
+extern VOID IO_TEST_STRCASECMP_L_002(VOID);
+extern VOID IO_TEST_DUPLOCALE_001(void);
+extern VOID IO_TEST_NL_LANGINFO_l_001(VOID);
+extern VOID IO_TEST_DNGETTEXT_001(VOID);
+extern VOID IO_TEST_DNGETTEXT_002(VOID);
+extern VOID IO_TEST_DCNGETTEXT_001(VOID);
+extern VOID IO_TEST_DCNGETTEXT_002(VOID);
+extern VOID IO_TEST_DCGETTEXT_001(VOID);
+extern VOID IO_TEST_DCGETTEXT_002(VOID);
+extern VOID IO_TEST_GETTEXT_001(VOID);
+extern VOID IO_TEST_PPOLL_001(void);
+extern VOID IO_TEST_PPOLL_002(void);
+extern VOID IO_TEST_PSELECT_001(void);
+extern VOID IO_TEST_STRFMON_L_001(VOID);
+extern VOID IO_TEST_STRFMON_L_002(VOID);
+
+
+#endif
diff --git a/testsuites/unittest/IO/full/IO_test_005.cpp b/testsuites/unittest/IO/full/IO_test_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9ba58578e0674fc9f2fe41a0f737e72a21406d26
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_005.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 i = 0;
+ wchar_t str[] = L"ABCDEFG";
+ wchar_t str2[] = L"abcdefg";
+ wchar_t c[20];
+
+ wctype_t check = wctype("upper");
+ wctrans_t trans = wctrans("tolower");
+
+ while (str[i]) {
+ c[i] = str[i];
+ if (iswctype(c[i], check)) {
+ c[i] = towctrans(c[i], trans);
+ }
+ if (c[i] != str2[i]) {
+ goto EXIT;
+ }
+ i++;
+ }
+
+ return 0;
+EXIT:
+ return -1;
+}
+
+
+VOID ItTestIo005(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_008.cpp b/testsuites/unittest/IO/full/IO_test_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ed785892cca6074e523de43b01644eb6c9b96a67
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_008.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+static INT32 Vdpfunc(int fd, char *format, ...)
+{
+ va_list aptr;
+ INT32 ret;
+
+ va_start(aptr, format);
+ ret = vdprintf(fd, format, aptr);
+ va_end(aptr);
+
+ return ret;
+}
+
+static UINT32 Testcase(VOID)
+{
+ CHAR file[30] = "/jffs0/vdprintf";
+ CHAR *str1 = "123456789";
+ CHAR buffer[20];
+ INT32 ret, fd;
+ CHAR str[20] = "789";
+ const int testBufLen = 20;
+
+ fd = open(file, O_CREAT | O_RDWR | O_TRUNC);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ ret = Vdpfunc(fd, "%s%s", "123456", str);
+ if (ret < 0) {
+ goto EXIT1;
+ }
+
+ ret = close(fd);
+
+ fd = open(file, O_RDWR);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ read(fd, buffer, testBufLen);
+ close(fd);
+
+ ICUNIT_GOTO_STRING_EQUAL(buffer, str1, buffer, EXIT2);
+
+ unlink(file);
+ return (0);
+EXIT1:
+ close(fd);
+EXIT2:
+ unlink(file);
+EXIT:
+ return -1;
+}
+
+VOID ItTestIo008(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_010.cpp b/testsuites/unittest/IO/full/IO_test_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b9189fafb27f3907d22621e6755eaa622eaa4c3c
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_010.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+
+static VOID GetWideMatches(const wchar_t *str, const wchar_t *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ vswscanf(str, format, args);
+ va_end(args);
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 val, ret;
+ wchar_t buf[100]; // 100, buffer size
+ wchar_t *str = L"bottles";
+
+ GetWideMatches(L"99 bottles of beer on the wall", L" %d %ls ", &val, buf);
+ ret = wcscmp(buf, str);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return 0;
+EXIT:
+ return -1;
+}
+
+VOID ItTestIo010(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_013.cpp b/testsuites/unittest/IO/full/IO_test_013.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9b2763c48cd5a6acc5db14d7e323c8e37c2117e0
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_013.cpp
@@ -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.
+ */
+#include "It_test_IO.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 val, ret, result;
+ wchar_t buf[200];
+ wchar_t *str = L"helloworld";
+
+ swscanf(str, L"%ls", buf);
+
+ ret = wcscmp(buf, str);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return 0;
+EXIT:
+ return -1;
+}
+
+VOID ItTestIo013(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_confstr_001.cpp b/testsuites/unittest/IO/full/IO_test_confstr_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ee364b4c33d793ad06a6db7883ca237564837225
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_confstr_001.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+static UINT32 testcase(VOID)
+{
+ char *pathbuf = nullptr;
+ char *gun_libpthread_version_buf = nullptr;
+ char *gun_libc_version_buf = nullptr;
+ size_t n = 0;
+
+ n = confstr(_CS_PATH, NULL, (size_t) 0);
+ ICUNIT_ASSERT_WITHIN_EQUAL(n, 0, UINT_MAX, n);
+ pathbuf = (char *)malloc(n);
+ if (pathbuf == NULL) {
+ return LOS_NOK;
+ }
+ confstr(_CS_PATH, pathbuf, n);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(pathbuf, NULL, -1);
+ free(pathbuf);
+ pathbuf = NULL;
+
+ n = confstr(_CS_GNU_LIBPTHREAD_VERSION, NULL, (size_t) 0);
+ ICUNIT_ASSERT_WITHIN_EQUAL(n, 0, UINT_MAX, n);
+ if (n > 0) {
+ gun_libpthread_version_buf = (char *)malloc(n);
+ }
+ if (gun_libpthread_version_buf == NULL) {
+ return LOS_NOK;
+ }
+ confstr(_CS_GNU_LIBPTHREAD_VERSION, gun_libpthread_version_buf, n);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(gun_libpthread_version_buf, NULL, -1);
+ free(gun_libpthread_version_buf);
+ gun_libpthread_version_buf = NULL;
+
+ n = confstr(_CS_GNU_LIBC_VERSION, NULL, (size_t) 0);
+ ICUNIT_ASSERT_WITHIN_EQUAL(n, 0, UINT_MAX, n);
+ if (n > 0) {
+ gun_libc_version_buf = (char *)malloc(n);
+ }
+ if (gun_libc_version_buf == NULL) {
+ return LOS_NOK;
+ }
+ confstr(_CS_GNU_LIBC_VERSION, gun_libc_version_buf, n);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(gun_libc_version_buf, NULL, -1);
+ free(gun_libc_version_buf);
+ gun_libc_version_buf = NULL;
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_CONFSTR_001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_dcgettext_001.cpp b/testsuites/unittest/IO/full/IO_test_dcgettext_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e51a27adb7b1b06724238ff77f781433ac77dc36
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_dcgettext_001.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase(VOID)
+{
+ char *s = "";
+
+ setlocale(LC_ALL, "");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ printf(dcgettext("www.huawei.com", "TestString1\n", LC_MESSAGES));
+
+ s = dcgettext("www.huawei.com", "TestString1\n", LC_MESSAGES);
+ printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1\n", s);
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_DCGETTEXT_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_dcgettext_002.cpp b/testsuites/unittest/IO/full/IO_test_dcgettext_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8ffb46b85b44fd8582a6943ee554bea3343b2994
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_dcgettext_002.cpp
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase1(VOID)
+{
+ char *s = "";
+
+ setlocale(LC_ALL, "");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ errno = 0;
+ s = dcgettext("www.huawei.com", "TestString1\n", LC_MESSAGES);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_GOTO_STRING_EQUAL(s, "TestString1\n", -1, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase2(VOID)
+{
+ char *s = "";
+
+ setlocale(LC_ALL, "");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ errno = 0;
+ s = dcgettext(nullptr, "Hello World!\n", LC_MESSAGES);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_GOTO_STRING_EQUAL(s, "Hello World!\n", -1, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase3(VOID)
+{
+ char *s = "";
+ char *domain = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\
+1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\
+12345678901234567890123456789012345678901234567890123456";
+ char *string = "Domain is NAME_MAX+1 256 characters long!\n";
+
+ setlocale(LC_ALL, "");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ errno = 0;
+ s = dcgettext(domain, string, LC_MESSAGES);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_GOTO_STRING_EQUAL(s, string, -1, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase4(VOID)
+{
+ char *s = "";
+ char *domain = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\
+1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\
+123456789012345678901234567890123456789012345678901234567";
+ char *string = "Domain is more than NAME_MAX+1(256) 257 characters long!\n";
+
+ setlocale(LC_ALL, "");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ errno = 0;
+ s = dcgettext(domain, string, LC_MESSAGES);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_GOTO_STRING_EQUAL(s, string, -1, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+static UINT32 testcase(VOID)
+{
+ errno = 0;
+
+ testcase1();
+ testcase2();
+ testcase3();
+ testcase4();
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_DCGETTEXT_002(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_dcngettext_001.cpp b/testsuites/unittest/IO/full/IO_test_dcngettext_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5d9ee5ef78a734b08ef67b72c9cb67591101d0c3
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_dcngettext_001.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase(VOID)
+{
+ char *s = "";
+
+ setlocale(LC_ALL, "");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ printf(dcngettext("www.huawei.com", "TestString1\n", "TestString2\n", 1, LC_MESSAGES));
+ printf(dcngettext("www.huawei.com", "TestString1\n", "TestString2\n", 2, LC_MESSAGES));
+
+ s = dcngettext("www.huawei.com", "TestString1\n", "TestString2\n", 1, LC_MESSAGES);
+ printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1\n", s);
+
+ s = dcngettext("www.huawei.com", "TestString1\n", "TestString2\n", 2, LC_MESSAGES);
+ printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2\n", s);
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_DCNGETTEXT_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_dcngettext_002.cpp b/testsuites/unittest/IO/full/IO_test_dcngettext_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4253cb43826b325be81d478750cf3421b7cb2f11
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_dcngettext_002.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase1(VOID)
+{
+ char *s = "";
+
+ setlocale(LC_ALL, "zh_CN.UTF-8");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ errno = 0;
+ s = dcngettext("", "TestString1:Hello world!\n", "TestString2\n", 1, LC_MESSAGES);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1:Hello world!\n", s);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ errno = 0;
+ s = dcngettext("", "TestString1\n", "TestString2:Hello world!\n", 2, LC_MESSAGES);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2:Hello world!\n", s);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase2(VOID)
+{
+ char *s = "";
+
+ setlocale(LC_ALL, "zh_CN.UTF-8");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ errno = 0;
+ s = dcngettext("en_US.UTF-8", "TestString1:Hello world!\n", "TestString2:Hello world!\n", 1, LC_MESSAGES);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1:Hello world!\n", s);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ errno = 0;
+ s = dcngettext("en_US.UTF-8", "TestString1\n", "TestString2:Hello world!\n", 2, LC_MESSAGES);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2:Hello world!\n", s);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1();
+ testcase2();
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_DCNGETTEXT_002(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_dngettext_001.cpp b/testsuites/unittest/IO/full/IO_test_dngettext_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dea72b5f772540f5355565fd033f10c7471f638c
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_dngettext_001.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase(VOID)
+{
+ char *s = "";
+
+ setlocale(LC_ALL, "");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ printf(dngettext("www.huawei.com", "TestString1\n", "TestString2\n", 1));
+ printf(dngettext("www.huawei.com", "TestString1\n", "TestString2\n", 2));
+
+ s = dngettext("www.huawei.com", "TestString1\n", "TestString2\n", 1);
+ printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1\n", s);
+
+ s = dngettext("www.huawei.com", "TestString1\n", "TestString2\n", 2);
+ printf("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2\n", s);
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_DNGETTEXT_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_dngettext_002.cpp b/testsuites/unittest/IO/full/IO_test_dngettext_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0e6753defb73afeb03eb483a3a9677d38d16eba5
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_dngettext_002.cpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase1(VOID)
+{
+ char *s = "";
+
+ setlocale(LC_ALL, "zh_CN.UTF-8");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ errno = 0;
+ s = dngettext("", "TestString1:Hello world!\n", "TestString2\n", 1);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1:Hello world!\n", s);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ errno = 0;
+ s = dngettext("", "TestString1\n", "TestString2:Hello world!\n", 2);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2:Hello world!\n", s);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase2(VOID)
+{
+ char *s = "";
+
+ setlocale(LC_ALL, "zh_CN.UTF-8");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ errno = 0;
+ s = dngettext("en_US.UTF-8", "TestString1:Hello world!\n", "TestString2\n", 1);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString1:Hello world!\n", s);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ errno = 0;
+ s = dngettext("en_US.UTF-8", "TestString1\n", "TestString2:Hello world!\n", 2);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_ASSERT_STRING_EQUAL(s, "TestString2:Hello world!\n", s);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase3(VOID)
+{
+ char *s = "";
+
+ setlocale(LC_ALL, "zh_CN.UTF-8");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ errno = 0;
+ s = dngettext("en_US.UTF-8", "TestString1:Hello world!\n", "TestString2!\n", 5);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_GOTO_STRING_EQUAL(s, "TestString2!\n", -1, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ errno = 0;
+ s = dngettext("en_US.UTF-8", "TestString1\n", "TestString2:Hello world!\n", 3);
+ TEST_PRINT("[INFO]%s:%d,%s,s=%s\n", __FILE__, __LINE__, __func__, s);
+ TEST_PRINT("[INFO]%s:%d,%s,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, errno, strerror(errno));
+ ICUNIT_GOTO_STRING_EQUAL(s, "TestString2:Hello world!\n", -1, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1(); /* test the domain is NULL */
+ testcase2(); /* test the domain is different with the setlocale */
+ testcase3(); /* if n != 1,then dngettext will choose msgid2's string */
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_DNGETTEXT_002(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_duplocale_001.cpp b/testsuites/unittest/IO/full/IO_test_duplocale_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0ba8e34698e5287957d1db3aa67147da0a7b517b
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_duplocale_001.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase(VOID)
+{
+ time_t currtime;
+ struct tm *timer = {nullptr};
+ char buffer[80];
+ locale_t oldloc = LC_GLOBAL_LOCALE;
+ locale_t newloc = nullptr;
+
+ printf("[INFO]newloc=0x%x,oldloc=0x%x\n", (int)newloc, (int)oldloc);
+ newloc = duplocale(oldloc);
+ printf("[INFO]newloc=0x%x,oldloc=0x%x\n", (int)newloc, (int)oldloc);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(newloc, nullptr, -1);
+
+ time(&currtime);
+ timer = localtime(&currtime);
+
+ /* set timer as 'Thu Jan 1 23:48:56 1970'" */
+ timer->tm_sec = 32;
+ timer->tm_min = 3;
+ timer->tm_hour = 1;
+ timer->tm_mday = 2;
+ timer->tm_mon = 0;
+ timer->tm_year = 70;
+ timer->tm_wday = 5;
+ timer->tm_yday = 1;
+ timer->tm_isdst = 0;
+ timer->__tm_gmtoff = 0;
+ timer->__tm_zone = nullptr;
+
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ printf("[INFO]getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
+ ICUNIT_GOTO_STRING_EQUAL(getenv("MUSL_LOCPATH"), "/storage", getenv("MUSL_LOCPATH"), OUT);
+
+ printf("[INFO]Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8"));
+ strftime(buffer, 80, "%c", timer);
+ printf("[INFO]Date is: %s\n", buffer);
+ ICUNIT_GOTO_STRING_EQUAL(buffer, "星期五 一月 2 01:03:32 1970", -1, OUT);
+
+ printf("[INFO]Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8"));
+ strftime(buffer, 80, "%c", timer);
+ printf("[INFO]Date is: %s\n", buffer);
+ ICUNIT_GOTO_STRING_EQUAL(buffer, "星期五 一月 2 01:03:32 1970", -1, OUT);
+
+ printf("[INFO]Locale is: %s\n", setlocale(LC_TIME, ""));
+ strftime(buffer, 80, "%c", timer);
+ printf("[INFO]Date is: %s\n", buffer);
+ ICUNIT_GOTO_STRING_EQUAL(buffer, "Fri Jan 2 01:03:32 1970", -1, OUT);
+
+ free(newloc);
+ return LOS_OK;
+OUT:
+ free(newloc);
+ return LOS_NOK;
+}
+
+VOID IO_TEST_DUPLOCALE_001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_gettext_001.cpp b/testsuites/unittest/IO/full/IO_test_gettext_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fb3c91d0a6dde1a04a0f1038e177ba638ca1e74b
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_gettext_001.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase1(VOID)
+{
+ char *s = nullptr;
+ char *tmp = nullptr;
+
+ /* set the locale. */
+ setlocale(LC_ALL, "zh_CN.UTF-8");
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ TEST_PRINT("[INFO]%s:%d,%s,getenv MUSL_LOCPATH=%s\n", __FILE__, __LINE__, __func__, getenv("MUSL_LOCPATH"));
+ tmp = setlocale(LC_TIME, "zh_CN.UTF-8");
+ TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__, tmp);
+ ICUNIT_GOTO_STRING_EQUAL(tmp, "zh_CN.UTF-8", -1, OUT);
+
+ /* choose a domain for your program. */
+ tmp = textdomain("messages");
+ /* bind a directory,use PWD here. */
+ bindtextdomain("messages", ".");
+ /* set the output codeset.It is not needed usually */
+ bind_textdomain_codeset("messages", "UTF-8");
+
+ /* test gettext. */
+ s = gettext("Monday/n\n");
+
+ ICUNIT_ASSERT_STRING_EQUAL(s, "Monday/n\n", s);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1();
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_GETTEXT_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_locale_001.cpp b/testsuites/unittest/IO/full/IO_test_locale_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4282ce170b3e305863173c1d29d36fb6b2369ab4
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_locale_001.cpp
@@ -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.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase(VOID)
+{
+ time_t currtime;
+ struct tm *timer = {nullptr};
+ char buffer[80];
+
+ time(&currtime);
+ timer = localtime(&currtime);
+
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
+
+ printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8"));
+ strftime(buffer, 80, "%c", timer);
+ printf("Date is: %s\n", buffer);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
+
+ printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8"));
+ strftime(buffer, 80, "%c", timer);
+ printf("Date is: %s\n", buffer);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
+
+ printf("Locale is: %s\n", setlocale(LC_TIME, ""));
+ strftime(buffer, 80, "%c", timer);
+ printf("Date is: %s\n", buffer);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_LOCALE_001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_locale_002.cpp b/testsuites/unittest/IO/full/IO_test_locale_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..000508d211c8d9e86cf91b80760d5b1605800c06
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_locale_002.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase(VOID)
+{
+ time_t currtime;
+ struct tm *timer = {nullptr};
+ char buffer[80];
+ //locale_t loc = malloc(sizeof(locale_t);
+
+ time(&currtime);
+ timer = localtime(&currtime);
+
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
+
+ printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8"));
+ strftime(buffer, 80, "%c", timer);
+ printf("Date is: %s\n", buffer);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
+
+ printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8"));
+ strftime(buffer, 80, "%c", timer);
+ printf("Date is: %s\n", buffer);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
+
+ printf("Locale is: %s\n", setlocale(LC_TIME, ""));
+ strftime(buffer, 80, "%c", timer);
+ printf("Date is: %s\n", buffer);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_LOCALE_002(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_ngettext_001.cpp b/testsuites/unittest/IO/full/IO_test_ngettext_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..18f3858b3ec3612bc38919726bc7097ffe38624b
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_ngettext_001.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase(VOID)
+{
+ char *s = "";
+
+ setlocale(LC_ALL, "");
+ textdomain("gettext_demo");
+ bindtextdomain("gettext_demo", ".");
+ bind_textdomain_codeset("gettext_demo", "UTF-8");
+
+ printf(ngettext("Delete the selected file?\n", "Delete the selected files?\n", 1));
+ printf(ngettext("Delete the selected file?\n", "Delete the selected files?\n", 2));
+
+ s = ngettext("0123456789", "0123456789", 2);
+ ICUNIT_ASSERT_STRING_EQUAL(s, "0123456789", s);
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_NGETTEXT_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_nl_langinfo_001.cpp b/testsuites/unittest/IO/full/IO_test_nl_langinfo_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8e8bd44b9f7508609d58ff855942233edeccc471
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_nl_langinfo_001.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+
+static UINT32 testcase(VOID)
+{
+ /* set the locale info */
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
+ printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8"));
+
+ setlocale(LC_CTYPE, "");
+ setlocale(LC_NUMERIC, "");
+
+ /* echo the nl_langinfo */
+ printf("%s\n", nl_langinfo(CODESET));
+ printf("%s\n", nl_langinfo(RADIXCHAR));
+ printf("%s\n", nl_langinfo(D_T_FMT));
+ printf("%s\n", nl_langinfo(D_FMT));
+ printf("%s\n", nl_langinfo(T_FMT));
+ printf("%s\n", nl_langinfo(DAY_1));
+ printf("%s\n", nl_langinfo(DAY_7));
+ printf("%s\n", nl_langinfo(ABDAY_1));
+ printf("%s\n", nl_langinfo(ABDAY_7));
+ printf("%s\n", nl_langinfo(MON_1));
+ printf("%s\n", nl_langinfo(MON_12));
+ printf("%s\n", nl_langinfo(ABMON_1));
+ printf("%s\n", nl_langinfo(ABMON_12));
+ printf("%s\n", nl_langinfo(THOUSEP));
+ printf("%s\n", nl_langinfo(YESEXPR));
+ printf("%s\n", nl_langinfo(NOEXPR));
+ printf("%s\n", nl_langinfo(CRNCYSTR));
+
+ /* set the locale info */
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
+ printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8"));
+
+ setlocale(LC_CTYPE, "");
+ setlocale(LC_NUMERIC, "");
+
+ /* echo the nl_langinfo */
+ printf("%s\n", nl_langinfo(CODESET));
+ printf("%s\n", nl_langinfo(RADIXCHAR));
+ printf("%s\n", nl_langinfo(D_T_FMT));
+ printf("%s\n", nl_langinfo(D_FMT));
+ printf("%s\n", nl_langinfo(T_FMT));
+ printf("%s\n", nl_langinfo(DAY_1));
+ printf("%s\n", nl_langinfo(DAY_7));
+ printf("%s\n", nl_langinfo(ABDAY_1));
+ printf("%s\n", nl_langinfo(ABDAY_7));
+ printf("%s\n", nl_langinfo(MON_1));
+ printf("%s\n", nl_langinfo(MON_12));
+ printf("%s\n", nl_langinfo(ABMON_1));
+ printf("%s\n", nl_langinfo(ABMON_12));
+ printf("%s\n", nl_langinfo(THOUSEP));
+ printf("%s\n", nl_langinfo(YESEXPR));
+ printf("%s\n", nl_langinfo(NOEXPR));
+ printf("%s\n", nl_langinfo(CRNCYSTR));
+
+ char *string = nl_langinfo(CRNCYSTR);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(string, NULL, string);
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_NL_LANGINFO_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_nl_langinfo_l_001.cpp b/testsuites/unittest/IO/full/IO_test_nl_langinfo_l_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8adb4f8fcf76850478562050475cb578054874e2
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_nl_langinfo_l_001.cpp
@@ -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.
+ */
+#include "It_test_IO.h"
+#include
+#include
+static UINT32 testcase(VOID) {
+ /* set the locale info */
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
+ printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8"));
+
+ setlocale(LC_CTYPE, "");
+ setlocale(LC_NUMERIC, "");
+
+ /* echo the nl_langinfo_l */
+ printf("%s\n", nl_langinfo_l(CODESET, (locale_t)"en_US.UTF-8"));
+ printf("%s\n", nl_langinfo_l(RADIXCHAR, (locale_t)"en_US.UTF-8"));
+
+ /* set the locale info */
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
+ printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8"));
+
+ setlocale(LC_CTYPE, "");
+ setlocale(LC_NUMERIC, "");
+
+ /* echo the nl_langinfo */
+ printf("%s\n", nl_langinfo_l(CODESET, (locale_t)"zh_CN.UTF-8"));
+ printf("%s\n", nl_langinfo_l(RADIXCHAR, (locale_t)"zh_CN.UTF-8"));
+
+ char *string = nl_langinfo_l(CRNCYSTR, (locale_t)"zh_CN.UTF-8");
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(string, NULL, string);
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_NL_LANGINFO_l_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_ppoll_001.cpp b/testsuites/unittest/IO/full/IO_test_ppoll_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..69c5b310be5aeae3e1c9307d7fba34e7bc2d4fbb
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_ppoll_001.cpp
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2021-2021, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2021-2021, Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include "signal.h"
+#include "pthread.h"
+
+#define LISTEN_FD_NUM 10
+#define POLL_EVENTS 1
+
+int pipeFdPpoll[LISTEN_FD_NUM][2];
+static pthread_t g_tid = -1;
+extern int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmo_p, const sigset_t *sigmask);
+
+static void *pthread_01(void)
+{
+ static int count = 0;
+ int total_num = 0;
+ int times = 3;
+ int i, ret;
+ struct pollfd fds[LISTEN_FD_NUM] = {0};
+ char buffer[20];
+ struct timespec t = { 3,0 };
+ sigset_t sigset;
+
+ TEST_PRINT("[INFO]%s:%d,%s,Create thread %d\n", __FILE__, __LINE__, __func__, count);
+ count++;
+
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGALRM); //把SIGALRM ä¿¡å·æ·»åŠ åˆ°sigset ä¿¡å·é›†ä¸
+ sigaddset(&sigset, SIGUSR1);
+
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ fds[i].fd = pipeFdPpoll[i][0];
+ fds[i].events = POLL_EVENTS;
+ }
+
+ while (times--) {
+ ret = ppoll(fds, LISTEN_FD_NUM, &t, &sigset);
+ total_num += ((ret > 0) ? ret : 0);
+
+ if (ret <= 0) {
+ continue;
+ }
+
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ if (fds[i].revents & POLL_EVENTS) {
+ ret = read(fds[i].fd, buffer, 12);
+ ICUNIT_GOTO_EQUAL(ret, 12, ret, EXIT);
+ ret = strcmp(buffer, "hello world");
+ TEST_PRINT("[EVENT]%s:%d,%s,buffer=%s\n", __FILE__, __LINE__, __func__, buffer);
+ }
+ }
+
+ if (total_num == LISTEN_FD_NUM) {
+ break;
+ }
+ }
+
+ /* ICUNIT_GOTO_EQUAL(total_num, 10, -1, EXIT); */
+ TEST_PRINT("[INFO]%s:%d,%s,total_num=%d\n", __FILE__, __LINE__, __func__, total_num);
+EXIT:
+ return nullptr;
+}
+
+static UINT32 testcase1(VOID)
+{
+ int i;
+ int ret;
+ int count = 0;
+
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ ret = pipe(pipeFdPpoll[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,pipeFdPpoll[%d][0]=%d\n", __FILE__, __LINE__, __func__, ret, i, pipeFdPpoll[i][0]);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,pipeFdPpoll[%d][0]=%d\n", __FILE__, __LINE__, __func__, ret, i, pipeFdPpoll[i][1]);
+ }
+
+ errno = 0;
+ ret = pthread_create(&g_tid, nullptr, pthread_01(nullptr), nullptr);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ errno = 0;
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ if ((pipeFdPpoll[i][1] != 9) && (pipeFdPpoll[i][1] != 10) && (pipeFdPpoll[i][1] != 11)) {
+ ret = write(pipeFdPpoll[i][1], "hello world!", 12); /* 12, "hello world" length and '\0' */
+ }
+ ICUNIT_GOTO_EQUAL(ret, 12, ret, EXIT);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ }
+
+#if 1 /* write looply */
+ while(1) {
+ if (count++ > 3) {
+ break;
+ }
+ sleep(1);
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ errno = 0;
+ ret = pthread_create(&g_tid, nullptr, pthread_01(nullptr), nullptr);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ if ((pipeFdPpoll[i][1] == 13) || (pipeFdPpoll[i][1] == 14) || (pipeFdPpoll[i][1] == 15)) {
+ errno = 0;
+ ret = write(pipeFdPpoll[i][1], "World HELLO!", 12); /* 12, "hello world" length and '\0' */
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,pipeFdPpoll[%d][1]=%d,count=%d\n", __FILE__, __LINE__, __func__, ret,i, pipeFdPpoll[i][1], count);
+ }
+ /* ICUNIT_GOTO_EQUAL(ret, 12, ret, EXIT); */
+ }
+ }
+#endif
+
+ pthread_join(g_tid, nullptr);
+
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ close(pipeFdPpoll[i][0]);
+ close(pipeFdPpoll[i][1]);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ close(pipeFdPpoll[i][0]);
+ close(pipeFdPpoll[i][1]);
+ }
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1();
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_PPOLL_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_ppoll_002.cpp b/testsuites/unittest/IO/full/IO_test_ppoll_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0beab11728e4a0bc326d572f4f056335d0dceae0
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_ppoll_002.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2021-2021, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2021-2021, Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include "time.h"
+#include "signal.h"
+#include
+#include
+#include
+#include
+
+#define BUF_LEN 20
+#define MAX_SCAN_FDSET 10 /* define poll's listened FD set's size */
+#define POLL_WAIT_TIMEOUT 10*1000 /* ms */
+
+extern int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *sigmask);
+void work_ppoll(int fd)
+{
+ int ret = 0;
+ int i = 0;
+ char recv_buf[BUF_LEN];
+ sigset_t sigset;
+ struct timespec t;
+ struct pollfd scan_fdset[MAX_SCAN_FDSET];
+ int scan_fdset_num = 10;
+ int count = 5;
+
+ bzero(recv_buf, BUF_LEN);
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGALRM); /* add SIGALRM to sigset */
+ sigaddset(&sigset, SIGUSR1); /* add SIGUSR1 to sigset */
+ bzero(&t, sizeof(struct timespec));
+ t.tv_sec = 10;
+ t.tv_nsec = 0;
+ bzero(scan_fdset, sizeof(struct pollfd) * MAX_SCAN_FDSET);
+ scan_fdset[0].fd = fd;
+
+ /* attention:in the book《UNIX网络编程第一å·ã€‹P162 metions:POLLERR,POLLHUP,POLLNVAL\
+ those error signals can not be set in events. */
+ /* they will return in revents,while the proper condition happens. */
+ scan_fdset[0].events = POLLOUT; /* set the signal needed to be listened:POLLOUT/POLLIN */
+
+ /* set other elements in the array as invalid. */
+ for (i = 1; i < MAX_SCAN_FDSET; i++) {
+ /* scan_fdset[i].fd = -1; */
+ scan_fdset[i].fd = fd;
+ scan_fdset[i].events = POLLOUT; /* set the signal needed to be listened. */
+ }
+ /* scan_fdset_num = 1; */ /* 表示当å‰çš„scan_fdset[] 数组ä¸åªä½¿ç”¨å‰é¢1 ä¸ªå…ƒç´ å˜æ”¾éœ€è¦ç›‘å¬çš„æ‰«æç¬¦ */
+
+ while (count--) {
+ ret = ppoll(scan_fdset, scan_fdset_num, &t, &sigset);
+
+ for (i = 0; i < MAX_SCAN_FDSET; i++) {
+ if (scan_fdset[i].revents & POLLOUT) {
+ TEST_PRINT("[INFO]%s:%d,%s,fd have signal!\n", __FILE__, __LINE__, __func__);
+ ret = read(fd, recv_buf, BUF_LEN);
+ if (-1 == ret) {
+ TEST_PRINT("[INFO]%s:%d,%s,read error!\n", __FILE__, __LINE__, __func__);
+ continue;
+ }
+ TEST_PRINT("[INFO]%s:%d,%s,recv_buf=%s\n", __FILE__, __LINE__, __func__, recv_buf);
+ }
+ TEST_PRINT("[INFO]%s:%d,%s,scan_fdset[i].revents=%d\n", __FILE__, __LINE__, __func__, scan_fdset[i].revents);
+ }
+ }
+}
+
+static UINT32 testcase(VOID)
+{
+ int fd;
+ char *filename = FILEPATH_775;
+
+ fd = open(filename, O_RDWR);
+ TEST_PRINT("[INFO]%s:%d,%s,fd=%d\n", __FILE__, __LINE__, __func__, fd);
+ work_ppoll(fd);
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_PPOLL_002(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_pselect_001.cpp b/testsuites/unittest/IO/full/IO_test_pselect_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..30908d720e4c57b7e6a5f3b9cd5ab3ffd893afdc
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_pselect_001.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2021-2021, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2021-2021, Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include
+#include
+#include
+#include "sys/select.h"
+
+static UINT32 testcase(VOID)
+{
+ fd_set rfds;
+ //struct timeval tv;
+ struct timespec tv;
+ int retval;
+
+ /* Watch stdin (fd 0) to see when it has input. */
+ FD_ZERO(&rfds);
+ FD_SET(0, &rfds);
+
+ /* Wait up to three seconds. */
+ //tv.tv_sec = 3;
+ //tv.tv_usec = 0;
+ tv.tv_sec = 3;
+ tv.tv_nsec = 0;
+
+ retval = pselect(1, &rfds, nullptr, nullptr, &tv, ((long[]){ 0, _NSIG/8 }));
+
+ if (retval == -1) {
+ perror("select()");
+ } else if (retval) {
+ printf("Data is available now.\n");
+ } else { /* FD_ISSET(0, &rfds) will be true. */
+ printf("No data within three seconds.\n");
+ }
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_PSELECT_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_strcasecmp_l_001.cpp b/testsuites/unittest/IO/full/IO_test_strcasecmp_l_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7c9acb69867317762c4a733375fb151ddb1e427f
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_strcasecmp_l_001.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include "locale.h"
+
+static UINT32 testcase(VOID)
+{
+ char *a = "aBcDeF";
+ char *b = "AbCdEf";
+ locale_t loc;
+
+ printf("Strings:a=%s,b=%s,doing if(!strcasecmp(a, b))printf(\"\%s=\%s\\n\", a, b);", a, b, a, b);
+ if (!strcasecmp_l(a, b, loc)) {
+ printf("%s=%s\n", a, b);
+ }
+ ICUNIT_ASSERT_EQUAL(strcasecmp_l(a, b, loc), 0, strcasecmp_l(a, b, loc));
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_STRCASECMP_L_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_strcasecmp_l_002.cpp b/testsuites/unittest/IO/full/IO_test_strcasecmp_l_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4312816eee4d714d25808d125a417034bba6d5a3
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_strcasecmp_l_002.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+
+static UINT32 testcase1(VOID)
+{
+ char *a = "aBcDeF";
+ char *b = "AbCEf";
+ int ret = 0;
+ locale_t loc;
+ errno = 0;
+
+ ret = strcasecmp_l(a, b, loc);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase2(VOID)
+{
+ char *a = "aBcDfF";
+ char *b = "AbCEe";
+ int ret = 0;
+ locale_t loc;
+ errno = 0;
+
+ ret = strcasecmp_l(a, b, loc);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1();
+ testcase2();
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_STRCASECMP_L_002(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_strfmon_l_001.cpp b/testsuites/unittest/IO/full/IO_test_strfmon_l_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2d4ab5fa5cabec01bff719b5577536f6444e1cc1
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_strfmon_l_001.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include "locale.h"
+
+static UINT32 testcase(VOID)
+{
+ char buf[100] = {0};
+ int ret = 0;
+ locale_t loc;
+
+ ret = strfmon_l(buf, sizeof(buf), loc, "[%^=*#6n] [%=*#6i]", 1234.567, 1234.567);
+ ICUNIT_ASSERT_EQUAL(ret, 23, ret);
+
+ ret = strfmon_l(buf, sizeof(buf), loc, "[%^=*#6n] [%=*#6i]", 134.567, 1234.567);
+ ICUNIT_ASSERT_EQUAL(ret, 23, ret);
+
+ ret = strfmon_l(buf, sizeof(buf), loc, "[%^=*#6n] [%=*#6i]", 1234.567, 134.567);
+ ICUNIT_ASSERT_EQUAL(ret, 23, ret);
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_STRFMON_L_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_strfmon_l_002.cpp b/testsuites/unittest/IO/full/IO_test_strfmon_l_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4b658239181e395fad2e7b4134cc2bdc1550312a
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_strfmon_l_002.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include "locale.h"
+
+static UINT32 testcase1(VOID)
+{
+ char buf[100] = {0};
+ int ret = 0;
+ locale_t loc;
+ errno = 0;
+
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__,setlocale(LC_TIME, "zh_CN.UTF-8"));
+
+ errno = 0;
+ ret = strfmon_l(buf, 2, loc, "[%^=*#6n] [%=*#6i]", 1234.567, 1234.567);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,buf=%s\n", __FILE__, __LINE__, __func__, ret, buf);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, E2BIG, errno, OUT);
+
+ errno = 0;
+ ret = strfmon_l(buf, 3, loc, "[%^=*#6n] [%=*#6i]", 134.567, 1234.567);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,buf=%s\n", __FILE__, __LINE__, __func__, ret, buf);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, E2BIG, errno, OUT);
+
+ errno = 0;
+ ret = strfmon_l(buf, 22, loc, "[%^=*#6n] [%=*#6i]", 1234.567, 134.567);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,buf=%s\n", __FILE__, __LINE__, __func__, ret, buf);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, E2BIG, errno, OUT);
+
+ errno = 0;
+ ret = strfmon_l(buf, 23, loc, "[%^=*#6n] [%=*#6i]", 1234.567, 134.567);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,buf=%s\n", __FILE__, __LINE__, __func__, ret, buf);
+ ICUNIT_GOTO_EQUAL(ret, 23, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1();
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_STRFMON_L_002(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_strncasecmp_l_001.cpp b/testsuites/unittest/IO/full/IO_test_strncasecmp_l_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..57ada71ccb83638bc6bfb8efcde02d02fbf15d46
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_strncasecmp_l_001.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+#include "locale.h"
+
+static UINT32 testcase(VOID)
+{
+ char *a = "aBcDeF";
+ char *b = "AbCdEf";
+ int n = 5;
+ locale_t loc;
+
+ printf("Strings:a=%s,b=%s,doing if(!strncasecmp(a, b, %d))printf(\"\%s=\%s\\n\", a, b);", a, b, n, a, b);
+ if (!strncasecmp_l(a, b, n, loc)) {
+ printf("%s=%s in first %d characters.\n", a, b, n);
+ }
+ ICUNIT_ASSERT_EQUAL(strncasecmp_l(a, b, n, loc), 0, strncasecmp_l(a, b, n, loc));
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_STRNCASECMP_L_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/IO_test_strncasecmp_l_002.cpp b/testsuites/unittest/IO/full/IO_test_strncasecmp_l_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..285088bd3c4a439b1b629d88cb25ed6b1c3077f6
--- /dev/null
+++ b/testsuites/unittest/IO/full/IO_test_strncasecmp_l_002.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+#include
+
+static UINT32 testcase1(VOID)
+{
+ char *a = "aBcDeF";
+ char *b = "AbCdEf";
+ int n = 600;
+ int ret = 0;
+ locale_t loc;
+ errno = 0;
+
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__,setlocale(LC_TIME, "zh_CN.UTF-8"));
+
+ errno = 0;
+ ret = strncasecmp_l(a, b, n, loc);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase2(VOID)
+{
+ char *a = "aBcDeF";
+ char *b = "AbCdEi";
+ int n = -6;
+ int ret = 0;
+ locale_t loc;
+ errno = 0;
+
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__,setlocale(LC_TIME, "zh_CN.UTF-8"));
+
+ errno = 0;
+ ret = strncasecmp_l(a, b, n, loc);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -3, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase3(VOID)
+{
+ char *a = "aBcDeF";
+ char *b = "AbCdAx";
+ int n = 0;
+ int ret = 0;
+ locale_t loc;
+ errno = 0;
+
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__,setlocale(LC_TIME, "zh_CN.UTF-8"));
+
+ errno = 0;
+ ret = strncasecmp_l(a, b, n, loc);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase4(VOID)
+{
+ char *a = "34342aBcDeF";
+ char *b = "AbCdAx";
+ int n = 4;
+ int ret = 0;
+ locale_t loc;
+ errno = 0;
+
+ setenv("MUSL_LOCPATH", "/storage", 1);
+ TEST_PRINT("[INFO]%s:%d,%s,Locale is: %s\n", __FILE__, __LINE__, __func__,setlocale(LC_TIME, "zh_CN.UTF-8"));
+
+ errno = 0;
+ ret = strncasecmp_l(a, b, n, loc);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -46, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1();
+ testcase2();
+ testcase3();
+ testcase4();
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_STRNCASECMP_L_002(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_locale_localeconv_001.cpp b/testsuites/unittest/IO/full/It_locale_localeconv_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e9e5ab65c1cfa9ea00ae781588d03fe14a5381cd
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_locale_localeconv_001.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+
+static UINT32 Testcase(VOID)
+{
+ struct lconv *newloc = localeconv();
+ ICUNIT_ASSERT_NOT_EQUAL(newloc, NULL, newloc);
+
+ return LOS_OK;
+}
+
+VOID ItLocaleLocaleconv001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdio_fputws_001.cpp b/testsuites/unittest/IO/full/It_stdio_fputws_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3a2a96201832e16e5d49eb760246f91bd6a9ef84
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdio_fputws_001.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+
+static UINT32 Testcase(VOID)
+{
+ wchar_t *srcStr = L"hello";
+ wchar_t tarStr[20] = {0}; // 20, target buffer size
+ int nRet;
+ unsigned int nPos;
+ int nType;
+ char pathname[50]; // 50, path name buffer size
+ FILE *testFile;
+ strncpy(pathname, g_ioTestPath, 50); // 50, path name buffer size
+ char *filename = "/crtfputwstest1";
+ strcat(pathname, filename);
+ for (nType = 0; nType < 6; nType++) { // 6, test loop num
+ testFile = fopen(pathname, "a");
+
+ ICUNIT_GOTO_NOT_EQUAL(testFile, NULL, testFile, EXIT);
+ fseek(testFile, 0, SEEK_END);
+ nPos = (unsigned int)ftell(testFile);
+
+ nRet = fputws(srcStr, testFile);
+
+ ICUNIT_GOTO_NOT_EQUAL(nRet, -1, nRet, EXIT);
+ if ((nPos + 5) != (unsigned int)ftell(testFile)) { // 5, expect position offset
+ ICUNIT_GOTO_EQUAL(1, 0, 1, EXIT);
+ }
+ fclose(testFile);
+
+ testFile = fopen(pathname, "r");
+ ICUNIT_GOTO_NOT_EQUAL(testFile, NULL, testFile, EXIT);
+ wchar_t *p = fgetws(tarStr, 6, testFile); // 6, "hello" length and '\0'
+ ICUNIT_GOTO_EQUAL(p, tarStr, p, EXIT);
+ nRet = wcscmp(srcStr, tarStr);
+ ICUNIT_GOTO_EQUAL(nRet, 0, nRet, EXIT);
+ fclose(testFile);
+ }
+
+ remove(pathname);
+ return LOS_OK;
+EXIT:
+ if (testFile != NULL) {
+ fclose(testFile);
+ remove(pathname);
+ }
+ return LOS_NOK;
+}
+
+VOID ItStdioFputws001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdio_fwprintf_001.cpp b/testsuites/unittest/IO/full/It_stdio_fwprintf_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6cda97adca83a85b97d71926e68e93d0bdd9a1c8
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdio_fwprintf_001.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+
+static UINT32 Testcase(VOID)
+{
+ wchar_t tarStr[20] = {0}; // 20, buffer size
+ wchar_t *p;
+ int nRet;
+ unsigned int nPos;
+ int nType;
+ char pathname[50]; // 50, path name buffer size
+ strncpy(pathname, g_ioTestPath, 50); // 50, path name buffer size
+ char *filename = "/crtfwprintftest1";
+ FILE *testFile = NULL;
+
+ strcat(pathname, filename);
+
+ for (nType = 0; nType < 6; nType++) { // 6, loop test num
+ testFile = fopen(pathname, "w+");
+ ICUNIT_GOTO_NOT_EQUAL(testFile, NULL, testFile, EXIT);
+
+ nPos = (unsigned int)ftell(testFile);
+
+ nRet = fwprintf(testFile, L"hello world %d", 666); // 666, for test, print to testFile
+ ICUNIT_GOTO_EQUAL(nRet, 15, nRet, EXIT); // 15, total write size
+
+ if ((nPos + 15) != (unsigned int)ftell(testFile)) { // 15, total write size
+ ICUNIT_GOTO_EQUAL(1, 0, 1, EXIT);
+ }
+ fclose(testFile);
+
+ testFile = fopen(pathname, "r");
+ p = fgetws(tarStr, 16, testFile); // 16, read size,total write and '\0'
+ nRet = wcscmp(L"hello world 666", tarStr);
+ ICUNIT_GOTO_EQUAL(nRet, 0, nRet, EXIT);
+
+ fclose(testFile);
+ }
+
+ remove(pathname);
+ return LOS_OK;
+EXIT:
+ if (testFile != NULL) {
+ fclose(testFile);
+ remove(pathname);
+ }
+ return LOS_NOK;
+}
+
+VOID ItStdioFwprintf001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdio_getc_unlocked_001.cpp b/testsuites/unittest/IO/full/It_stdio_getc_unlocked_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5f437c0bc054d8e7ca93c6e7459d0b75a3f1429a
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdio_getc_unlocked_001.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+
+static UINT32 Testcase(VOID)
+{
+ char ch;
+ unsigned int nPos;
+ int ret;
+ char pathname[50]; // 50, enough space.
+ strncpy(pathname, g_ioTestPath, sizeof(pathname));
+ char *filename = "/crt_getc_unlocked_test1";
+ FILE *testFile = NULL;
+
+ strcat(pathname, filename);
+ testFile = fopen(pathname, "w+");
+ ICUNIT_ASSERT_NOT_EQUAL(testFile, NULL, LOS_NOK);
+ ret = fputs("0123456789abcdefghijklmnopqrstuvwxyz", testFile);
+ ICUNIT_GOTO_NOT_EQUAL(ret, EOF, ret, EXIT);
+ fclose(testFile);
+
+ testFile = fopen(pathname, "r");
+ ICUNIT_GOTO_NOT_EQUAL(testFile, NULL, testFile, EXIT);
+
+ nPos = ftell(testFile);
+
+ ch = getc_unlocked(testFile);
+ ICUNIT_GOTO_EQUAL(ch, '0', ch, EXIT);
+
+ if ((nPos + sizeof(char)) != (unsigned int)ftell(testFile)) {
+ ICUNIT_GOTO_EQUAL(1, 0, 1, EXIT);
+ }
+
+ fclose(testFile);
+ remove(pathname);
+ return LOS_OK;
+EXIT:
+ if (testFile != NULL) {
+ fclose(testFile);
+ remove(pathname);
+ }
+ return LOS_NOK;
+}
+
+VOID ItStdioGetcUnlocked001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdio_hasmntopt_001.cpp b/testsuites/unittest/IO/full/It_stdio_hasmntopt_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3e27bef44c0e6167074ec0d9adad2f61a9e6601d
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdio_hasmntopt_001.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+static UINT32 testcase(VOID)
+{
+ struct mntent* mnt = nullptr;
+ struct mntent* mnt_new = nullptr;
+ FILE *fp = nullptr;
+ char *argv[2] = {nullptr};
+ argv[0] = "/etc/fstab";
+ argv[1] = "errors";
+ char *opt = argv[1];
+ char *ret = nullptr;
+
+ mnt_new = (struct mntent *)malloc(sizeof(struct mntent));
+ mnt_new->mnt_fsname = "UUID=c4992556-a86e-45e8-ba5f-190b16a9073x";
+ mnt_new->mnt_dir = "/usr1";
+ mnt_new->mnt_type = "ext3";
+ mnt_new->mnt_opts = "errors=remount-ro,nofail";
+ mnt_new->mnt_freq = 0;
+ mnt_new->mnt_passno = 1;
+
+ fp = setmntent("/etc/fstab", "r");
+ if (!fp) {
+ printf("fp=0x%x\n", fp);
+ return LOS_NOK;
+ }
+
+ mnt = getmntent(fp);
+ if (mnt && !(feof(fp) || ferror(fp))) {
+ ret = hasmntopt(mnt, opt);
+ printf("hasmntopt=%s\n", ret);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(ret, NULL, -1);
+ mnt = getmntent(fp);
+ }
+
+ if (fp != NULL) {
+ endmntent(fp);
+ }
+
+ /* test the addmntent below */
+ fp = setmntent(argv[0], "a");
+ if (fopen("/lib/libc.so", "r")) {
+ printf("aha I found you are OHOS!!!\n");
+ if (addmntent(fp, mnt_new)) {
+ printf("a new mnt is added to %s\n", argv[0]);
+ }
+ }
+
+ if (fp != NULL) {
+ endmntent(fp);
+ }
+
+ return LOS_OK;
+}
+
+VOID IT_STDIO_HASMNTOPT_001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdio_mblen_001.cpp b/testsuites/unittest/IO/full/It_stdio_mblen_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7667ce6c702f0504d48b2669f24392b715d974b8
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdio_mblen_001.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+
+static UINT32 Testcase(VOID)
+{
+ setlocale(LC_ALL, "en_US.utf8");
+ size_t result = 0;
+ const char *str = "z\u00df\u6c34\U0001f34c";
+ const char *end = str + strlen(str);
+
+ mblen(NULL, 0);
+ while (str < end) {
+ int next = mblen(str, end - str);
+ if (next == -1) {
+ perror("strlen_mb");
+ break;
+ }
+ str += next;
+ ++result;
+ }
+ ICUNIT_GOTO_EQUAL(result, 4, result, EXIT); // 4, except value
+
+ return LOS_OK;
+EXIT:
+ return LOS_NOK;
+}
+
+VOID ItStdioMblen001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdio_mbrlen_001.cpp b/testsuites/unittest/IO/full/It_stdio_mbrlen_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..39ee9f4abfdee6c26264b94c4837f2b60b1591ad
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdio_mbrlen_001.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+
+static UINT32 Testcase(VOID)
+{
+ // allow mbrlen() to work with UTF-8 multibyte encoding
+ setlocale(LC_ALL, "en_US.utf8");
+ const char *str = "æ°´";
+ size_t sz = strlen(str);
+ int len1, len2, len3;
+
+ mbstate_t mb;
+ memset(&mb, 0, sizeof(mb));
+ len1 = mbrlen(str, 1, &mb);
+ ICUNIT_GOTO_EQUAL(len1, -2, len1, EXIT); // -2, except return value
+
+ len2 = mbrlen(str + 1, sz - 1, &mb);
+ ICUNIT_GOTO_EQUAL(len2, 2, len2, EXIT); // 2, except return value
+
+ len3 = mbrlen(str + 1, sz - 1, &mb);
+ ICUNIT_GOTO_EQUAL(len3, -1, len3, EXIT);
+
+ return LOS_OK;
+EXIT:
+ return LOS_NOK;
+}
+
+VOID ItStdioMbrlen001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdio_putwc_001.cpp b/testsuites/unittest/IO/full/It_stdio_putwc_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6c122743885a4b7b0959095b1746bf20a018b453
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdio_putwc_001.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+
+static UINT32 Testcase(VOID)
+{
+ wchar_t srcWc = L'H';
+ int tarWc, nRet;
+ long nPos;
+ int nType, i;
+ FILE *putwcFile = NULL;
+ char pathname[50]; // 50, pathname size
+ strncpy(pathname, g_ioTestPath, 50); // 50, pathname size
+ char *filename = "/crtputwctest1";
+
+ strcat(pathname, filename);
+
+ for (nType = 0; nType < 6; nType++) { // 6, loop test num
+ putwcFile = fopen(pathname, "w+");
+ ICUNIT_GOTO_NOT_EQUAL(putwcFile, NULL, putwcFile, EXIT);
+
+ nPos = ftell(putwcFile);
+
+ nRet = putwc(srcWc, putwcFile);
+ ICUNIT_GOTO_EQUAL(nRet, L'H', nRet, EXIT);
+ fclose(putwcFile);
+
+ putwcFile = fopen(pathname, "r");
+ tarWc = getwc(putwcFile);
+ ICUNIT_GOTO_EQUAL(tarWc, L'H', tarWc, EXIT);
+
+ if ((nPos + 1) != ftell(putwcFile)) {
+ ICUNIT_GOTO_EQUAL(1, 0, 1, EXIT);
+ }
+
+ fclose(putwcFile);
+ }
+
+ remove(pathname);
+ return LOS_OK;
+EXIT:
+ if (putwcFile != NULL) {
+ fclose(putwcFile);
+ remove(pathname);
+ }
+ return LOS_NOK;
+}
+
+VOID ItStdioPutwc001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdio_readv_001.cpp b/testsuites/unittest/IO/full/It_stdio_readv_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..78eebb9106db2201b3b82e83d268a16e9a334677
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdio_readv_001.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+static UINT32 Testcase(VOID)
+{
+ char *srcStr = "helloworld";
+ int nRet, fd;
+ char pathname[50]; // 50, path name size
+ char *filename = "/crtreadvtest1";
+ char buf1[6] = { 0 };
+ char buf2[6] = { 0 };
+ struct iovec iov[2]; // 2, read 2 block
+ ssize_t nread;
+ const int testStrLen = 10;
+
+ iov[0].iov_base = buf1;
+ iov[0].iov_len = sizeof(buf1) - 1;
+ iov[1].iov_base = buf2;
+ iov[1].iov_len = sizeof(buf2) - 1;
+
+ strncpy(pathname, g_ioTestPath, 50); // 50, path name size
+ strcat(pathname, filename);
+ fd = open(pathname, O_CREAT | O_RDWR | O_TRUNC, 0666); // 0666, file authority
+ if (fd < 0) {
+ printf("error: can`t open file\n");
+ }
+ nRet = write(fd, srcStr, testStrLen);
+ ICUNIT_GOTO_EQUAL(nRet, testStrLen, nRet, EXIT);
+ close(fd);
+
+ fd = open(pathname, O_RDWR);
+ if (fd < 0) {
+ printf("error: can`t open file\n");
+ }
+ nread = readv(fd, iov, 2); // 2, read 2 block
+ ICUNIT_GOTO_EQUAL(nread, testStrLen, nread, EXIT);
+ nRet = strcmp(buf2, "world");
+ ICUNIT_GOTO_EQUAL(nRet, 0, nRet, EXIT);
+ nRet = strcmp(buf1, "hello");
+ ICUNIT_GOTO_EQUAL(nRet, 0, nRet, EXIT);
+
+ close(fd);
+ remove(pathname);
+ return LOS_OK;
+EXIT:
+ close(fd);
+ remove(pathname);
+ return LOS_NOK;
+}
+
+VOID ItStdioReadv001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdio_rindex_001.cpp b/testsuites/unittest/IO/full/It_stdio_rindex_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b69df021faa602a341867cb9d6e42f200f86ac89
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdio_rindex_001.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+
+static UINT32 Testcase(VOID)
+{
+ int ret;
+ char *s = "abcdef123456abcdef";
+ char *p = NULL;
+ p = rindex(s, 'b');
+ ret = strcmp(p, "bcdef");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return LOS_OK;
+EXIT:
+ return LOS_NOK;
+}
+
+VOID ItStdioRindex001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdio_setlogmask_001.cpp b/testsuites/unittest/IO/full/It_stdio_setlogmask_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9fa4f469b05d35bb6cdbb09e144df25f9f8a6605
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdio_setlogmask_001.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+
+static UINT32 Testcase(VOID)
+{
+ int oldmask;
+ int newmask = 0xff;
+ oldmask = setlogmask(newmask);
+ newmask = setlogmask(oldmask);
+ ICUNIT_ASSERT_EQUAL(newmask, 0xff, newmask);
+
+ return LOS_OK;
+}
+
+VOID ItStdioSetlogmask001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdlib_gcvt_001.cpp b/testsuites/unittest/IO/full/It_stdlib_gcvt_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9894425e306d5015de6b65f9502a58eea4a21061
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdlib_gcvt_001.cpp
@@ -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.
+ */
+#include "It_test_IO.h"
+
+
+static UINT32 Testcase(VOID)
+{
+ double a = 12345678.12549;
+ double b = 0.1234567;
+ char ptr[128] = {0}; // 128, target buffer size
+ int ret;
+ gcvt(a, 10, ptr); // 10, convert significant value setting
+ ret = strcmp(ptr, "12345678.13");
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gcvt(b, 6, ptr); // 6, convert significant value setting
+ ret = strcmp(ptr, "0.123457");
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return 0;
+}
+
+VOID ItStdlibGcvt001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdlib_poll_002.cpp b/testsuites/unittest/IO/full/It_stdlib_poll_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..58eb521cc7913026edca3d445879d73d71abee36
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdlib_poll_002.cpp
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+int g_pipeFd[10][2]; // 2, read and write; 10, listen fd number.
+static pthread_t g_tid = -1;
+static const int LISTEN_FD_NUM = 10;
+
+static void *Pthread01(void *arg)
+{
+ int totalNum = 0;
+ int times = 3; // 3, loop number for test.
+ int i, ret;
+ struct pollfd fds[LISTEN_FD_NUM] = {0};
+ char buffer[20]; // 20, enough space for test.
+ const int pollEvents = 1;
+
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ fds[i].fd = g_pipeFd[i][0];
+ fds[i].events = pollEvents;
+ }
+
+ while (times--) {
+ ret = poll(fds, LISTEN_FD_NUM, 1000); // 1000, wait time.
+ totalNum += ((ret > 0) ? ret : 0);
+
+ if (ret <= 0) {
+ continue;
+ }
+
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ if (fds[i].revents & pollEvents) {
+ ret = read(fds[i].fd, buffer, 12); // 12, "hello world" length and '\0'
+ ICUNIT_GOTO_EQUAL(ret, 12, ret, EXIT); // 12, "hello world" length and '\0'
+ ret = strcmp(buffer, "hello world");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ }
+ }
+
+ if (totalNum == LISTEN_FD_NUM) {
+ break;
+ }
+ }
+
+ ICUNIT_GOTO_EQUAL(totalNum, LISTEN_FD_NUM, -1, EXIT);
+
+EXIT:
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ int i;
+ int ret;
+
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ ret = pipe(g_pipeFd[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ }
+
+ ret = pthread_create(&g_tid, NULL, Pthread01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ ret = write(g_pipeFd[i][1], "hello world", 12); // 12, "hello world" length and '\0'
+ ICUNIT_GOTO_EQUAL(ret, 12, ret, EXIT); // 12, "hello world" length and '\0'
+ }
+
+ pthread_join(g_tid, NULL);
+
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ close(g_pipeFd[i][0]);
+ close(g_pipeFd[i][1]);
+ }
+
+ return LOS_OK;
+
+EXIT:
+ for (i = 0; i < LISTEN_FD_NUM; i++) {
+ close(g_pipeFd[i][0]);
+ close(g_pipeFd[i][1]);
+ }
+ return LOS_NOK;
+}
+
+VOID ItStdlibPoll002(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/full/It_stdlib_poll_003.cpp b/testsuites/unittest/IO/full/It_stdlib_poll_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d1a99db88f3f539c166c806d8489ffa52c3161b5
--- /dev/null
+++ b/testsuites/unittest/IO/full/It_stdlib_poll_003.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IO.h"
+
+struct PollParam {
+ int nfds;
+ int timeout;
+ int ret;
+ int err;
+};
+
+static UINT32 Testcase(VOID)
+{
+ const int TEST_STR_LEN = 12;
+ int pipeFd[2], ret, err; // 2, pipe return 2 file descirpter
+ struct pollfd pollFd;
+ struct PollParam pollParam[4] = { /* nfds timeout ret err */
+ { 0, 100, -1, EINVAL},
+ { 4096, 10, -1, EINVAL},
+ { 4095, 10, -1, EFAULT},
+ { 1, -1, 1, 0}
+ };
+
+ ret = pipe(pipeFd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = write(pipeFd[1], "hello world", TEST_STR_LEN);
+ printf("write first status: %d\n", ret);
+ ICUNIT_GOTO_EQUAL(ret, TEST_STR_LEN, ret, EXIT);
+
+ pollFd.fd = pipeFd[0];
+ pollFd.events = POLLIN;
+
+ for (int i = 0; i < sizeof(pollParam) / sizeof(pollParam[0]); i++) {
+ ret = poll(&pollFd, pollParam[i].nfds, pollParam[i].timeout);
+ ICUNIT_GOTO_EQUAL(ret, pollParam[i].ret, ret, EXIT);
+ if (ret == -1) {
+ printf("i = %d\n", i);
+ if (i == 2) { // 2, pollParam[2].
+ ICUNIT_GOTO_TWO_EQUAL(errno, EFAULT, EBADF, errno, EXIT);
+ } else {
+ ICUNIT_GOTO_EQUAL(errno, pollParam[i].err, errno, EXIT);
+ }
+ }
+ }
+
+ close(pipeFd[0]);
+ close(pipeFd[1]);
+ return LOS_OK;
+EXIT:
+ close(pipeFd[0]);
+ close(pipeFd[1]);
+ return LOS_NOK;
+}
+
+VOID ItStdlibPoll003(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IO/io_test.cpp b/testsuites/unittest/IO/io_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..020be401f859cc1f0de505b7bb3de2d47fca6797
--- /dev/null
+++ b/testsuites/unittest/IO/io_test.cpp
@@ -0,0 +1,238 @@
+/*
+ * 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
+#include
+
+#include "It_test_IO.h"
+
+char *g_ioTestPath = "/storage";
+
+using namespace testing::ext;
+namespace OHOS {
+class IoTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_FULL)
+/* *
+ * @tc.name: IT_TEST_IO_005
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItTestIo005, TestSize.Level0)
+{
+ ItTestIo005();
+}
+
+#ifdef LOSCFG_USER_TEST_FS_JFFS
+/* *
+ * @tc.name: IT_TEST_IO_008
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItTestIo008, TestSize.Level0)
+{
+ ItTestIo008();
+}
+#endif
+
+
+/* *
+ * @tc.name: IT_TEST_IO_010
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItTestIo010, TestSize.Level0)
+{
+ ItTestIo010();
+}
+
+/* *
+ * @tc.name: IT_TEST_IO_013
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItTestIo013, TestSize.Level0)
+{
+ ItTestIo013();
+}
+
+/* *
+ * @tc.name: IT_STDLIB_POLL_002
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdlibPoll002, TestSize.Level0)
+{
+ ItStdlibPoll002();
+}
+
+/* *
+ * @tc.name: IT_STDLIB_POLL_003
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdlibPoll003, TestSize.Level0)
+{
+ ItStdlibPoll003();
+}
+
+/* *
+ * @tc.name: IT_STDIO_PUTWC_001
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdioPutwc001, TestSize.Level0)
+{
+ ItStdioPutwc001();
+}
+
+/* *
+ * @tc.name: IT_STDIO_READV_001
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdioReadv001, TestSize.Level0)
+{
+ ItStdioReadv001();
+}
+
+
+/* *
+ * @tc.name: IT_STDIO_RINDEX_001
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdioRindex001, TestSize.Level0)
+{
+ ItStdioRindex001();
+}
+
+/* *
+ * @tc.name: IT_STDIO_SETLOGMASK_001
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdioSetlogmask001, TestSize.Level0)
+{
+ ItStdioSetlogmask001();
+}
+
+/* *
+ * @tc.name: IT_STDLIB_GCVT_001
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdlibGcvt001, TestSize.Level0)
+{
+ ItStdlibGcvt001();
+}
+
+/* *
+ * @tc.name: IT_LOCALE_LOCALECONV_001
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItLocaleLocaleconv001, TestSize.Level0)
+{
+ ItLocaleLocaleconv001();
+}
+
+/* *
+ * @tc.name: IT_STDIO_FPUTWS_001
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdioFputws001, TestSize.Level0)
+{
+ ItStdioFputws001();
+}
+
+/* *
+ * @tc.name: IT_STDIO_FWPRINTF_001
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdioFwprintf001, TestSize.Level0)
+{
+ ItStdioFwprintf001();
+}
+
+/* *
+ * @tc.name: IT_STDIO_GETC_UNLOCKED_001
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdioGetcUnlocked001, TestSize.Level0)
+{
+ ItStdioGetcUnlocked001();
+}
+
+/* *
+ * @tc.name: IT_STDIO_MBLEN_001
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdioMblen001, TestSize.Level0)
+{
+ ItStdioMblen001();
+}
+
+/* *
+ * @tc.name: IT_STDIO_MBRLEN_001
+ * @tc.desc: function for IoTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(IoTest, ItStdioMbrlen001, TestSize.Level0)
+{
+ ItStdioMbrlen001();
+}
+#endif
+} // namespace OHOS
diff --git a/testsuites/unittest/IPC/BUILD.gn b/testsuites/unittest/IPC/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..db9a18e56fd769ed647da8796edca2c6790f3474
--- /dev/null
+++ b/testsuites/unittest/IPC/BUILD.gn
@@ -0,0 +1,53 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../config.gni")
+
+unittest("liteos_a_ipc_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../common/include",
+ "../IPC",
+ ]
+ sources = [
+ "../common/osTest.cpp",
+ "ipc_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_FULL == true) {
+ sources_full = [
+ "full/IPC_test_mkfifoat_001.cpp",
+ "full/IPC_test_mkfifoat_002.cpp",
+ ]
+ sources += sources_full
+ }
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+ configs = [ "..:public_config" ]
+}
diff --git a/testsuites/unittest/IPC/It_test_IPC.h b/testsuites/unittest/IPC/It_test_IPC.h
new file mode 100644
index 0000000000000000000000000000000000000000..c9fd393f5109d87a01ad18411a0a84d1516652ad
--- /dev/null
+++ b/testsuites/unittest/IPC/It_test_IPC.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _IT_TEST_IPC_H
+#define _IT_TEST_IPC_H
+
+#include "osTest.h"
+#include "stdio.h"
+#include "stdlib.h"
+#include "unistd.h"
+#include "string.h"
+#include "termios.h"
+#include "sys/types.h"
+#include "sys/stat.h"
+#include "fcntl.h"
+#include "locale.h"
+#include "wctype.h"
+#include "wchar.h"
+#include "stdarg.h"
+#include "semaphore.h"
+#include "ftw.h"
+#include "aio.h"
+#include "shadow.h"
+#include "pty.h"
+#include "dirent.h"
+#include "poll.h"
+#include "grp.h"
+#include "pwd.h"
+#include "sys/uio.h"
+#include "syslog.h"
+
+extern int CloseRmAllFile(int fd[], char filePathName[][50], int cnt);
+extern char *g_IoTestPath;
+
+extern VOID IPC_TEST_MKFIFOAT_001(VOID);
+extern VOID IPC_TEST_MKFIFOAT_002(VOID);
+
+#endif
diff --git a/testsuites/unittest/IPC/full/IPC_test_mkfifoat_001.cpp b/testsuites/unittest/IPC/full/IPC_test_mkfifoat_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ae69b88281339d568ad68ebc822a6f8bab0e5725
--- /dev/null
+++ b/testsuites/unittest/IPC/full/IPC_test_mkfifoat_001.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IPC.h"
+#include
+#include
+
+#define PATHNAME_FIFO "./fifo.test"
+#define PATHNAME_FIFO_FULL "/dev/fifo.test"
+
+static UINT32 testcase1(VOID)
+{
+ int ret = 0;
+ char *dirname = "/dev";
+ DIR *dir = NULL;
+ int fdDir = 0;
+
+ errno = 0;
+ dir = opendir(dirname);
+ fdDir = dirfd(dir);
+ TEST_PRINT("[INFO]%s:%d,%s,fdDir=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, fdDir, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(fdDir, -1, fdDir, OUT);
+
+ errno = 0;
+ ret = mkfifoat(fdDir, PATHNAME_FIFO, 0777);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ /* remove the pipe file created in order to ensure to run the testcase again. */
+ errno = 0;
+ ret = remove(PATHNAME_FIFO_FULL);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ close(fdDir);
+ return LOS_OK;
+OUT:
+ close(fdDir);
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1();
+
+ return LOS_OK;
+}
+
+VOID IPC_TEST_MKFIFOAT_001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IPC/full/IPC_test_mkfifoat_002.cpp b/testsuites/unittest/IPC/full/IPC_test_mkfifoat_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8432e1404713efb2eb3120fb6da78fc006f45079
--- /dev/null
+++ b/testsuites/unittest/IPC/full/IPC_test_mkfifoat_002.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_IPC.h"
+#include
+#include
+
+#define PATHNAME_FIFO "./fifo.test"
+#define PATHNAME_FIFO_FULL "/dev/fifo.test"
+#define PATHNAME_ENOTDIR FILEPATH_775
+
+static UINT32 testcase1(VOID)
+{
+ int ret = 0;
+ int fdDir = 0;
+
+ errno = 0;
+ fdDir = open(PATHNAME_ENOTDIR, O_RDWR, 0666);
+ TEST_PRINT("[INFO]%s:%d,%s,fdDir=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, fdDir, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(fdDir, -1, fdDir, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ errno = 0;
+ ret = mkfifoat(fdDir, PATHNAME_FIFO, 0777);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, ENOTDIR, errno, OUT);
+
+ close(fdDir);
+ return LOS_OK;
+OUT:
+ close(fdDir);
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1();
+
+ return LOS_OK;
+}
+
+VOID IPC_TEST_MKFIFOAT_002(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/IPC/ipc_test.cpp b/testsuites/unittest/IPC/ipc_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..95b89e56988ede0c44238f3329e943a4338f2bda
--- /dev/null
+++ b/testsuites/unittest/IPC/ipc_test.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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
+#include
+
+#include "It_test_IPC.h"
+
+using namespace testing::ext;
+namespace OHOS {
+class IoTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_FULL)
+/* *
+ * @tc.name: IPC_TEST_MKFIFOAT_001
+ * @tc.desc: function for IoTest:mkfifoat-normal test
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+#if 0
+HWTEST_F(IoTest, IPC_TEST_MKFIFOAT_001, TestSize.Level0)
+{
+ IPC_TEST_MKFIFOAT_001();
+}
+#endif
+
+/* *
+ * @tc.name: IPC_TEST_MKFIFOAT_002
+ * @tc.desc: function for IoTest:mkfifoat-innormal test
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+#if 0
+HWTEST_F(IoTest, IPC_TEST_MKFIFOAT_002, TestSize.Level0)
+{
+ IPC_TEST_MKFIFOAT_002();
+}
+#endif
+#endif
+} // namespace OHOS
diff --git a/testsuites/unittest/common/include/iCunit.h b/testsuites/unittest/common/include/iCunit.h
new file mode 100644
index 0000000000000000000000000000000000000000..167f773acddd8cc9feac94eac3ae808a822dbb8b
--- /dev/null
+++ b/testsuites/unittest/common/include/iCunit.h
@@ -0,0 +1,401 @@
+/*
+ * 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 _UNI_ICUNIT_H
+#define _UNI_ICUNIT_H
+
+#include
+#include
+#include "los_typedef.h"
+#include
+#include
+
+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 ICUNIT_SUCCESS 0x00000000
+
+#define FUNCTION_TEST (1 << 0)
+
+#define PRESSURE_TEST (1 << 1)
+
+#define PERFORMANCE_TEST (1 << 2)
+
+#define TEST_MODE (FUNCTION_TEST)
+
+#define TEST_LESSER_MEM NO
+
+#define TEST_ADD_CASE(string, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION) \
+ do { \
+ UINT32 ret; \
+ ret = TestCase(); \
+ ASSERT_EQ(ret, LOS_OK); \
+ } while (0)
+
+#if 1
+/* *
+ * 跟踪paramå’Œvalueä¸åŒï¼Œä¸åšä»»ä½•处ç†
+ */
+#define ICUNIT_TRACK_EQUAL(param, value, retcode) \
+ do { \
+ if ((param) != (value)) { \
+ EXPECT_EQ((long)(value), (long)(param)); \
+ } \
+ } while (0)
+
+/* *
+ * 跟踪paramå’Œvalue相åŒï¼Œä¸åšä»»ä½•处ç†
+ */
+#define ICUNIT_TRACK_NOT_EQUAL(param, value, retcode) \
+ do { \
+ if ((param) == (value)) { \
+ EXPECT_NE((long)(value), (long)(param)); \
+ } \
+ } while (0)
+
+
+#define ICUNIT_ASSERT_NOT_EQUAL_NULL(param, value, retcode) \
+ do { \
+ if ((param) == (value)) { \
+ EXPECT_NE((long)(value), (long)(param)); \
+ return NULL; \
+ } \
+ } while (0)
+
+
+#define ICUNIT_ASSERT_EQUAL_NULL(param, value, retcode) \
+ do { \
+ if ((param) != (value)) { \
+ EXPECT_EQ((long)(value), (long)(param)); \
+ return NULL; \
+ } \
+ } while (0)
+
+
+/* *
+ * æ–言paramå’Œvalue相åŒï¼Œä¸åŒåˆ™return
+ */
+#define ICUNIT_ASSERT_EQUAL_VOID(param, value, retcode) \
+ do { \
+ if ((param) != (value)) { \
+ EXPECT_EQ((long)(value), (long)(param)); \
+ return; \
+ } \
+ } while (0)
+
+
+/* *
+ * æ–言paramå’Œvalueä¸åŒï¼Œç›¸åŒåˆ™return
+ */
+#define ICUNIT_ASSERT_NOT_EQUAL_VOID(param, value, retcode) \
+ do { \
+ if ((param) == (value)) { \
+ EXPECT_NE((long)(value), (long)(param)); \
+ return; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_EQUAL(param, value, retcode) \
+ do { \
+ if ((param) != (value)) { \
+ EXPECT_EQ((long)(param), (long)(value)); \
+ return 1; \
+ } \
+ } while (0)
+
+
+#define ICUNIT_ASSERT_TWO_EQUAL(param, value1, value2, retcode) \
+ do { \
+ if (((param) != (value1)) && ((param) != (value2))) { \
+ EXPECT_EQ((long)(value1), (long)(param)); \
+ EXPECT_EQ((long)(value2), (long)(param)); \
+ return 1; \
+ } \
+ } while (0)
+
+/* *
+ * 判æ–paramç‰äºŽvalue1或value2,ä¸ç‰åˆ™è·³è½¬åˆ°label处
+ */
+#define ICUNIT_GOTO_TWO_EQUAL(param, value1, value2, retcode, label) \
+ do { \
+ if (((param) != (value1)) && ((param) != (value2))) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ goto label; \
+ } \
+ } while (0)
+
+/* *
+ * æ–言paramå’Œvalueä¸åŒï¼Œç›¸åŒåˆ™return
+ */
+#define ICUNIT_ASSERT_NOT_EQUAL(param, value, retcode) \
+ do { \
+ if ((param) == (value)) { \
+ EXPECT_NE(retcode, retcode); \
+ return 1; \
+ } \
+ } while (0)
+/* *
+ * æ–言paramä¸åœ¨value1å’Œvalue2之间就return
+ */
+#define ICUNIT_ASSERT_WITHIN_EQUAL(param, value1, value2, retcode) \
+ do { \
+ if ((param) < (value1) || (param) > (value2)) { \
+ EXPECT_GE((long)(param), (long)(value1)); \
+ EXPECT_LE((long)(param), (long)(value2)); \
+ return 1; \
+ } \
+ } while (0)
+
+
+/* *
+ * æ–言param是å¦åœ¨ä¸€å®šèŒƒå›´å†…,ä¸åœ¨åˆ™return
+ */
+#define ICUNIT_ASSERT_WITHIN_EQUAL_VOID(param, value1, value2, retcode) \
+ do { \
+ if ((param) < (value1) || (param) > (value2)) { \
+ EXPECT_GE((long)(param), (long)(value1)); \
+ EXPECT_LE((long)(param), (long)(value2)); \
+ return; \
+ } \
+ } while (0)
+
+
+/* *
+ * æ–言param是å¦åœ¨ä¸€å®šèŒƒå›´å†…,ä¸åœ¨åˆ™return
+ */
+#define ICUNIT_ASSERT_WITHIN_EQUAL_NULL(param, value1, value2, retcode) \
+ do { \
+ if ((param) < (value1) || (param) > (value2)) { \
+ EXPECT_GE((long)(param), (long)(value1)); \
+ EXPECT_LE((long)(param), (long)(value2)); \
+ return NULL; \
+ } \
+ } while (0)
+
+
+/* *
+ * æ–言指定个数str1å’Œstr2å—符串内容相åŒï¼Œä¸åŒåˆ™return
+ */
+
+#define ICUNIT_ASSERT_SIZE_STRING_EQUAL(str1, str2, strsize, retcode) \
+ do { \
+ if (strncmp((str1), (str2), (strsize)) != 0) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ return 1; \
+ } \
+ } while (0)
+
+
+/* *
+ * 判æ–paramå’Œvalue是å¦ç›¸åŒï¼Œä¸åŒåˆ™è·³è½¬åˆ°label处
+ */
+#define ICUNIT_ASSERT_EQUAL_TIME(param, value, retcode, label) \
+ do { \
+ if ((param) < (value - 1) || (param) > (value + 1)) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ goto label; \
+ } \
+ } while (0)
+
+
+#if 1
+/* *
+ * æ–言指定个数str1å’Œstr2å—符串内容相åŒï¼Œä¸åŒåˆ™return
+ */
+#define ICUNIT_ASSERT_SIZE_STRING_EQUAL_VOID(str1, str2, size, retcode) \
+ do { \
+ if (strncmp(str1, str2, size) != 0) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ return; \
+ } \
+ } while (0)
+
+/* *
+ * æ–言指定个数str1å’Œstr2å—符串内容ä¸åŒï¼Œç›¸åŒåˆ™return
+ */
+#define ICUNIT_ASSERT_SIZE_STRING_NOT_EQUAL(str1, str2, size, retcode) \
+ do { \
+ if (strncmp(str1, str2, size) == 0) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ return 1; \
+ } \
+ } while (0)
+#endif
+
+/* *
+ * æ–言str1å’Œstr2å—符串内容相åŒï¼Œä¸åŒåˆ™return
+ */
+#define ICUNIT_ASSERT_STRING_EQUAL(str1, str2, retcode) \
+ do { \
+ if (strcmp(str1, str2) != 0) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ return 1; \
+ } \
+ } while (0)
+
+/* *
+ * æ–言str1å’Œstr2å—符串内容相åŒï¼Œä¸åŒåˆ™return
+ */
+#define ICUNIT_ASSERT_STRING_EQUAL_VOID(str1, str2, retcode) \
+ do { \
+ if (strcmp(str1, str2) != 0) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ return; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_STRING_EQUAL_RET(str1, str2, retcode, ret) \
+ do { \
+ if (strcmp(str1, str2) != 0) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ return (ret); \
+ } \
+ } while (0)
+
+/* *
+ * æ–言str1å’Œstr2å—符串内容ä¸åŒï¼Œç›¸åŒåˆ™return
+ */
+#define ICUNIT_ASSERT_STRING_NOT_EQUAL(str1, str2, retcode) \
+ do { \
+ if (strcmp(str1, str2) == 0) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ return 1; \
+ } \
+ } while (0)
+
+/* *
+ * 判æ–paramå’Œvalue是å¦ç›¸åŒï¼Œä¸åŒåˆ™è·³è½¬åˆ°label处
+ */
+#define ICUNIT_GOTO_EQUAL(param, value, retcode, label) \
+ do { \
+ if ((param) != (value)) { \
+ EXPECT_EQ((long)(value), (long)(param)); \
+ goto label; \
+ } \
+ } while (0)
+
+
+#define ICUNIT_GOTO_EQUAL_IN(param, value1, value2, retcode, label) \
+ do { \
+ if (((param) != (value1)) && ((param) != (value2))) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ goto label; \
+ } \
+ } while (0)
+
+/* *
+ * 判æ–paramå’Œvalue是å¦ä¸åŒï¼Œç›¸åŒåˆ™è·³è½¬åˆ°label处
+ */
+#define ICUNIT_GOTO_NOT_EQUAL(param, value, retcode, label) \
+ do { \
+ if ((param) == (value)) { \
+ EXPECT_NE((long)(value), (long)(param)); \
+ goto label; \
+ } \
+ } while (0)
+
+
+#define ICUNIT_GOTO_WITHIN_EQUAL(param, value1, value2, retcode, label) \
+ do { \
+ if ((param) < (value1) || (param) > (value2)) { \
+ EXPECT_GE((long)(param), (long)(value1)); \
+ EXPECT_LE((long)(param), (long)(value2)); \
+ goto label; \
+ } \
+ } while (0)
+
+
+/* *
+ * 判æ–str1å’Œstr2是å¦ç›¸åŒï¼Œä¸åŒåˆ™è·³è½¬åˆ°label处
+ */
+#define ICUNIT_GOTO_STRING_EQUAL(str1, str2, retcode, label) \
+ do { \
+ if (strcmp(str1, str2) != 0) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ goto label; \
+ } \
+ } while (0)
+
+
+/* *
+ * 判æ–str1å’Œstr2是å¦ä¸åŒï¼Œç›¸åŒåˆ™è·³è½¬åˆ°label处
+ */
+#define ICUNIT_GOTO_STRING_NOT_EQUAL(str1, str2, retcode, label) \
+ do { \
+ if (strcmp(str1, str2) == 0) { \
+ EXPECT_NE((long)(retcode), (long)(retcode)); \
+ goto label; \
+ } \
+ } while (0)
+
+/* *
+ * 跟踪paramå’Œvalueä¸åŒï¼Œä¸åšä»»ä½•处ç†
+ */
+#define ICUNIT_ASSERT_EQUAL_EXIT(param, value, exitcode) \
+ do { \
+ if ((param) != (value)) { \
+ EXPECT_EQ((long)(value), (long)(param)); \
+ exit(exitcode); \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(param, value, retcode) \
+ do { \
+ if ((param) == (value)) { \
+ EXPECT_NE((long)(value), (long)(param)); \
+ return NULL; \
+ } \
+ } while (0)
+
+#define ICUNIT_ASSERT_EQUAL_NULL_VOID(param, value, retcode) \
+ do { \
+ if ((param) != (value)) { \
+ EXPECT_EQ((long)(value), (long)(param)); \
+ return NULL; \
+ } \
+ } while (0)
+
+#endif
+
+#endif /* _UNI_ICUNIT_H */
diff --git a/testsuites/unittest/common/include/los_typedef.h b/testsuites/unittest/common/include/los_typedef.h
new file mode 100644
index 0000000000000000000000000000000000000000..a80a1dd58579612c8055220c3aaa9d3e56591d8d
--- /dev/null
+++ b/testsuites/unittest/common/include/los_typedef.h
@@ -0,0 +1,212 @@
+/*
+ * 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.
+ */
+
+/* *
+ * @defgroup los_typedef Type define
+ * @ingroup kernel
+ */
+
+#ifndef _LOS_TYPEDEF_H
+#define _LOS_TYPEDEF_H
+
+#include "stddef.h"
+#include "stdbool.h"
+#include "stdint.h"
+
+
+#define OS_STRING(x) #x
+#define X_STRING(x) OS_STRING(x)
+
+/* type definitions */
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned int UINT32;
+typedef signed char INT8;
+typedef signed short INT16;
+typedef signed int INT32;
+typedef float FLOAT;
+typedef double DOUBLE;
+typedef char CHAR;
+typedef unsigned long u_long;
+typedef u_long ULong;
+typedef long Long;
+
+#ifdef __LP64__
+typedef long unsigned int UINT64;
+typedef long signed int INT64;
+typedef unsigned long UINTPTR;
+typedef signed long INTPTR;
+#else
+typedef unsigned long long UINT64;
+typedef signed long long INT64;
+typedef unsigned int UINTPTR;
+typedef signed int INTPTR;
+#endif
+
+#ifdef __LP64__
+typedef __uint128_t UINT128;
+typedef INT64 ssize_t;
+typedef UINT64 size_t;
+#define LOSCFG_AARCH64
+#else
+typedef INT32 ssize_t;
+typedef UINT32 size_t;
+#endif
+
+typedef UINTPTR AARCHPTR;
+typedef size_t BOOL;
+
+#define VOID void
+#define STATIC static
+
+#ifndef FALSE
+#define FALSE 0U
+#endif
+
+#ifndef TRUE
+#define TRUE 1U
+#endif
+
+#ifndef NULL
+#define NULL ((VOID *)0)
+#endif
+
+#ifdef YES
+#undef YES
+#endif
+#define YES 1
+
+#ifdef NO
+#undef NO
+#endif
+#define NO 0
+
+#define OS_NULL_BYTE ((UINT8)0xFF)
+#define OS_NULL_SHORT ((UINT16)0xFFFF)
+#define OS_NULL_INT ((UINT32)0xFFFFFFFF)
+
+#ifndef USER
+#define USER
+#endif
+
+#ifndef LOS_OK
+#define LOS_OK 0
+#endif
+
+#ifndef LOS_NOK
+#define LOS_NOK 1
+#endif
+
+#ifndef LOS_EPERM
+#define LOS_EPERM 1
+#endif
+
+#ifndef LOS_ESRCH
+#define LOS_ESRCH 3
+#endif
+
+#ifndef LOS_ECHILD
+#define LOS_ECHILD 10
+#endif
+
+#ifndef LOS_EINVAL
+#define LOS_EINVAL 22
+#endif
+
+#ifndef LOS_EOPNOTSUPP
+#define LOS_EOPNOTSUPP 95
+#endif
+
+#define OS_FAIL 1
+#define OS_ERROR (UINT32)(-1)
+#define OS_INVALID (UINT32)(-1)
+#define OS_INVALID_VALUE ((UINT32)0xFFFFFFFF)
+
+#define asm __asm
+#ifdef typeof
+#undef typeof
+#endif
+#define typeof __typeof__
+
+#ifndef LOS_LABEL_DEFN
+#define LOS_LABEL_DEFN(label) label
+#endif
+
+#ifndef LOSARC_ALIGNMENT
+#define LOSARC_ALIGNMENT 8
+#endif
+/* And corresponding power of two alignment */
+#ifndef LOSARC_P2ALIGNMENT
+#ifdef LOSCFG_AARCH64
+#define LOSARC_P2ALIGNMENT 3
+#else
+#define LOSARC_P2ALIGNMENT 2
+#endif
+#endif
+
+#define PAGE_SIZE_SHIFT (12)
+
+#ifndef PAGE_SIZE
+#define PAGE_SIZE (1UL << PAGE_SIZE_SHIFT)
+#endif
+#define USER_PAGE_SIZE (1UL << 12)
+
+#if ARM64_CPU_CORTEX_A53 || ARM64_CPU_CORTEX_A57 || ARM64_CPU_CORTEX_A72
+#define CACHE_LINE 64
+#else
+#define CACHE_LINE 32
+#endif
+
+typedef int status_t;
+typedef unsigned long vaddr_t;
+typedef unsigned long paddr_t;
+typedef unsigned int uint;
+typedef unsigned long pte_t;
+
+/* Give a type or object explicit minimum alignment */
+#if !defined(LOSBLD_ATTRIB_ALIGN)
+#define LOSBLD_ATTRIB_ALIGN(__align__) __attribute__((aligned(__align__)))
+#endif
+
+/* Assign a defined variable to a specific section */
+#if !defined(LOSBLD_ATTRIB_SECTION)
+#define LOSBLD_ATTRIB_SECTION(__sect__) __attribute__((section(__sect__)))
+#endif
+
+/*
+ * Tell the compiler not to throw away a variable or function. Only known
+ * available on 3.3.2 or above. Old version's didn't throw them away,
+ * but using the unused attribute should stop warnings.
+ */
+#define LOSBLD_ATTRIB_USED __attribute__((used))
+
+
+#endif /* _LOS_TYPEDEF_H */
diff --git a/testsuites/unittest/common/include/osTest.h b/testsuites/unittest/common/include/osTest.h
new file mode 100644
index 0000000000000000000000000000000000000000..5fa25e697bb4e540a4b69d337b20ba8938475e00
--- /dev/null
+++ b/testsuites/unittest/common/include/osTest.h
@@ -0,0 +1,513 @@
+/*
+ * 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
+
+#ifndef SWTMR_TEST
+#define SWTMR_TEST
+#endif
+#include "iCunit.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "los_typedef.h"
+#include "sys/wait.h"
+#include "glob.h"
+#include "mntent.h"
+#include "securectype.h"
+#include "securec.h"
+#include
+#include
+#include
+#include
+#include
+
+#ifndef OK
+#define OK 0
+#endif
+
+#define dprintf printf
+#define ENOERR OK
+#define LOSCFG_BASE_CORE_TSK_CONFIG 1024
+
+#define USER_PROCESS_PRIORITY_HIGHEST 10
+#define USER_PROCESS_PRIORITY_LOWEST 31
+#define TEST_TASK_PARAM_INIT(stTestTask, task_name, entry, prio) \
+ do { \
+ (void)memset_s(&stTestTask, sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S)); \
+ stTestTask.pfnTaskEntry = (TSK_ENTRY_FUNC)entry; \
+ stTestTask.uwStackSize = LOS_TASK_MIN_STACK_SIZE; \
+ stTestTask.pcName = task_name; \
+ stTestTask.usTaskPrio = prio; \
+ stTestTask.uwResved = LOS_TASK_STATUS_DETACHED; \
+ } while (0)
+
+#if (LOSCFG_KERNEL_SMP == YES)
+#define TEST_TASK_PARAM_INIT_AFFI(stTestTask, task_name, entry, prio, affi) \
+ TEST_TASK_PARAM_INIT(stTestTask, task_name, entry, prio) \
+ stTestTask.usCpuAffiMask = affi;
+#else
+#define TEST_TASK_PARAM_INIT_AFFI(stTestTask, task_name, entry, prio, affi) \
+ TEST_TASK_PARAM_INIT(stTestTask, task_name, entry, prio)
+#endif
+#define JFFS_BASE_MTD_ADDR 0x100000
+#define JFFS_BASE_MTD_LEN 0x600000
+
+#define LOS_TASK_MIN_STACK_SIZE 2048
+#define TASK_PRIO_TEST 20
+#ifdef LOSCFG_AARCH64
+#define TASK_STACK_SIZE_TEST (LOS_TASK_MIN_STACK_SIZE * 3)
+#else
+#define TASK_STACK_SIZE_TEST LOS_TASK_MIN_STACK_SIZE
+#endif
+#define LOS_MS_PER_TICK (OS_SYS_MS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND)
+
+#define HWI_NUM_INTVALID OS_HWI_MAX_NUM
+#define writel(value, address) WRITE_UINT32(value, address)
+
+extern UINT32 PosixPthreadInit(pthread_attr_t *attr, int pri);
+extern UINT32 PosixPthreadDestroy(pthread_attr_t *attr, pthread_t thread);
+
+extern VOID TaskHold(UINT64 sec);
+
+extern UINT32 TaskCountGetTest(VOID);
+extern UINT32 Sem_Count_Get_Test(VOID);
+extern UINT32 QueueCountGetTest(VOID);
+extern UINT32 Swtmr_Count_Get_Test(VOID);
+extern void hal_interrupt_set_affinity(uint32_t irq, uint32_t cpuMask);
+
+#define TASK_EXISTED_NUM (TaskCountGetTest())
+#define QUEUE_EXISTED_NUM (QueueCountGetTest())
+#define SWTMR_EXISTED_NUM (Swtmr_Count_Get_Test())
+#define SEM_EXISTED_NUM (Sem_Count_Get_Test())
+
+extern void TEST_TEST_HwiDelete(unsigned int irq, void *dev_id);
+extern void TEST_HwiTrigger(unsigned int irq);
+extern void TestExtraTaskDelay(UINT32 tick);
+extern UINT64 TestTickCountGet(void);
+extern UINT64 TestTickCountByCurrCpuid(void);
+extern void TestBusyTaskDelay(UINT32 tick);
+extern void *malloc(size_t size);
+extern void TEST_DumpCpuid(void);
+extern u_long T_random(void);
+
+UINT32 LosTaskDelay(UINT32 tick);
+#define TEST_HwiDelete(ID) TEST_TEST_HwiDelete(ID, NULL)
+#define TEST_HwiClear(ID) HalIrqMask(ID)
+#define TEST_HwiTriggerDelay LosTaskDelay(200 * LOSCFG_BASE_CORE_TICK_PER_SECOND / 1000)
+#define TEST_HwiCreate(ID, prio, mode, Func, arg) LOS_HwiCreate(ID, prio, mode, Func, arg)
+
+#if HUAWEI_ENV_NFS
+#define NFS_MOUNT_DIR "/nfs"
+#define NFS_MAIN_DIR NFS_MOUNT_DIR
+#define NFS_PATH_NAME "/nfs/test"
+#else
+#define NFS_MOUNT_DIR "/nfs"
+#define NFS_MAIN_DIR NFS_MOUNT_DIR
+#define NFS_PATH_NAME "/nfs/test"
+#endif
+
+#define WIN_MOUNT_PATH "/nfs"
+#define WIN_NFS_MOUNT_DIR WIN_MOUNT_PATH
+#define WIN_NFS_MAIN_DIR WIN_NFS_MOUNT_DIR
+#define WIN_NFS_PATH_NAME "/nfs/test"
+
+#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_INT19 19
+#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_INT34 34
+#define HWI_NUM_INT35 35
+#define HWI_NUM_INT42 42
+#define HWI_NUM_INT45 45
+#define HWI_NUM_INT46 46
+#define HWI_NUM_INT50 50
+#define HWI_NUM_INT55 55
+#define HWI_NUM_INT56 56
+#define HWI_NUM_INT57 57
+#define HWI_NUM_INT58 58
+#define HWI_NUM_INT59 59
+#define HWI_NUM_INT60 60
+#define HWI_NUM_INT61 61
+#define HWI_NUM_INT63 63
+#define HWI_NUM_INT62 62
+#define HWI_NUM_INT68 68
+#define HWI_NUM_INT69 69
+
+#define HWI_NUM_INT95 95
+#define HWI_NUM_INT114 114
+#define HWI_NUM_INT169 169
+
+#if defined TESTPBXA9
+#define HWI_NUM_TEST HWI_NUM_INT56
+#define HWI_NUM_TEST1 HWI_NUM_INT57
+#define HWI_NUM_TEST0 HWI_NUM_INT58
+#define HWI_NUM_TEST2 HWI_NUM_INT59
+#define HWI_NUM_TEST3 HWI_NUM_INT60
+#elif defined TEST3518EV300
+#define HWI_NUM_TEST0 HWI_NUM_INT58
+#define HWI_NUM_TEST HWI_NUM_INT59
+#define HWI_NUM_TEST1 HWI_NUM_INT60
+#define HWI_NUM_TEST2 HWI_NUM_INT61
+#define HWI_NUM_TEST3 HWI_NUM_INT68
+#elif defined TEST3516DV300
+#define HWI_NUM_TEST HWI_NUM_INT56
+#define HWI_NUM_TEST1 HWI_NUM_INT57
+#define HWI_NUM_TEST0 HWI_NUM_INT58
+#define HWI_NUM_TEST2 HWI_NUM_INT59
+#define HWI_NUM_TEST3 HWI_NUM_INT60
+#endif
+
+#define TEST_TASKDELAY_1TICK 1
+#define TEST_TASKDELAY_2TICK 2
+#define TEST_TASKDELAY_4TICK 4
+#define TEST_TASKDELAY_10TICK 10
+#define TEST_TASKDELAY_20TICK 20
+#define TEST_TASKDELAY_50TICK 50
+
+#ifdef TEST3731
+#define TestTimer2ValueGet(temp) READ_UINT32(temp, TIMER1_REG_BASE + TIMER_VALUE)
+#elif defined TEST3559
+#define TestTimer2ValueGet(temp) READ_UINT32(temp, TIMER3_REG_BASE + TIMER_VALUE)
+#else
+#define TestTimer2ValueGet(temp) READ_UINT32(temp, TIMER2_REG_BASE + TIMER_VALUE)
+#endif
+extern void TestTimer2Config(void);
+
+#define REALTIME(time) (UINT32)((UINT64)(0xffffffff - time) * 1000 / OS_SYS_CLOCK) /* accuracy:ms */
+#define HW_TMI(time) (UINT32)((UINT64)(0xffffffff - time) * 1000 / (OS_SYS_CLOCK / 1000000)) /* accuracy:ns */
+
+#define uart_printf_func printf
+
+#ifndef VFS_STAT_PRINTF
+#define VFS_STAT_PRINTF 0
+#endif
+
+#ifndef VFS_STATFS_PRINTF
+#define VFS_STATFS_PRINTF 0
+#endif
+
+#define OPEN_FILE_MAX 20
+
+#define HUAWEI_ENV_NFS 0
+
+#ifndef TEST_RESOURCELEAK_CHECK
+#define TEST_RESOURCELEAK_CHECK YES
+#endif
+
+#ifndef TEST_MODULE_CHECK
+#define TEST_MODULE_CHECK YES
+#endif
+
+extern UINT32 g_shellTestQueueID;
+extern int g_min_mempool_size;
+extern UINT32 g_testCount;
+extern UINT32 g_testCount1;
+extern UINT32 g_testCount2;
+extern UINT32 g_testCount3;
+extern UINT32 g_flowcheck;
+extern UINT32 g_failResult;
+extern UINT32 g_passResult;
+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_semID;
+extern UINT32 g_semID2;
+extern UINT32 g_mutexTest;
+extern UINT32 g_cpupTestCount;
+extern UINT16 g_swTmrID;
+extern UINT32 g_semID;
+extern UINT32 g_testQueueID01;
+extern UINT32 g_testQueueID02;
+extern UINT32 g_testQueueID03;
+extern UINT32 g_testTskHandle;
+extern UINT32 g_leavingTaskNum;
+extern UINT32 g_mAuwTestTaskID[32];
+extern UINT8 g_mUsIndex;
+extern UINT32 g_usSemID3[];
+extern UINT32 g_testPeriod;
+extern BOOL g_isAddArray;
+extern BOOL g_isSpinorInit;
+extern BOOL g_isSdInit;
+extern UINT32 g_getTickConsume;
+extern UINT32 g_waitTestCount;
+extern INT32 g_libFilesystem;
+
+extern UINT32 GetTimer2Value(VOID);
+extern int hinand_erase(unsigned long start, unsigned long size);
+#define hispinor_erase(start, size) \
+ do { \
+ struct erase_info opts; \
+ struct mtd_info *pstMtd; \
+ pstMtd = get_mtd("spinor"); \
+ (void)memset_s(&opts, sizeof(opts), 0, sizeof(opts)); \
+ opts.addr = start; \
+ opts.len = size; \
+ pstMtd->erase(pstMtd, &opts); \
+ } while (0)
+extern void ipc_gmac_init(void);
+
+extern UINT32 Mem_Consume_Show(void);
+extern VOID shell_cmd_register(void);
+extern INT32 OsShellCmdSystemInfo(INT32 argc, const CHAR **argv);
+extern UINT32 OsShellCmdDumpTask(INT32 argc, const CHAR **argv);
+extern UINT32 OsShellCmdTaskCntGet(VOID);
+extern UINT32 OsShellCmdSwtmrCntGet(VOID);
+extern void msleep(unsigned int msecs);
+extern unsigned int sleep(unsigned int seconds);
+extern int usleep(unsigned useconds);
+
+extern VOID ipc_network_init(void);
+#ifdef LOSCFG_DRIVERS_MMC
+extern INT32 SD_MMC_Host_init(void);
+#endif
+extern VOID rdk_fs_init(void);
+extern VOID jffs2_fs_init(void);
+extern VOID ProcFsInit(void);
+
+extern UINT32 LOS_MemTotalUsedGet(VOID *pool);
+extern VOID ptestTickConsume(VOID);
+extern UINT32 TEST_TskDelete(UINT32 taskID);
+extern UINT32 TEST_SemDelete(UINT32 semHandle);
+extern VOID irq_trigger(unsigned int irq);
+extern VOID TestPartInit(char *type, UINT32 startAddr, UINT32 length);
+extern VOID TestPartDelete(char *type);
+
+extern VOID TestRunShell(VOID);
+
+extern VOID It_Usb_AutoTest(VOID);
+extern VOID Test_hid_dev_mode(VOID);
+
+extern UINT32 usbshell_cmd_reg(VOID);
+extern void usbshell_queue_control(VOID);
+extern UINT32 OsTestInit(VOID);
+
+extern void TEST_DT_COMMON(void);
+
+extern void it_process_testcase(void);
+extern void it_pthread_testcase(void);
+extern void it_mutex_test(void);
+extern void it_rwlock_test(void);
+extern void it_spinlock_test(void);
+
+/* Format options (3rd argument of f_mkfs) */
+#define TEST_FM_FAT 0x01
+#define TEST_FM_FAT32 0x02
+#define TEST_FM_EXFAT 0x04
+#define TEST_FM_ANY 0x07
+#define TEST_FM_SFD 0x08
+
+#define BIG_FD 512
+typedef struct testrunParam {
+ CHAR testcase_sequence[16];
+ CHAR testcase_num[16];
+ CHAR testcase_layer[32];
+ CHAR testcase_module[32];
+ CHAR testcase_level[16];
+ CHAR testcase_type[16];
+ CHAR testcase_id[128];
+} TEST_RUN_PARAM;
+
+typedef enum test_type {
+ HOST_U, // USB U PERFORMANCE
+ HOST_MUTIL, // MUTIL
+ HOST_DISK, // USB DISKPARTION
+ HOST_HUB, // USB HUB
+ HOST_ETH, // USB HOST ETH
+ USB_SMP,
+ HOST_UVC, // USB HOST UVC
+ HOST_NULL
+} usb_test_type;
+
+
+#define SHELLTEST_QUEUE_BUFSIZE sizeof(TEST_RUN_PARAM)
+#ifdef LOSCFG_DRIVERS_USB
+
+void Test_usb_shellcmd(controller_type ctype, device_type dtype, usb_test_type typetest);
+#endif
+
+extern int Gettid(void);
+
+#define COLOR(c) "\033[" c "m"
+#define COLOR_RED(text) COLOR("1;31") text COLOR("0")
+#define COLOR_GREEN(text) COLOR("1;32") text COLOR("0")
+
+/* like the ctime/asctime api, use static buffer, though not thread-safe. */
+static inline const char *Curtime()
+{
+ struct timespec ts;
+ struct tm t;
+ static char buf[32];
+ (void)clock_gettime(CLOCK_REALTIME, &ts);
+ (void)localtime_r(&ts.tv_sec, &t);
+ (void)sprintf_s(buf, sizeof(buf), "%d-%02d-%02d %02d:%02d:%02d.%06ld", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour,
+ t.tm_min, t.tm_sec, ts.tv_nsec / 1000);
+ return buf;
+}
+
+#define LogPrintln(fmt, ...) \
+ printf("%s [%d] %s:%d " fmt "%c", Curtime(), Gettid(), __FILE__, __LINE__, ##__VA_ARGS__, \
+ ('\n' == " " fmt[sizeof(" " fmt) - 2]) ? '\0' : '\n') // trailing newline is auto appended
+
+#if !_REDIR_TIME64 || defined(__LP64__)
+#define TIME_F "ld"
+#else
+#define TIME_F "lld"
+#endif
+
+static void noprintf (...)
+{
+ return;
+}
+#define TEST_PRINT printf
+
+/* the files with different access privilege used in testcases are define below */
+#define FILEPATH_ENOENT "/storage/test_nosuchfile.txt"
+#define FILEPATHLEN_ENOENT (strlen(FILEPATH_ENOENT) +1U)
+
+#define FILEPATH_NOACCESS "noaccessssssssssssssssssssssssssssssssssssssssssss"
+#define FILEPATHLEN_NOACCESS (strlen(FILEPATH_NOACCESS) +1U)
+
+#define FILEPATH_000 "/storage/test_000.txt"
+#define FILEPATHLEN_000 (strlen(FILEPATH_000) +1U)
+
+#define FILEPATH_775 "/storage/test_775.txt"
+#define FILEPATHLEN_775 (strlen(FILEPATH_775) +1U)
+
+#define FILEPATH_755 "/storage/test_775.txt"
+#define FILEPATHLEN_755 (strlen(FILEPATH_755) +1U)
+
+#define FILEPATH_RELATIVE "./1.txt"
+#define FILEPATHLEN_RELATIVE (strlen(FILEPATH_RELATIVE) +1U)
+
+#define DIRPATH_775 "/storage"
+
+#define FD_EBADF 513
+#define FD_EFAULT -1000
+
+#define PATHNAME_ENAMETOOLONG "ENAMETOOLONG12345678912345678912345678912345678912345678912345678912345678911111\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789\
+12345678912345678912345678913245678912345678912345678913245678913456789123456789"
+
+#endif /* _OSTEST_H */
diff --git a/testsuites/unittest/common/osTest.cpp b/testsuites/unittest/common/osTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6bcb34de81fb8f80b4be9d34bfcc5301f2d1fe20
--- /dev/null
+++ b/testsuites/unittest/common/osTest.cpp
@@ -0,0 +1,403 @@
+/*
+ * 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
+#include
+
+UINT32 g_shellTestQueueID;
+INT32 g_iCunitErrCode = 0;
+INT32 g_iCunitErrLineNo = 0;
+
+UINT32 g_testTskHandle;
+UINT32 g_testCount;
+UINT32 g_flowcheck = 0;
+UINT32 g_failResult = 0;
+UINT32 g_passResult = 0;
+
+#ifdef TEST1980
+UINT32 g_testhwiFlag;
+UINT32 g_testCpuMask;
+#endif
+
+UINT32 g_testCount1;
+UINT32 g_testCount2;
+UINT32 g_testCount3;
+UINT32 g_testTaskID01;
+UINT32 g_testTaskID02;
+UINT32 g_testTaskID03;
+UINT32 g_testTaskID04;
+UINT32 g_hwiNum1;
+UINT32 g_hwiNum2;
+UINT32 g_semID;
+UINT32 g_semID2;
+UINT32 g_mutexTest;
+UINT32 g_cpupTestCount;
+UINT32 g_waitTestCount;
+UINT32 g_testPeriod;
+
+UINT16 g_swTmrID;
+UINT32 g_testQueueID01;
+UINT32 g_testQueueID02;
+UINT32 g_testQueueID03;
+UINT32 g_leavingTaskNum;
+UINT32 g_mAuwTestTaskID[32] = {0};
+UINT32 g_getTickConsume = 0;
+CHAR g_libcPathname[50] = "/usr/jffs0";
+UINT32 g_testCircleCount = 0;
+
+UINT32 g_fatFilesystem;
+UINT8 g_mUsIndex;
+
+#if TEST_MODULE_CHECK == YES
+
+extern UINT32 g_FailModelResult[];
+extern UINT32 g_PassModelResult[];
+extern UINT32 g_ExecutModelNum[];
+#endif
+extern char *StrLayer[];
+extern char *StrLevel[];
+extern char *StrType[];
+
+extern char *StrModule[];
+extern UINT32 g_ModelNum;
+
+#ifdef LOSCFG_USER_TEST_FS_FAT
+#define TEST_FAT32 0x02
+#define TEST_EXFAT 0x04
+#endif
+
+BOOL g_isSpinorInit = FALSE;
+BOOL g_isSdInit = FALSE;
+BOOL g_isUartDevInit = FALSE;
+BOOL g_isTcpipInit = FALSE;
+BOOL g_isInitSerial = FALSE;
+UINT32 g_vfsCyclesCount = 0;
+INT32 g_serialInitFlag = -1;
+BOOL g_isAddArray = TRUE;
+BOOL g_isUsbInit = FALSE;
+BOOL g_isIpcGmacInit = FALSE;
+
+BOOL g_isDriversRandomInit = FALSE;
+
+BOOL g_isHisiEthSetPhyModeInit = FALSE;
+
+BOOL g_isVfsInit = FALSE;
+BOOL g_isProcInit = FALSE;
+
+INT32 g_libFilesystem = -1;
+enum {
+ LIB_USE_FAT = 1,
+ LIB_USE_JFFS2,
+};
+#ifdef LOSCFG_DRIVERS_USB
+VOID test_init_usb(controller_type ctype, device_type dtype);
+#endif
+VOID test_init_ipc_gmac(VOID);
+VOID test_init_proc(VOID);
+VOID test_init_sd(VOID);
+VOID TestInitVfs(VOID);
+VOID test_init_spinor(VOID);
+VOID test_deinit_jffs(VOID);
+VOID test_mtd_jffs(VOID);
+
+VOID Wfi(VOID)
+{
+ __asm__ __volatile__("wfi" : : : "memory");
+}
+
+VOID Dmb(VOID)
+{
+ __asm__ __volatile__("dmb" : : : "memory");
+}
+
+VOID Dsb(VOID)
+{
+ __asm__ __volatile__("dsb" : : : "memory");
+}
+
+__attribute__((weak)) int Gettid()
+{
+ return syscall(SYS_gettid);
+}
+
+UINT32 LosCurTaskIDGet()
+{
+ return Gettid();
+}
+
+
+UINT32 LosTaskDelay(UINT32 tick)
+{
+ return usleep(10 * tick * 1000);
+}
+
+VOID TestExtraTaskDelay(UINT32 uwTick)
+{
+#if (LOSCFG_KERNEL_SMP == YES)
+ // trigger task schedule may occor on another core
+ // needs adding delay and checking status later
+ LosTaskDelay(uwTick);
+#else
+ // do nothing
+#endif
+}
+
+extern volatile UINT64 g_tickCount[];
+UINT64 TestTickCountGet(VOID)
+{
+ /* not use LOS_TickCountGet for now,
+ cause every timer is not match with others.
+ use cpu0 timer instead. */
+ return clock();
+}
+
+UINT64 TestTickCountByCurrCpuid(VOID)
+{
+ return clock();
+}
+
+/*
+ * different from calling LOS_TaskDelay,
+ * this func will not yeild this task to another one.
+ */
+VOID TestBusyTaskDelay(UINT32 tick)
+{
+ UINT64 runtime = 0;
+
+ runtime = TestTickCountByCurrCpuid() + tick;
+ while (1) {
+ if (runtime <= TestTickCountByCurrCpuid()) {
+ break;
+ }
+ Wfi();
+ }
+}
+
+VOID TestAssertBusyTaskDelay(UINT32 timeout, UINT32 flag)
+{
+ UINT64 runtime = 0;
+
+ runtime = TestTickCountGet() + timeout;
+ while (1) {
+ if ((runtime <= TestTickCountGet()) || (g_testCount == flag)) {
+ break;
+ }
+ Wfi();
+ }
+}
+
+UINT32 PosixPthreadInit(pthread_attr_t *attr, int pri)
+{
+ UINT32 uwRet = 0;
+ struct sched_param sp;
+
+ uwRet = pthread_attr_init(attr);
+ ICUNIT_GOTO_EQUAL(uwRet, 0, uwRet, NOK);
+
+ uwRet = pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED);
+ ICUNIT_GOTO_EQUAL(uwRet, 0, uwRet, NOK);
+
+ sp.sched_priority = pri;
+ uwRet = pthread_attr_setschedparam(attr, &sp);
+ ICUNIT_GOTO_EQUAL(uwRet, 0, uwRet, NOK);
+
+ return LOS_OK;
+NOK:
+ return LOS_NOK;
+}
+
+UINT32 PosixPthreadDestroy(pthread_attr_t *attr, pthread_t thread)
+{
+ UINT32 uwRet = 0;
+
+ uwRet = pthread_join(thread, NULL);
+ ICUNIT_GOTO_EQUAL(uwRet, 0, uwRet, NOK);
+
+ uwRet = pthread_attr_destroy(attr);
+ ICUNIT_GOTO_EQUAL(uwRet, 0, uwRet, NOK);
+
+ return LOS_OK;
+NOK:
+ return LOS_NOK;
+}
+
+VOID TestInitVfs(VOID)
+{
+#if defined(LOSCFG_FS_VFS)
+ if (g_isVfsInit) {
+ return;
+ }
+
+ extern VOID los_vfs_init(VOID);
+ los_vfs_init();
+ g_isVfsInit = TRUE;
+
+#endif
+}
+
+VOID TestInitDriversRandom(VOID)
+{
+ if (g_isDriversRandomInit) {
+ return;
+ }
+
+#if defined(LOSCFG_DRIVERS_RANDOM)
+
+ printf("random init ...\n");
+ extern int ran_dev_register(VOID);
+ ran_dev_register();
+
+#endif
+
+#if defined(LOSCFG_HW_RANDOM_ENABLE)
+
+ extern int random_hw_dev_register(VOID);
+ printf("random_hw init ...\n");
+ if (random_hw_dev_register() != 0) {
+ printf("Failed!\n");
+ }
+
+#endif
+
+ g_isDriversRandomInit = TRUE;
+}
+
+VOID TestInitUartDev(VOID) {}
+
+/* ****************************************
+Function:Test_PartInit
+Description: creat a partition for testing,partition num is 0,mount point is jffs0
+Input:
+ [1]type: "spinor"
+ [2]start_addr: the partition start address
+ [3]length: the partition length
+Output: None
+Return: None
+***************************************** */
+VOID TestPartInit(char *type, UINT32 start_addr, UINT32 length)
+{
+#if defined(LOSCFG_FS_JFFS)
+ int uwRet = 0;
+
+ if ((uwRet = add_mtd_partition(type, start_addr, length, 0)) != 0)
+ PRINT_ERR("add %s partition failed, return %d\n", type, uwRet);
+ else {
+ printf("[OK] add %s partition successful\n", type);
+ if (strcmp(type, "spinor") == 0) {
+ if ((uwRet = mount("/dev/spinorblk0", "/jffs0", "jffs", 0, NULL)) != 0)
+ PRINT_ERR("mount jffs0 failed,err %d\n", uwRet);
+ else
+ printf("[OK] mount jffs0 successful\n");
+ }
+ }
+#endif
+ return;
+}
+
+/* ****************************************
+Function:Test_PartDelete
+Description: delete the partition for test
+Input:
+ [1]type: "spinor"
+Output: None
+Return: None
+***************************************** */
+VOID TestPartDelete(char *type)
+{
+#if defined(LOSCFG_FS_JFFS)
+
+ int uwRet = 0;
+ char *point = "";
+
+ if (strcmp(type, "spinor") == 0) {
+ point = "/jffs0";
+ }
+
+ if ((uwRet = umount(point)) != 0) {
+ PRINT_ERR("umount %s failed,err %d.\n", point, uwRet);
+ } else {
+ printf("[OK] umount %s OK.\n", point);
+ if ((uwRet = delete_mtd_partition(0, type)) != 0)
+ PRINT_ERR("delete %s partition failed, return %d\n", type, uwRet);
+ else
+ printf("[OK] delete %s partition OK.\n", type);
+ }
+#endif
+ return;
+}
+
+/* *
+ * dir: what you want to delete force
+ */
+int RemoveDir(const char *dir)
+{
+ char cur_dir[] = ".";
+ char up_dir[] = "..";
+ char dir_name[128] = { 0 };
+ DIR *dirp = NULL;
+ struct dirent *dp = NULL;
+ struct stat dir_stat;
+ int ret;
+
+ if (access(dir, F_OK) != 0) {
+ return 0;
+ }
+
+ if (stat(dir, &dir_stat) < 0) {
+ perror("get directory stat error");
+ return -1;
+ }
+
+ if (S_ISREG(dir_stat.st_mode)) {
+ remove(dir);
+ } else if (S_ISDIR(dir_stat.st_mode)) {
+ dirp = opendir(dir);
+ while ((dp = readdir(dirp)) != NULL) {
+ if ((strcmp(cur_dir, dp->d_name) == 0) || (strcmp(up_dir, dp->d_name) == 0)) {
+ continue;
+ }
+
+ ret = sprintf_s(dir_name, sizeof(dir_name), "%s/%s", dir, dp->d_name);
+ if (ret < 0) {
+ perror("sprintf dir_name error");
+ return -1;
+ }
+ RemoveDir(dir_name);
+ }
+ closedir(dirp);
+
+ rmdir(dir); /* now dir is empty */
+ } else {
+ perror("unknow file type!");
+ }
+ return 0;
+}
diff --git a/testsuites/unittest/config.gni b/testsuites/unittest/config.gni
new file mode 100644
index 0000000000000000000000000000000000000000..62136719df03c28937e26b1d0a8d08387265681a
--- /dev/null
+++ b/testsuites/unittest/config.gni
@@ -0,0 +1,65 @@
+# 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.
+
+LOSCFG_USER_TEST_LLT = false
+LOSCFG_USER_TEST_SMOKE = true
+LOSCFG_USER_TEST_PRESSURE = false
+LOSCFG_USER_TEST_FULL = false
+
+LOSCFG_USER_TEST_DRIVERS_STORAGE = true
+LOSCFG_USER_TEST_DRIVERS_HID = true
+LOSCFG_USER_TEST_DYNLOAD = true
+LOSCFG_USER_TEST_EXC = true
+LOSCFG_USER_TEST_IO = true
+LOSCFG_USER_TEST_MEM_VM = true
+LOSCFG_USER_TEST_MEM_SHM = true
+LOSCFG_USER_TEST_MISC = true
+LOSCFG_USER_TEST_POSIX_PTHREAD = false
+LOSCFG_USER_TEST_POSIX_MQUEUE = true
+LOSCFG_USER_TEST_POSIX_MEM = true
+LOSCFG_USER_TEST_SPINLOCK = true
+LOSCFG_USER_TEST_RWLOCK = true
+LOSCFG_USER_TEST_PTHREAD = false
+LOSCFG_USER_TEST_PROCESS = false
+LOSCFG_USER_TEST_MUTEX = true
+LOSCFG_USER_TEST_SECURITY_CAPABILITY = true
+LOSCFG_USER_TEST_SECURITY_VID = true
+LOSCFG_USER_TEST_SECURITY_REUGID = true
+LOSCFG_USER_TEST_SIGNAL = true
+LOSCFG_USER_TEST_SYS = true
+LOSCFG_USER_TEST_TIME_CLOCK = true
+LOSCFG_USER_TEST_TIME_TIMER = true
+LOSCFG_USER_TEST_UTIL = true
+LOSCFG_USER_TEST_NET_NETDB = true
+LOSCFG_USER_TEST_NET_RESOLV = true
+LOSCFG_USER_TEST_NET_SOCKET = true
+LOSCFG_USER_TEST_IPC = false
+LOSCFG_USER_TEST_LITEIPC = false
+LOSCFG_USER_TEST_FS_JFFS = false
+LOSCFG_USER_TEST_FS_VFAT = false
diff --git a/testsuites/unittest/drivers/hid/BUILD.gn b/testsuites/unittest/drivers/hid/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..7e6afb1b34e3ad12a78b04b2bc6b6af5d2603105
--- /dev/null
+++ b/testsuites/unittest/drivers/hid/BUILD.gn
@@ -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.
+
+import("//build/lite/config/test.gni")
+import("../../config.gni")
+
+unittest("liteos_a_drivers_hid_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../../common/include",
+ "../../drivers/hid",
+ ]
+ sources = [
+ "../../common/osTest.cpp",
+ "drivers_hid_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_SMOKE == true) {
+ sources_smoke = [
+ "smoke/hid_test_001.cpp",
+ ]
+ sources += sources_smoke
+ }
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+ configs = [ "../..:public_config" ]
+}
diff --git a/testsuites/unittest/drivers/hid/drivers_hid_test.cpp b/testsuites/unittest/drivers/hid/drivers_hid_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1120011d744eccb50a9f2e4b5798303f6df90bd0
--- /dev/null
+++ b/testsuites/unittest/drivers/hid/drivers_hid_test.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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
+#include
+#include "it_test_hid.h"
+
+using namespace testing::ext;
+namespace OHOS {
+class DriversHidTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_SMOKE)
+/* *
+ * @tc.name: it_test_hid_001
+ * @tc.desc: function for drivers hid
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(DriversHidTest, ItTestHid001, TestSize.Level0)
+{
+ ItTestHid001();
+}
+#endif
+} // namespace OHOS
diff --git a/testsuites/unittest/drivers/hid/it_test_hid.h b/testsuites/unittest/drivers/hid/it_test_hid.h
new file mode 100644
index 0000000000000000000000000000000000000000..e948b34964958e59a16e479c4c50e8285cfd307b
--- /dev/null
+++ b/testsuites/unittest/drivers/hid/it_test_hid.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _IT_TEST_DRIVERS_HID_H
+#define _IT_TEST_DRIVERS_HID_H
+
+#include "osTest.h"
+#include "poll.h"
+
+extern void ItTestHid001(void);
+
+#endif
diff --git a/testsuites/unittest/drivers/hid/smoke/hid_test_001.cpp b/testsuites/unittest/drivers/hid/smoke/hid_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d78847103bb9a1f4678b7a384b16167c1fc1bb4f
--- /dev/null
+++ b/testsuites/unittest/drivers/hid/smoke/hid_test_001.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_hid.h"
+#include "fcntl.h"
+#include "sys/ioctl.h"
+
+#define MOUSE_DEV_PATH "/dev/usb/uhid0"
+#define MOUSE_DATA_LEN 5
+#define MOUSE_TEST_COUNT 20
+#define MOUSE_WAIT_TIME 1000
+
+#define USB_GET_REPORT_ID _IOR('U', 25, int)
+
+static int Testcase(VOID)
+{
+ int ret;
+ int fd = -1;
+ int i;
+ struct pollfd pfds[1];
+ char *buf = NULL;
+ int id = -1;
+
+ ret = access(MOUSE_DEV_PATH, 0);
+ if (!ret) {
+ fd = open(MOUSE_DEV_PATH, O_RDWR, 0666);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+
+ buf = (char *)malloc(MOUSE_DATA_LEN);
+ ICUNIT_ASSERT_NOT_EQUAL(buf, NULL, buf);
+ (void)memset_s(buf, MOUSE_DATA_LEN, 0, MOUSE_DATA_LEN);
+
+ ret = ioctl(fd, USB_GET_REPORT_ID, &id);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(id, 0, id);
+
+ printf("Reading mouse data ... \n");
+ for (i = 0; i < MOUSE_TEST_COUNT; i++) {
+ pfds[0].fd = fd;
+ pfds[0].events = POLLIN;
+
+ ret = poll(pfds, 1, MOUSE_WAIT_TIME);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ if (ret == 0) {
+ continue;
+ } else {
+ printf("read ...\n");
+ read(fd, buf, MOUSE_DATA_LEN);
+ printf("mouse data [%#x %#x %#x %#x]\n", buf[0], buf[1], buf[2], buf[3]);
+ }
+ }
+ ret = close(fd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ free(buf);
+ }
+
+ return 0;
+}
+
+void ItTestHid001(void)
+{
+ TEST_ADD_CASE("IT_DRIVERS_HID_001", Testcase, TEST_LOS, TEST_DRIVERBASE, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/drivers/storage/BUILD.gn b/testsuites/unittest/drivers/storage/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..43324c529f48ce874eb575bf56cf30106ba80704
--- /dev/null
+++ b/testsuites/unittest/drivers/storage/BUILD.gn
@@ -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.
+
+import("//build/lite/config/test.gni")
+import("../../config.gni")
+
+unittest("liteos_a_drivers_storage_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../../common/include",
+ "../../drivers/storage",
+ ]
+ sources = [
+ "../../common/osTest.cpp",
+ "drivers_storage_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_SMOKE == true) {
+ sources_smoke = [
+ "smoke/storage_test_001.cpp",
+ ]
+ sources += sources_smoke
+ }
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+ configs = [ "../..:public_config" ]
+}
diff --git a/testsuites/unittest/drivers/storage/drivers_storage_test.cpp b/testsuites/unittest/drivers/storage/drivers_storage_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fe69c0e574a0e0b682d269068eedd4f25c7c5c1d
--- /dev/null
+++ b/testsuites/unittest/drivers/storage/drivers_storage_test.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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
+#include
+#include "it_test_storage.h"
+
+using namespace testing::ext;
+namespace OHOS {
+class DriversStorageTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_SMOKE)
+/* *
+ * @tc.name: it_test_storage_001
+ * @tc.desc: function for drivers storage
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(DriversStorageTest, ItTestStorage001, TestSize.Level0)
+{
+ ItTestStorage001();
+}
+#endif
+} // namespace OHOS
diff --git a/testsuites/unittest/drivers/storage/it_test_storage.h b/testsuites/unittest/drivers/storage/it_test_storage.h
new file mode 100644
index 0000000000000000000000000000000000000000..5c1ab7774d781beec8ab11a3d4f956d8eff37f07
--- /dev/null
+++ b/testsuites/unittest/drivers/storage/it_test_storage.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _IT_TEST_DRIVERS_STORAGE_H
+#define _IT_TEST_DRIVERS_STORAGE_H
+
+#include "osTest.h"
+#include "poll.h"
+
+extern void ItTestStorage001(void);
+
+#endif
diff --git a/testsuites/unittest/drivers/storage/smoke/storage_test_001.cpp b/testsuites/unittest/drivers/storage/smoke/storage_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9e35c78f9288945dd721ada56a86b208cd167077
--- /dev/null
+++ b/testsuites/unittest/drivers/storage/smoke/storage_test_001.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_storage.h"
+#include "fcntl.h"
+#include "sys/ioctl.h"
+
+#define STORAGE_DEV_PATH "/dev/sdap0"
+#define STORAGE_DATA_LEN 32
+#define DIOC_GETPRIV 0x1000
+#define INVALID_PTR 0x11111111
+
+static int Testcase(VOID)
+{
+ int ret;
+ int fd = -1;
+ int i;
+ ssize_t n;
+ char *buf = NULL;
+ void *bch = NULL;
+
+ ret = access(STORAGE_DEV_PATH, 0);
+ if (!ret) {
+ fd = open(STORAGE_DEV_PATH, O_RDWR, 0666);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+
+ buf = (char *)malloc(STORAGE_DATA_LEN);
+ ICUNIT_ASSERT_NOT_EQUAL(buf, NULL, buf);
+ (void)memset_s(buf, STORAGE_DATA_LEN, 0, STORAGE_DATA_LEN);
+
+ ret = ioctl(fd, DIOC_GETPRIV, &bch);
+ printf("bch = %#x, &bch = %#x, errno = %d\n", bch, &bch, errno);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+
+ printf("Reading storage data ... \n");
+ n = read(fd, buf, STORAGE_DATA_LEN);
+ ICUNIT_ASSERT_EQUAL(n, STORAGE_DATA_LEN, n);
+ printf("storage data [%#x %#x %#x %#x]\n", buf[0], buf[1], buf[2], buf[3]);
+
+ n = read(fd, (void *)INVALID_PTR, STORAGE_DATA_LEN);
+ ICUNIT_ASSERT_NOT_EQUAL(n, STORAGE_DATA_LEN, n);
+
+ ret = close(fd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ free(buf);
+ }
+
+ return 0;
+}
+
+void ItTestStorage001(void)
+{
+ TEST_ADD_CASE("IT_DRIVERS_STORAGE_001", Testcase, TEST_LOS, TEST_DRIVERBASE, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/dynload/BUILD.gn b/testsuites/unittest/dynload/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..8ac18fd1d67e777f1b776108f135f8bc7038e619
--- /dev/null
+++ b/testsuites/unittest/dynload/BUILD.gn
@@ -0,0 +1,53 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../config.gni")
+
+unittest("liteos_a_dynload_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../common/include",
+ "../dynload",
+ ]
+ sources = [
+ "../common/osTest.cpp",
+ "dynload_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_SMOKE == true) {
+ sources_smoke = [
+ "smoke/dynload_test_002.cpp",
+ "smoke/dynload_test_004.cpp",
+ ]
+ sources += sources_smoke
+ }
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+ configs = [ "..:public_config" ]
+}
diff --git a/testsuites/unittest/dynload/dynload_test.cpp b/testsuites/unittest/dynload/dynload_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..937c109b5ac3d6ea62f24fa42dd68d3f571be023
--- /dev/null
+++ b/testsuites/unittest/dynload/dynload_test.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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
+#include
+
+#include "it_test_dynload.h"
+
+using namespace testing::ext;
+namespace OHOS {
+class DynloadTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_SMOKE)
+/* *
+ * @tc.name: it_test_dynload_002
+ * @tc.desc: function for DynloadTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(DynloadTest, ItTestDynload002, TestSize.Level0)
+{
+ ItTestDynload002();
+}
+
+/* *
+ * @tc.name: it_test_dynload_004
+ * @tc.desc: function for DynloadTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(DynloadTest, ItTestDynload004, TestSize.Level0)
+{
+ ItTestDynload004();
+}
+#endif
+} // namespace OHOS
diff --git a/testsuites/unittest/dynload/it_test_dynload.h b/testsuites/unittest/dynload/it_test_dynload.h
new file mode 100644
index 0000000000000000000000000000000000000000..50f33c37cb0113864ba8713f7468616c831356da
--- /dev/null
+++ b/testsuites/unittest/dynload/it_test_dynload.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _IT_TEST_DYNLOAD_H
+#define _IT_TEST_DYNLOAD_H
+
+#include "osTest.h"
+#include
+#include
+
+extern void ItTestDynload002(void);
+extern void it_test_dynload_003(void);
+extern void ItTestDynload004(void);
+#endif
diff --git a/testsuites/unittest/dynload/smoke/dynload_test_002.cpp b/testsuites/unittest/dynload/smoke/dynload_test_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0c2e5f5acef3ed7021df07026708c1c0017246e3
--- /dev/null
+++ b/testsuites/unittest/dynload/smoke/dynload_test_002.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_dynload.h"
+#include
+
+#define LIBCSO_REAL_PATH "/lib/libc.so"
+#define LIBCSO_RELATIVE_PATH "../../lib/libc.so"
+#define SYMBOL_TO_FIND "printf"
+#define SYMBOL_TO_MATCH (void *)printf
+
+static int Testcase(void)
+{
+ int ret;
+ char *workingPath = "/usr/bin";
+ void *handle = nullptr;
+ int (*func)(int);
+
+ ret = chdir(workingPath);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ handle = dlopen(NULL, RTLD_NOW | RTLD_LOCAL);
+ ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
+
+ ret = dlclose(handle);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ handle = dlopen(LIBCSO_REAL_PATH, RTLD_NOW);
+ ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
+
+ func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND);
+ ICUNIT_ASSERT_NOT_EQUAL(func, NULL, func);
+ ICUNIT_ASSERT_EQUAL(func, SYMBOL_TO_MATCH, func);
+
+ ret = dlclose(handle);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ handle = dlopen(LIBCSO_RELATIVE_PATH, RTLD_NOW);
+ ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
+
+ func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND);
+ ICUNIT_ASSERT_NOT_EQUAL(func, NULL, func);
+
+ ret = dlclose(handle);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+void ItTestDynload002(void)
+{
+ TEST_ADD_CASE("IT_TEST_DYNLOAD_002", Testcase, TEST_EXTEND, TEST_DYNLOAD, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/dynload/smoke/dynload_test_004.cpp b/testsuites/unittest/dynload/smoke/dynload_test_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9ff3ab7fb26c88606694bcac1ec5deced31d4c5d
--- /dev/null
+++ b/testsuites/unittest/dynload/smoke/dynload_test_004.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_dynload.h"
+#include
+
+#define LIBCSO_REAL_PATH "/lib/libc.so"
+#define INVALID_MODE (-1)
+#define MODE_WITHOUT_NOW_AND_LAZY (RTLD_NOLOAD | RTLD_GLOBAL | RTLD_LOCAL | RTLD_NODELETE)
+#define INVALID_FILENAME (char *)((void *)0)
+
+static int Testcase(void)
+{
+ int ret;
+ void *handle = nullptr;
+
+ handle = dlopen(LIBCSO_REAL_PATH, 0);
+ ICUNIT_ASSERT_EQUAL(handle, NULL, handle);
+
+ handle = dlopen(LIBCSO_REAL_PATH, INVALID_MODE);
+ ICUNIT_ASSERT_EQUAL(handle, NULL, handle);
+
+ handle = dlopen(LIBCSO_REAL_PATH, MODE_WITHOUT_NOW_AND_LAZY);
+ ICUNIT_ASSERT_EQUAL(handle, NULL, handle);
+
+ handle = dlopen(INVALID_FILENAME, 0);
+ ICUNIT_ASSERT_EQUAL(handle, NULL, handle);
+
+ handle = dlopen(INVALID_FILENAME, INVALID_MODE);
+ ICUNIT_ASSERT_EQUAL(handle, NULL, handle);
+
+ handle = dlopen(INVALID_FILENAME, MODE_WITHOUT_NOW_AND_LAZY);
+ ICUNIT_ASSERT_EQUAL(handle, NULL, handle);
+
+ handle = dlopen(INVALID_FILENAME, RTLD_NOW);
+ ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
+
+ ret = dlclose(handle);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+void ItTestDynload004(void)
+{
+ TEST_ADD_CASE("IT_TEST_DYNLOAD_004", Testcase, TEST_EXTEND, TEST_DYNLOAD, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/exc/BUILD.gn b/testsuites/unittest/exc/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..292980f793dacbf3d4e796679acf6c118fe9c37d
--- /dev/null
+++ b/testsuites/unittest/exc/BUILD.gn
@@ -0,0 +1,57 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../config.gni")
+
+unittest("liteos_a_exc_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../common/include",
+ "../exc",
+ ]
+ sources = [
+ "../common/osTest.cpp",
+ "exc_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_FULL == true) {
+ sources_full = [
+ "full/it_test_exc_001.cpp",
+ "full/it_test_exc_002.cpp",
+ "full/it_test_exc_003.cpp",
+ "full/it_test_exc_004.cpp",
+ "full/it_test_exc_005.cpp",
+ "full/it_test_fexecve_001.cpp",
+ ]
+ sources += sources_full
+ }
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+ configs = [ "..:public_config" ]
+}
diff --git a/testsuites/unittest/exc/exc_test.cpp b/testsuites/unittest/exc/exc_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..655d88ddfa3db9a56776d11a046b443029e05412
--- /dev/null
+++ b/testsuites/unittest/exc/exc_test.cpp
@@ -0,0 +1,100 @@
+/*
+ * 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
+#include
+
+#include "it_test_exc.h"
+
+using namespace testing::ext;
+namespace OHOS {
+class ExcTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_FULL)
+/* *
+ * @tc.name: ItTestExc005
+ * @tc.desc: function for ExcTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(ExcTest, ItTestExc005, TestSize.Level0)
+{
+ ItTestExc005();
+}
+
+/* *
+ * @tc.name: ItTestExc001
+ * @tc.desc: function for ExcTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(ExcTest, ItTestExc001, TestSize.Level0)
+{
+ ItTestExc001();
+}
+
+/* *
+ * @tc.name: ItTestExc002
+ * @tc.desc: function for ExcTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(ExcTest, ItTestExc002, TestSize.Level0)
+{
+ ItTestExc002();
+}
+
+/* *
+ * @tc.name: ItTestExc003
+ * @tc.desc: function for ExcTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(ExcTest, ItTestExc003, TestSize.Level0)
+{
+ ItTestExc003();
+}
+
+/* *
+ * @tc.name: ItTestExc004
+ * @tc.desc: function for ExcTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(ExcTest, ItTestExc004, TestSize.Level0)
+{
+ ItTestExc004();
+}
+#endif
+} // namespace OHOS
diff --git a/testsuites/unittest/exc/full/it_test_exc_001.cpp b/testsuites/unittest/exc/full/it_test_exc_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b7330789a2562a0b850ec8bc79dda356e88d6977
--- /dev/null
+++ b/testsuites/unittest/exc/full/it_test_exc_001.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_exc.h"
+
+static int TestCase(void)
+{
+ int ret;
+ int *test = NULL;
+ int status = 0;
+ pid_t pid = fork();
+ ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
+ if (pid == 0) {
+ *test = 0x1;
+ exit(0);
+ }
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+ ret = WIFEXITED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = WIFSIGNALED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+ ret = WTERMSIG(status);
+ ICUNIT_ASSERT_EQUAL(ret, SIGUSR2, ret);
+
+ pid = fork();
+ ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
+ if (pid == 0) {
+ *test = 0x1;
+ exit(0);
+ }
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+ ret = WIFEXITED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = WIFSIGNALED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+ ret = WTERMSIG(status);
+ ICUNIT_ASSERT_EQUAL(ret, SIGUSR2, ret);
+
+ return 0;
+}
+
+void ItTestExc001(void)
+{
+ TEST_ADD_CASE("IT_TEST_EXC_001", TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/exc/full/it_test_exc_002.cpp b/testsuites/unittest/exc/full/it_test_exc_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..45b941f115ea318a160c08b60101395118819ea9
--- /dev/null
+++ b/testsuites/unittest/exc/full/it_test_exc_002.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_exc.h"
+#include "pthread.h"
+
+static void *ThreadFunc2(void *arg)
+{
+ while (1) {
+ }
+
+ return nullptr;
+}
+
+static void *ThreadFunc1(void *arg)
+{
+ int *test = nullptr;
+ *test = 0x1;
+
+ while (1) {
+ }
+ return nullptr;
+}
+
+static int TestThread(void)
+{
+ pthread_t newThread;
+ int ret;
+ int currThreadPolicy = 3;
+ int currThreadPri;
+ pthread_attr_t a = { 0 };
+ struct sched_param param = { 0 };
+ int count = 5;
+ while (count > 0) {
+ ret = pthread_create(&newThread, nullptr, ThreadFunc2, nullptr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ count--;
+ }
+
+ ret = pthread_getschedparam(pthread_self(), &currThreadPolicy, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ currThreadPri = param.sched_priority;
+
+ ret = pthread_attr_init(&a);
+ param.sched_priority = currThreadPri - 1;
+ pthread_attr_setschedparam(&a, ¶m);
+ ret = pthread_create(&newThread, &a, ThreadFunc1, nullptr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+static int TestCase(void)
+{
+ int *test = nullptr;
+ int count = 5;
+ int status = 0;
+ int ret;
+ pid_t pid = fork();
+ ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
+ if (pid == 0) {
+ (void)TestThread();
+ while (1) {
+ }
+ }
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+ ret = WIFEXITED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = WIFSIGNALED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+ ret = WTERMSIG(status);
+ ICUNIT_ASSERT_EQUAL(ret, SIGUSR2, ret);
+
+ return 0;
+}
+
+void ItTestExc002(void)
+{
+ TEST_ADD_CASE("IT_TEST_EXC_002", TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/exc/full/it_test_exc_003.cpp b/testsuites/unittest/exc/full/it_test_exc_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c275cd655010d10f7ad108871fc87c7cba786351
--- /dev/null
+++ b/testsuites/unittest/exc/full/it_test_exc_003.cpp
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_exc.h"
+#include "pthread.h"
+
+#define TEST_THREAD_COUNT 5
+static volatile int g_testCondFlag;
+static int g_count[TEST_THREAD_COUNT];
+static void *ThreadFunc2(void *arg)
+{
+ int count = *(int *)arg;
+ int *test = nullptr;
+
+ g_testCondFlag++;
+
+ while (g_testCondFlag < 2) {
+ }
+
+ *test = 0x1;
+
+ while (1) {
+ }
+
+ return nullptr;
+}
+
+static int TestThread(void)
+{
+ pthread_t newThread;
+ int ret;
+ int currThreadPolicy = 3;
+ int currThreadPri;
+ pthread_attr_t a = { 0 };
+ struct sched_param param = { 0 };
+ int count = 0;
+
+ ret = pthread_getschedparam(pthread_self(), &currThreadPolicy, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ currThreadPri = param.sched_priority;
+
+ ret = pthread_attr_init(&a);
+ param.sched_priority = currThreadPri + 1;
+ pthread_attr_setschedparam(&a, ¶m);
+
+ while (count < TEST_THREAD_COUNT) {
+ g_count[count] = count;
+ ret = pthread_create(&newThread, &a, ThreadFunc2, &g_count[count]);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ count++;
+ }
+
+ ret = pthread_join(newThread, nullptr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+static int TestCase(void)
+{
+ int *test = nullptr;
+ int count = 5;
+ int status = 0;
+ int ret;
+
+ g_testCondFlag = 0;
+
+ pid_t pid = fork();
+ ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
+ if (pid == 0) {
+ (void)TestThread();
+ while (1) {
+ }
+ }
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+ ret = WIFEXITED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = WIFSIGNALED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+ ret = WTERMSIG(status);
+ ICUNIT_ASSERT_EQUAL(ret, SIGUSR2, ret);
+ return 0;
+}
+
+void ItTestExc003(void)
+{
+ TEST_ADD_CASE("IT_TEST_EXC_003", TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/exc/full/it_test_exc_004.cpp b/testsuites/unittest/exc/full/it_test_exc_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6ad1462a57daab1f48b374c47fcb2d589bfaccb6
--- /dev/null
+++ b/testsuites/unittest/exc/full/it_test_exc_004.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_exc.h"
+#include "pthread.h"
+
+#define TEST_THREAD_COUNT 5
+
+static int TestThread(void)
+{
+ int *test = nullptr;
+ int ret;
+
+ pid_t pid = fork();
+ ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
+ if (pid == 0) {
+ *test = 0x1;
+ while (1) {
+ }
+ }
+
+ *test = 0x1;
+
+ ret = waitpid(pid, NULL, 0);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+
+ return 0;
+}
+
+static int TestCase(void)
+{
+ int *test = nullptr;
+ int count = 5;
+ int status = 0;
+ int ret;
+
+ pid_t pid = fork();
+ ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
+ if (pid == 0) {
+ (void)TestThread();
+ while (1) {
+ }
+ }
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+ ret = WIFEXITED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = WIFSIGNALED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+ ret = WTERMSIG(status);
+ ICUNIT_ASSERT_EQUAL(ret, SIGUSR2, ret);
+ return 0;
+}
+
+void ItTestExc004(void)
+{
+ TEST_ADD_CASE("IT_TEST_EXC_004", TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/exc/full/it_test_exc_005.cpp b/testsuites/unittest/exc/full/it_test_exc_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..64c664727b734a3ad2b8e7bb136acbfbfe0b701f
--- /dev/null
+++ b/testsuites/unittest/exc/full/it_test_exc_005.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_exc.h"
+
+static void Child(void)
+{
+ while (1) {
+ printf("@@@@@@@@@@@@@ pid : %d getppid : %d @@@@@@@@@@@@@@@@\n", getpid(), getppid());
+ }
+}
+static void TestKill(int sig)
+{
+ exit(0);
+}
+
+static int TestCase(void)
+{
+ int ret;
+ void (*retptr)(int) = NULL;
+ int *test = NULL;
+ int status = 0;
+ pid_t pid1;
+
+ retptr = signal(SIGTERM, TestKill);
+ ICUNIT_ASSERT_NOT_EQUAL(retptr, NULL, retptr);
+
+ pid_t pid = fork();
+ ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
+ if (pid == 0) {
+ Child();
+ exit(0);
+ }
+
+ for (int i = 0; i < 2; i++) {
+ pid1 = fork();
+ ICUNIT_ASSERT_WITHIN_EQUAL(pid1, 0, INVALID_PROCESS_ID, pid1);
+ if (pid1 == 0) {
+ *test = 0x1;
+ exit(0);
+ } else {
+ ret = waitpid(pid1, &status, 0);
+ ICUNIT_ASSERT_EQUAL(ret, pid1, ret);
+ }
+ }
+
+ kill(pid, SIGTERM);
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+
+ return 0;
+}
+
+void ItTestExc005(void)
+{
+ TEST_ADD_CASE("IT_TEST_EXC_005", TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/exc/full/it_test_fexecve_001.cpp b/testsuites/unittest/exc/full/it_test_fexecve_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e4cfa5eb891eb0db699ee126f350bfc93a6bb14a
--- /dev/null
+++ b/testsuites/unittest/exc/full/it_test_fexecve_001.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#define __USE_GUN
+#include "it_test_exc.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+static char *g_args[] = {
+ "hic et nunc",
+ "-l",
+ "/dev/shm",
+ nullptr
+};
+
+static int TestCase(void)
+{
+ struct stat st = {0};
+ void *p = nullptr;
+ int fd = 0;
+ int shmFd = 0;
+ int rc = 0;
+ int ret = 0;
+
+ shmFd = shm_open("wurstverschwendung", O_RDWR | O_CREAT, 0777);
+ if (shmFd == -1) {
+ perror("shm_open");
+ return -1;
+ }
+
+ rc = stat("/bin/shell", &st);
+ if (rc == -1) {
+ perror("stat");
+ return -1;
+ }
+
+ printf("shm_fd=%d,st.st_size=%lld\n", shmFd, st.st_size);
+ rc = ftruncate(shmFd, st.st_size);
+ if (rc == -1) {
+ perror("ftruncate");
+ return -1;
+ }
+
+ p = mmap(nullptr, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, shmFd, 0);
+ if (p == MAP_FAILED) {
+ perror("mmap");
+ return -1;
+ }
+
+ fd = open("/bin/shell", O_RDONLY, 0);
+ printf("fd=%d\n", fd);
+ if (fd == -1) {
+ perror("openls");
+ return -1;
+ }
+
+ rc = read(fd, p, st.st_size);
+ if (rc == -1) {
+ perror("read");
+ return -1;
+ }
+ if (rc != st.st_size) {
+ fputs("Strange situation!\n", stderr);
+ return -1;
+ }
+
+ munmap(p, st.st_size);
+ close(shmFd);
+
+ shmFd = shm_open("wurstverschwendung", O_RDONLY, 0);
+ ret = fexecve(shmFd, g_args, environ);
+ perror("fexecve");
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ return LOS_OK;
+}
+
+void ItTestFexecve001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/exc/it_test_exc.h b/testsuites/unittest/exc/it_test_exc.h
new file mode 100644
index 0000000000000000000000000000000000000000..e204898e228de11fecc280f75e583623996dd06a
--- /dev/null
+++ b/testsuites/unittest/exc/it_test_exc.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _IT_TEST_EXC_H
+#define _IT_TEST_EXC_H
+
+#include "osTest.h"
+
+#define INVALID_PROCESS_ID 100000
+extern void ItTestExc001(void);
+extern void ItTestExc002(void);
+extern void ItTestExc003(void);
+extern void ItTestExc004(void);
+extern void ItTestExc005(void);
+extern void ItTestFexecve001(void);
+
+#endif
diff --git a/testsuites/unittest/fs/BUILD.gn b/testsuites/unittest/fs/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..1e9d0e96253b9ced26d1866b57c8d1c7d74b559e
--- /dev/null
+++ b/testsuites/unittest/fs/BUILD.gn
@@ -0,0 +1,792 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../config.gni")
+
+unittest("liteos_a_fs_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "//kernel/liteos_a/testsuites/unittest/common/include",
+ "//kernel/liteos_a/testsuites/unittest/fs/vfs",
+ "//kernel/liteos_a/testsuites/unittest/fs/jffs",
+ ]
+ sources = [
+ "//kernel/liteos_a/testsuites/unittest/common/osTest.cpp",
+ "jffs/vfs_jffs_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_SMOKE == true) {
+ sources_smoke = [
+ "jffs/smoke/It_vfs_jffs_001.cpp",
+ "jffs/smoke/It_vfs_jffs_002.cpp",
+ "jffs/smoke/It_vfs_jffs_003.cpp",
+ "jffs/smoke/It_vfs_jffs_005.cpp",
+ "jffs/smoke/It_vfs_jffs_021.cpp",
+ "jffs/smoke/It_vfs_jffs_022.cpp",
+ "jffs/smoke/It_vfs_jffs_026.cpp",
+ "jffs/smoke/It_vfs_jffs_027.cpp",
+ "jffs/smoke/It_vfs_jffs_034.cpp",
+ "jffs/smoke/It_vfs_jffs_035.cpp",
+ "jffs/smoke/It_vfs_jffs_094.cpp",
+ "jffs/smoke/It_vfs_jffs_095.cpp",
+ #"jffs/smoke/It_vfs_jffs_103.cpp",
+ "jffs/smoke/It_vfs_jffs_535.cpp",
+ "jffs/smoke/It_vfs_jffs_Dac_001.cpp",
+ ]
+ sources += sources_smoke
+ }
+ if (LOSCFG_USER_TEST_PRESSURE == true) {
+ sources_pressure = [
+ "jffs/pressure/It_fs_jffs_performance_001.cpp",
+ "jffs/pressure/It_fs_jffs_performance_002.cpp",
+ "jffs/pressure/It_fs_jffs_performance_003.cpp",
+ "jffs/pressure/It_fs_jffs_performance_004.cpp",
+ "jffs/pressure/It_fs_jffs_performance_005.cpp",
+ "jffs/pressure/It_fs_jffs_performance_006.cpp",
+ "jffs/pressure/It_fs_jffs_performance_007.cpp",
+ "jffs/pressure/It_fs_jffs_performance_008.cpp",
+ "jffs/pressure/It_fs_jffs_performance_009.cpp",
+ "jffs/pressure/It_fs_jffs_performance_010.cpp",
+ "jffs/pressure/It_fs_jffs_performance_011.cpp",
+ "jffs/pressure/It_fs_jffs_performance_012.cpp",
+ "jffs/pressure/It_fs_jffs_performance_013.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_001.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_002.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_003.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_004.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_005.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_006.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_007.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_008.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_009.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_010.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_011.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_012.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_014.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_015.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_016.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_017.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_018.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_019.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_020.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_021.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_022.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_023.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_024.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_025.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_026.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_027.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_028.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_029.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_030.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_031.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_032.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_033.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_034.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_035.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_036.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_037.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_038.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_039.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_040.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_041.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_042.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_043.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_044.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_045.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_046.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_047.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_048.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_049.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_050.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_051.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_052.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_053.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_301.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_302.cpp",
+ #"jffs/pressure/It_fs_jffs_pressure_303.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_304.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_305.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_306.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_307.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_308.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_309.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_310.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_311.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_312.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_313.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_314.cpp",
+ "jffs/pressure/It_fs_jffs_pressure_315.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_001.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_002.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_003.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_004.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_005.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_006.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_007.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_008.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_009.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_010.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_011.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_012.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_013.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_014.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_015.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_016.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_017.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_018.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_019.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_020.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_021.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_022.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_023.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_024.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_025.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_026.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_027.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_028.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_029.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_030.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_031.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_032.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_033.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_034.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_035.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_036.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_037.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_038.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_039.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_040.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_041.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_042.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_043.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_044.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_045.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_046.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_047.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_048.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_049.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_050.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_051.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_052.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_053.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_054.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_055.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_056.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_057.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_058.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_059.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_060.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_061.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_062.cpp",
+ "jffs/pressure/It_vfs_jffs_multipthread_063.cpp",
+ ]
+ sources += sources_pressure
+ }
+ if (LOSCFG_USER_TEST_FULL == true) {
+ sources_full = [
+ "jffs/full/It_jffs_001.cpp",
+ "jffs/full/It_jffs_002.cpp",
+ "jffs/full/It_jffs_003.cpp",
+ "jffs/full/It_jffs_004.cpp",
+ "jffs/full/It_jffs_005.cpp",
+ "jffs/full/It_jffs_006.cpp",
+ "jffs/full/It_jffs_007.cpp",
+ "jffs/full/It_jffs_008.cpp",
+ "jffs/full/It_jffs_009.cpp",
+ "jffs/full/It_jffs_010.cpp",
+ "jffs/full/It_jffs_011.cpp",
+ "jffs/full/It_jffs_012.cpp",
+ "jffs/full/It_jffs_013.cpp",
+ "jffs/full/It_jffs_014.cpp",
+ "jffs/full/It_jffs_015.cpp",
+ "jffs/full/It_jffs_016.cpp",
+ "jffs/full/It_jffs_017.cpp",
+ "jffs/full/It_jffs_018.cpp",
+ "jffs/full/It_jffs_019.cpp",
+ "jffs/full/It_jffs_020.cpp",
+ "jffs/full/It_jffs_021.cpp",
+ "jffs/full/It_jffs_022.cpp",
+ "jffs/full/It_jffs_023.cpp",
+ "jffs/full/It_jffs_024.cpp",
+ "jffs/full/It_jffs_025.cpp",
+ "jffs/full/It_jffs_026.cpp",
+ "jffs/full/It_jffs_027.cpp",
+ "jffs/full/It_jffs_028.cpp",
+ "jffs/full/It_jffs_029.cpp",
+ "jffs/full/It_jffs_030.cpp",
+ "jffs/full/It_jffs_031.cpp",
+ "jffs/full/It_jffs_032.cpp",
+ "jffs/full/It_jffs_033.cpp",
+ "jffs/full/It_jffs_034.cpp",
+ "jffs/full/It_jffs_035.cpp",
+ "jffs/full/It_jffs_036.cpp",
+ "jffs/full/It_jffs_037.cpp",
+ "jffs/full/It_jffs_038.cpp",
+ "jffs/full/It_jffs_039.cpp",
+ "jffs/full/It_jffs_040.cpp",
+ "jffs/full/It_jffs_041.cpp",
+ "jffs/full/It_jffs_042.cpp",
+ "jffs/full/It_jffs_043.cpp",
+ "jffs/full/It_jffs_044.cpp",
+ "jffs/full/It_vfs_jffs_004.cpp",
+ "jffs/full/It_vfs_jffs_006.cpp",
+ "jffs/full/It_vfs_jffs_007.cpp",
+ "jffs/full/It_vfs_jffs_008.cpp",
+ "jffs/full/It_vfs_jffs_009.cpp",
+ "jffs/full/It_vfs_jffs_010.cpp",
+ "jffs/full/It_vfs_jffs_011.cpp",
+ "jffs/full/It_vfs_jffs_012.cpp",
+ "jffs/full/It_vfs_jffs_013.cpp",
+ "jffs/full/It_vfs_jffs_014.cpp",
+ "jffs/full/It_vfs_jffs_015.cpp",
+ "jffs/full/It_vfs_jffs_016.cpp",
+ "jffs/full/It_vfs_jffs_017.cpp",
+ "jffs/full/It_vfs_jffs_018.cpp",
+ "jffs/full/It_vfs_jffs_019.cpp",
+ "jffs/full/It_vfs_jffs_020.cpp",
+ "jffs/full/It_vfs_jffs_023.cpp",
+ "jffs/full/It_vfs_jffs_024.cpp",
+ "jffs/full/It_vfs_jffs_025.cpp",
+ "jffs/full/It_vfs_jffs_028.cpp",
+ "jffs/full/It_vfs_jffs_029.cpp",
+ "jffs/full/It_vfs_jffs_030.cpp",
+ "jffs/full/It_vfs_jffs_031.cpp",
+ "jffs/full/It_vfs_jffs_032.cpp",
+ "jffs/full/It_vfs_jffs_033.cpp",
+ "jffs/full/It_vfs_jffs_037.cpp",
+ "jffs/full/It_vfs_jffs_038.cpp",
+ "jffs/full/It_vfs_jffs_039.cpp",
+ "jffs/full/It_vfs_jffs_040.cpp",
+ "jffs/full/It_vfs_jffs_041.cpp",
+ "jffs/full/It_vfs_jffs_042.cpp",
+ "jffs/full/It_vfs_jffs_043.cpp",
+ "jffs/full/It_vfs_jffs_044.cpp",
+ "jffs/full/It_vfs_jffs_045.cpp",
+ "jffs/full/It_vfs_jffs_046.cpp",
+ "jffs/full/It_vfs_jffs_048.cpp",
+ "jffs/full/It_vfs_jffs_049.cpp",
+ "jffs/full/It_vfs_jffs_050.cpp",
+ #"jffs/full/It_vfs_jffs_051.cpp",
+ "jffs/full/It_vfs_jffs_053.cpp",
+ "jffs/full/It_vfs_jffs_055.cpp",
+ "jffs/full/It_vfs_jffs_056.cpp",
+ "jffs/full/It_vfs_jffs_057.cpp",
+ "jffs/full/It_vfs_jffs_058.cpp",
+ "jffs/full/It_vfs_jffs_059.cpp",
+ "jffs/full/It_vfs_jffs_060.cpp",
+ "jffs/full/It_vfs_jffs_061.cpp",
+ "jffs/full/It_vfs_jffs_062.cpp",
+ "jffs/full/It_vfs_jffs_063.cpp",
+ "jffs/full/It_vfs_jffs_064.cpp",
+ "jffs/full/It_vfs_jffs_065.cpp",
+ "jffs/full/It_vfs_jffs_066.cpp",
+ "jffs/full/It_vfs_jffs_067.cpp",
+ "jffs/full/It_vfs_jffs_068.cpp",
+ "jffs/full/It_vfs_jffs_069.cpp",
+ "jffs/full/It_vfs_jffs_070.cpp",
+ "jffs/full/It_vfs_jffs_071.cpp",
+ "jffs/full/It_vfs_jffs_072.cpp",
+ "jffs/full/It_vfs_jffs_073.cpp",
+ "jffs/full/It_vfs_jffs_074.cpp",
+ "jffs/full/It_vfs_jffs_076.cpp",
+ "jffs/full/It_vfs_jffs_077.cpp",
+ "jffs/full/It_vfs_jffs_078.cpp",
+ "jffs/full/It_vfs_jffs_079.cpp",
+ "jffs/full/It_vfs_jffs_080.cpp",
+ "jffs/full/It_vfs_jffs_081.cpp",
+ "jffs/full/It_vfs_jffs_082.cpp",
+ "jffs/full/It_vfs_jffs_083.cpp",
+ "jffs/full/It_vfs_jffs_084.cpp",
+ "jffs/full/It_vfs_jffs_085.cpp",
+ "jffs/full/It_vfs_jffs_086.cpp",
+ "jffs/full/It_vfs_jffs_088.cpp",
+ "jffs/full/It_vfs_jffs_090.cpp",
+ "jffs/full/It_vfs_jffs_092.cpp",
+ "jffs/full/It_vfs_jffs_093.cpp",
+ "jffs/full/It_vfs_jffs_096.cpp",
+ "jffs/full/It_vfs_jffs_097.cpp",
+ "jffs/full/It_vfs_jffs_099.cpp",
+ "jffs/full/It_vfs_jffs_100.cpp",
+ "jffs/full/It_vfs_jffs_101.cpp",
+ "jffs/full/It_vfs_jffs_102.cpp",
+ "jffs/full/It_vfs_jffs_104.cpp",
+ "jffs/full/It_vfs_jffs_105.cpp",
+ "jffs/full/It_vfs_jffs_106.cpp",
+ "jffs/full/It_vfs_jffs_107.cpp",
+ "jffs/full/It_vfs_jffs_116.cpp",
+ "jffs/full/It_vfs_jffs_117.cpp",
+ "jffs/full/It_vfs_jffs_118.cpp",
+ "jffs/full/It_vfs_jffs_119.cpp",
+ "jffs/full/It_vfs_jffs_120.cpp",
+ "jffs/full/It_vfs_jffs_121.cpp",
+ "jffs/full/It_vfs_jffs_122.cpp",
+ "jffs/full/It_vfs_jffs_123.cpp",
+ "jffs/full/It_vfs_jffs_124.cpp",
+ "jffs/full/It_vfs_jffs_125.cpp",
+ "jffs/full/It_vfs_jffs_126.cpp",
+ "jffs/full/It_vfs_jffs_127.cpp",
+ "jffs/full/It_vfs_jffs_128.cpp",
+ "jffs/full/It_vfs_jffs_129.cpp",
+ "jffs/full/It_vfs_jffs_130.cpp",
+ "jffs/full/It_vfs_jffs_131.cpp",
+ "jffs/full/It_vfs_jffs_132.cpp",
+ "jffs/full/It_vfs_jffs_133.cpp",
+ "jffs/full/It_vfs_jffs_134.cpp",
+ "jffs/full/It_vfs_jffs_135.cpp",
+ "jffs/full/It_vfs_jffs_136.cpp",
+ "jffs/full/It_vfs_jffs_137.cpp",
+ "jffs/full/It_vfs_jffs_138.cpp",
+ "jffs/full/It_vfs_jffs_139.cpp",
+ "jffs/full/It_vfs_jffs_140.cpp",
+ "jffs/full/It_vfs_jffs_141.cpp",
+ "jffs/full/It_vfs_jffs_142.cpp",
+ "jffs/full/It_vfs_jffs_143.cpp",
+ "jffs/full/It_vfs_jffs_144.cpp",
+ "jffs/full/It_vfs_jffs_145.cpp",
+ "jffs/full/It_vfs_jffs_146.cpp",
+ "jffs/full/It_vfs_jffs_147.cpp",
+ "jffs/full/It_vfs_jffs_148.cpp",
+ "jffs/full/It_vfs_jffs_149.cpp",
+ "jffs/full/It_vfs_jffs_150.cpp",
+ "jffs/full/It_vfs_jffs_151.cpp",
+ "jffs/full/It_vfs_jffs_152.cpp",
+ "jffs/full/It_vfs_jffs_153.cpp",
+ "jffs/full/It_vfs_jffs_154.cpp",
+ "jffs/full/It_vfs_jffs_155.cpp",
+ "jffs/full/It_vfs_jffs_156.cpp",
+ "jffs/full/It_vfs_jffs_157.cpp",
+ "jffs/full/It_vfs_jffs_158.cpp",
+ "jffs/full/It_vfs_jffs_159.cpp",
+ "jffs/full/It_vfs_jffs_160.cpp",
+ "jffs/full/It_vfs_jffs_161.cpp",
+ "jffs/full/It_vfs_jffs_162.cpp",
+ "jffs/full/It_vfs_jffs_163.cpp",
+ "jffs/full/It_vfs_jffs_164.cpp",
+ "jffs/full/It_vfs_jffs_165.cpp",
+ "jffs/full/It_vfs_jffs_166.cpp",
+ "jffs/full/It_vfs_jffs_167.cpp",
+ "jffs/full/It_vfs_jffs_168.cpp",
+ "jffs/full/It_vfs_jffs_169.cpp",
+ "jffs/full/It_vfs_jffs_170.cpp",
+ "jffs/full/It_vfs_jffs_171.cpp",
+ "jffs/full/It_vfs_jffs_172.cpp",
+ "jffs/full/It_vfs_jffs_173.cpp",
+ "jffs/full/It_vfs_jffs_174.cpp",
+ "jffs/full/It_vfs_jffs_175.cpp",
+ "jffs/full/It_vfs_jffs_176.cpp",
+ "jffs/full/It_vfs_jffs_177.cpp",
+ "jffs/full/It_vfs_jffs_178.cpp",
+ "jffs/full/It_vfs_jffs_179.cpp",
+ "jffs/full/It_vfs_jffs_180.cpp",
+ "jffs/full/It_vfs_jffs_182.cpp",
+ "jffs/full/It_vfs_jffs_183.cpp",
+ "jffs/full/It_vfs_jffs_184.cpp",
+ "jffs/full/It_vfs_jffs_185.cpp",
+ "jffs/full/It_vfs_jffs_187.cpp",
+ "jffs/full/It_vfs_jffs_188.cpp",
+ "jffs/full/It_vfs_jffs_189.cpp",
+ "jffs/full/It_vfs_jffs_190.cpp",
+ "jffs/full/It_vfs_jffs_191.cpp",
+ "jffs/full/It_vfs_jffs_192.cpp",
+ "jffs/full/It_vfs_jffs_193.cpp",
+ "jffs/full/It_vfs_jffs_194.cpp",
+ "jffs/full/It_vfs_jffs_195.cpp",
+ "jffs/full/It_vfs_jffs_196.cpp",
+ "jffs/full/It_vfs_jffs_197.cpp",
+ "jffs/full/It_vfs_jffs_198.cpp",
+ "jffs/full/It_vfs_jffs_199.cpp",
+ "jffs/full/It_vfs_jffs_200.cpp",
+ "jffs/full/It_vfs_jffs_201.cpp",
+ "jffs/full/It_vfs_jffs_202.cpp",
+ "jffs/full/It_vfs_jffs_203.cpp",
+ "jffs/full/It_vfs_jffs_204.cpp",
+ "jffs/full/It_vfs_jffs_205.cpp",
+ "jffs/full/It_vfs_jffs_206.cpp",
+ "jffs/full/It_vfs_jffs_207.cpp",
+ "jffs/full/It_vfs_jffs_208.cpp",
+ "jffs/full/It_vfs_jffs_209.cpp",
+ "jffs/full/It_vfs_jffs_210.cpp",
+ "jffs/full/It_vfs_jffs_211.cpp",
+ "jffs/full/It_vfs_jffs_212.cpp",
+ "jffs/full/It_vfs_jffs_213.cpp",
+ "jffs/full/It_vfs_jffs_214.cpp",
+ "jffs/full/It_vfs_jffs_215.cpp",
+ "jffs/full/It_vfs_jffs_216.cpp",
+ "jffs/full/It_vfs_jffs_217.cpp",
+ "jffs/full/It_vfs_jffs_218.cpp",
+ "jffs/full/It_vfs_jffs_219.cpp",
+ "jffs/full/It_vfs_jffs_220.cpp",
+ "jffs/full/It_vfs_jffs_221.cpp",
+ "jffs/full/It_vfs_jffs_222.cpp",
+ "jffs/full/It_vfs_jffs_223.cpp",
+ "jffs/full/It_vfs_jffs_224.cpp",
+ "jffs/full/It_vfs_jffs_225.cpp",
+ "jffs/full/It_vfs_jffs_226.cpp",
+ "jffs/full/It_vfs_jffs_227.cpp",
+ "jffs/full/It_vfs_jffs_228.cpp",
+ "jffs/full/It_vfs_jffs_229.cpp",
+ "jffs/full/It_vfs_jffs_230.cpp",
+ "jffs/full/It_vfs_jffs_231.cpp",
+ "jffs/full/It_vfs_jffs_232.cpp",
+ "jffs/full/It_vfs_jffs_233.cpp",
+ "jffs/full/It_vfs_jffs_234.cpp",
+ "jffs/full/It_vfs_jffs_235.cpp",
+ "jffs/full/It_vfs_jffs_236.cpp",
+ "jffs/full/It_vfs_jffs_237.cpp",
+ "jffs/full/It_vfs_jffs_238.cpp",
+ "jffs/full/It_vfs_jffs_239.cpp",
+ "jffs/full/It_vfs_jffs_240.cpp",
+ "jffs/full/It_vfs_jffs_241.cpp",
+ "jffs/full/It_vfs_jffs_242.cpp",
+ "jffs/full/It_vfs_jffs_243.cpp",
+ "jffs/full/It_vfs_jffs_244.cpp",
+ "jffs/full/It_vfs_jffs_245.cpp",
+ "jffs/full/It_vfs_jffs_246.cpp",
+ "jffs/full/It_vfs_jffs_247.cpp",
+ "jffs/full/It_vfs_jffs_248.cpp",
+ "jffs/full/It_vfs_jffs_249.cpp",
+ "jffs/full/It_vfs_jffs_250.cpp",
+ "jffs/full/It_vfs_jffs_251.cpp",
+ "jffs/full/It_vfs_jffs_252.cpp",
+ "jffs/full/It_vfs_jffs_253.cpp",
+ "jffs/full/It_vfs_jffs_254.cpp",
+ "jffs/full/It_vfs_jffs_255.cpp",
+ "jffs/full/It_vfs_jffs_256.cpp",
+ "jffs/full/It_vfs_jffs_257.cpp",
+ "jffs/full/It_vfs_jffs_258.cpp",
+ "jffs/full/It_vfs_jffs_259.cpp",
+ "jffs/full/It_vfs_jffs_260.cpp",
+ "jffs/full/It_vfs_jffs_261.cpp",
+ "jffs/full/It_vfs_jffs_262.cpp",
+ "jffs/full/It_vfs_jffs_263.cpp",
+ "jffs/full/It_vfs_jffs_264.cpp",
+ "jffs/full/It_vfs_jffs_265.cpp",
+ "jffs/full/It_vfs_jffs_266.cpp",
+ "jffs/full/It_vfs_jffs_267.cpp",
+ "jffs/full/It_vfs_jffs_268.cpp",
+ "jffs/full/It_vfs_jffs_269.cpp",
+ "jffs/full/It_vfs_jffs_270.cpp",
+ "jffs/full/It_vfs_jffs_271.cpp",
+ "jffs/full/It_vfs_jffs_272.cpp",
+ "jffs/full/It_vfs_jffs_273.cpp",
+ "jffs/full/It_vfs_jffs_274.cpp",
+ "jffs/full/It_vfs_jffs_275.cpp",
+ "jffs/full/It_vfs_jffs_276.cpp",
+ "jffs/full/It_vfs_jffs_277.cpp",
+ "jffs/full/It_vfs_jffs_278.cpp",
+ "jffs/full/It_vfs_jffs_279.cpp",
+ "jffs/full/It_vfs_jffs_280.cpp",
+ "jffs/full/It_vfs_jffs_281.cpp",
+ "jffs/full/It_vfs_jffs_282.cpp",
+ "jffs/full/It_vfs_jffs_283.cpp",
+ "jffs/full/It_vfs_jffs_284.cpp",
+ "jffs/full/It_vfs_jffs_285.cpp",
+ "jffs/full/It_vfs_jffs_286.cpp",
+ "jffs/full/It_vfs_jffs_287.cpp",
+ "jffs/full/It_vfs_jffs_288.cpp",
+ "jffs/full/It_vfs_jffs_289.cpp",
+ "jffs/full/It_vfs_jffs_290.cpp",
+ "jffs/full/It_vfs_jffs_291.cpp",
+ "jffs/full/It_vfs_jffs_292.cpp",
+ "jffs/full/It_vfs_jffs_293.cpp",
+ "jffs/full/It_vfs_jffs_294.cpp",
+ "jffs/full/It_vfs_jffs_295.cpp",
+ "jffs/full/It_vfs_jffs_296.cpp",
+ "jffs/full/It_vfs_jffs_297.cpp",
+ "jffs/full/It_vfs_jffs_298.cpp",
+ "jffs/full/It_vfs_jffs_299.cpp",
+ "jffs/full/It_vfs_jffs_300.cpp",
+ "jffs/full/It_vfs_jffs_301.cpp",
+ "jffs/full/It_vfs_jffs_302.cpp",
+ "jffs/full/It_vfs_jffs_303.cpp",
+ "jffs/full/It_vfs_jffs_304.cpp",
+ "jffs/full/It_vfs_jffs_305.cpp",
+ "jffs/full/It_vfs_jffs_306.cpp",
+ "jffs/full/It_vfs_jffs_307.cpp",
+ "jffs/full/It_vfs_jffs_308.cpp",
+ "jffs/full/It_vfs_jffs_309.cpp",
+ "jffs/full/It_vfs_jffs_310.cpp",
+ "jffs/full/It_vfs_jffs_311.cpp",
+ "jffs/full/It_vfs_jffs_312.cpp",
+ "jffs/full/It_vfs_jffs_313.cpp",
+ "jffs/full/It_vfs_jffs_314.cpp",
+ "jffs/full/It_vfs_jffs_315.cpp",
+ "jffs/full/It_vfs_jffs_316.cpp",
+ "jffs/full/It_vfs_jffs_317.cpp",
+ "jffs/full/It_vfs_jffs_318.cpp",
+ "jffs/full/It_vfs_jffs_319.cpp",
+ "jffs/full/It_vfs_jffs_320.cpp",
+ "jffs/full/It_vfs_jffs_321.cpp",
+ "jffs/full/It_vfs_jffs_322.cpp",
+ "jffs/full/It_vfs_jffs_323.cpp",
+ "jffs/full/It_vfs_jffs_324.cpp",
+ "jffs/full/It_vfs_jffs_325.cpp",
+ "jffs/full/It_vfs_jffs_326.cpp",
+ "jffs/full/It_vfs_jffs_327.cpp",
+ "jffs/full/It_vfs_jffs_328.cpp",
+ "jffs/full/It_vfs_jffs_329.cpp",
+ "jffs/full/It_vfs_jffs_330.cpp",
+ "jffs/full/It_vfs_jffs_331.cpp",
+ "jffs/full/It_vfs_jffs_332.cpp",
+ "jffs/full/It_vfs_jffs_333.cpp",
+ "jffs/full/It_vfs_jffs_334.cpp",
+ "jffs/full/It_vfs_jffs_335.cpp",
+ "jffs/full/It_vfs_jffs_336.cpp",
+ "jffs/full/It_vfs_jffs_337.cpp",
+ "jffs/full/It_vfs_jffs_338.cpp",
+ "jffs/full/It_vfs_jffs_339.cpp",
+ "jffs/full/It_vfs_jffs_340.cpp",
+ "jffs/full/It_vfs_jffs_342.cpp",
+ "jffs/full/It_vfs_jffs_343.cpp",
+ "jffs/full/It_vfs_jffs_344.cpp",
+ "jffs/full/It_vfs_jffs_346.cpp",
+ "jffs/full/It_vfs_jffs_352.cpp",
+ "jffs/full/It_vfs_jffs_353.cpp",
+ "jffs/full/It_vfs_jffs_354.cpp",
+ "jffs/full/It_vfs_jffs_355.cpp",
+ "jffs/full/It_vfs_jffs_356.cpp",
+ "jffs/full/It_vfs_jffs_357.cpp",
+ "jffs/full/It_vfs_jffs_358.cpp",
+ "jffs/full/It_vfs_jffs_359.cpp",
+ "jffs/full/It_vfs_jffs_360.cpp",
+ "jffs/full/It_vfs_jffs_361.cpp",
+ "jffs/full/It_vfs_jffs_362.cpp",
+ "jffs/full/It_vfs_jffs_364.cpp",
+ "jffs/full/It_vfs_jffs_365.cpp",
+ "jffs/full/It_vfs_jffs_366.cpp",
+ "jffs/full/It_vfs_jffs_367.cpp",
+ "jffs/full/It_vfs_jffs_368.cpp",
+ "jffs/full/It_vfs_jffs_369.cpp",
+ "jffs/full/It_vfs_jffs_370.cpp",
+ "jffs/full/It_vfs_jffs_371.cpp",
+ "jffs/full/It_vfs_jffs_372.cpp",
+ "jffs/full/It_vfs_jffs_373.cpp",
+ "jffs/full/It_vfs_jffs_374.cpp",
+ "jffs/full/It_vfs_jffs_375.cpp",
+ "jffs/full/It_vfs_jffs_376.cpp",
+ "jffs/full/It_vfs_jffs_377.cpp",
+ "jffs/full/It_vfs_jffs_378.cpp",
+ "jffs/full/It_vfs_jffs_379.cpp",
+ "jffs/full/It_vfs_jffs_380.cpp",
+ "jffs/full/It_vfs_jffs_381.cpp",
+ "jffs/full/It_vfs_jffs_382.cpp",
+ "jffs/full/It_vfs_jffs_383.cpp",
+ "jffs/full/It_vfs_jffs_384.cpp",
+ "jffs/full/It_vfs_jffs_385.cpp",
+ "jffs/full/It_vfs_jffs_386.cpp",
+ "jffs/full/It_vfs_jffs_387.cpp",
+ "jffs/full/It_vfs_jffs_388.cpp",
+ "jffs/full/It_vfs_jffs_389.cpp",
+ "jffs/full/It_vfs_jffs_390.cpp",
+ "jffs/full/It_vfs_jffs_391.cpp",
+ "jffs/full/It_vfs_jffs_392.cpp",
+ "jffs/full/It_vfs_jffs_393.cpp",
+ "jffs/full/It_vfs_jffs_394.cpp",
+ "jffs/full/It_vfs_jffs_395.cpp",
+ "jffs/full/It_vfs_jffs_396.cpp",
+ "jffs/full/It_vfs_jffs_397.cpp",
+ "jffs/full/It_vfs_jffs_398.cpp",
+ "jffs/full/It_vfs_jffs_399.cpp",
+ "jffs/full/It_vfs_jffs_400.cpp",
+ "jffs/full/It_vfs_jffs_401.cpp",
+ "jffs/full/It_vfs_jffs_402.cpp",
+ "jffs/full/It_vfs_jffs_403.cpp",
+ "jffs/full/It_vfs_jffs_404.cpp",
+ "jffs/full/It_vfs_jffs_405.cpp",
+ "jffs/full/It_vfs_jffs_406.cpp",
+ "jffs/full/It_vfs_jffs_407.cpp",
+ "jffs/full/It_vfs_jffs_408.cpp",
+ "jffs/full/It_vfs_jffs_409.cpp",
+ "jffs/full/It_vfs_jffs_410.cpp",
+ "jffs/full/It_vfs_jffs_411.cpp",
+ "jffs/full/It_vfs_jffs_412.cpp",
+ "jffs/full/It_vfs_jffs_413.cpp",
+ "jffs/full/It_vfs_jffs_414.cpp",
+ "jffs/full/It_vfs_jffs_415.cpp",
+ "jffs/full/It_vfs_jffs_416.cpp",
+ "jffs/full/It_vfs_jffs_417.cpp",
+ "jffs/full/It_vfs_jffs_418.cpp",
+ "jffs/full/It_vfs_jffs_419.cpp",
+ "jffs/full/It_vfs_jffs_420.cpp",
+ "jffs/full/It_vfs_jffs_421.cpp",
+ "jffs/full/It_vfs_jffs_422.cpp",
+ "jffs/full/It_vfs_jffs_423.cpp",
+ "jffs/full/It_vfs_jffs_424.cpp",
+ "jffs/full/It_vfs_jffs_425.cpp",
+ "jffs/full/It_vfs_jffs_426.cpp",
+ "jffs/full/It_vfs_jffs_427.cpp",
+ "jffs/full/It_vfs_jffs_428.cpp",
+ "jffs/full/It_vfs_jffs_429.cpp",
+ "jffs/full/It_vfs_jffs_430.cpp",
+ "jffs/full/It_vfs_jffs_431.cpp",
+ "jffs/full/It_vfs_jffs_432.cpp",
+ "jffs/full/It_vfs_jffs_433.cpp",
+ "jffs/full/It_vfs_jffs_434.cpp",
+ "jffs/full/It_vfs_jffs_435.cpp",
+ "jffs/full/It_vfs_jffs_454.cpp",
+ "jffs/full/It_vfs_jffs_455.cpp",
+ "jffs/full/It_vfs_jffs_456.cpp",
+ "jffs/full/It_vfs_jffs_457.cpp",
+ "jffs/full/It_vfs_jffs_458.cpp",
+ "jffs/full/It_vfs_jffs_459.cpp",
+ "jffs/full/It_vfs_jffs_460.cpp",
+ "jffs/full/It_vfs_jffs_461.cpp",
+ "jffs/full/It_vfs_jffs_462.cpp",
+ "jffs/full/It_vfs_jffs_487.cpp",
+ "jffs/full/It_vfs_jffs_488.cpp",
+ "jffs/full/It_vfs_jffs_489.cpp",
+ "jffs/full/It_vfs_jffs_490.cpp",
+ "jffs/full/It_vfs_jffs_491.cpp",
+ "jffs/full/It_vfs_jffs_492.cpp",
+ "jffs/full/It_vfs_jffs_493.cpp",
+ "jffs/full/It_vfs_jffs_494.cpp",
+ "jffs/full/It_vfs_jffs_495.cpp",
+ "jffs/full/It_vfs_jffs_496.cpp",
+ "jffs/full/It_vfs_jffs_497.cpp",
+ "jffs/full/It_vfs_jffs_498.cpp",
+ "jffs/full/It_vfs_jffs_499.cpp",
+ "jffs/full/It_vfs_jffs_500.cpp",
+ "jffs/full/It_vfs_jffs_501.cpp",
+ "jffs/full/It_vfs_jffs_502.cpp",
+ "jffs/full/It_vfs_jffs_503.cpp",
+ "jffs/full/It_vfs_jffs_504.cpp",
+ "jffs/full/It_vfs_jffs_505.cpp",
+ "jffs/full/It_vfs_jffs_506.cpp",
+ "jffs/full/It_vfs_jffs_507.cpp",
+ "jffs/full/It_vfs_jffs_508.cpp",
+ "jffs/full/It_vfs_jffs_509.cpp",
+ "jffs/full/It_vfs_jffs_510.cpp",
+ "jffs/full/It_vfs_jffs_511.cpp",
+ "jffs/full/It_vfs_jffs_512.cpp",
+ "jffs/full/It_vfs_jffs_513.cpp",
+ "jffs/full/It_vfs_jffs_514.cpp",
+ "jffs/full/It_vfs_jffs_515.cpp",
+ "jffs/full/It_vfs_jffs_516.cpp",
+ "jffs/full/It_vfs_jffs_517.cpp",
+ "jffs/full/It_vfs_jffs_518.cpp",
+ "jffs/full/It_vfs_jffs_519.cpp",
+ "jffs/full/It_vfs_jffs_520.cpp",
+ "jffs/full/It_vfs_jffs_521.cpp",
+ "jffs/full/It_vfs_jffs_522.cpp",
+ "jffs/full/It_vfs_jffs_523.cpp",
+ "jffs/full/It_vfs_jffs_524.cpp",
+ "jffs/full/It_vfs_jffs_526.cpp",
+ "jffs/full/It_vfs_jffs_528.cpp",
+ "jffs/full/It_vfs_jffs_529.cpp",
+ "jffs/full/It_vfs_jffs_530.cpp",
+ "jffs/full/It_vfs_jffs_531.cpp",
+ "jffs/full/It_vfs_jffs_532.cpp",
+ "jffs/full/It_vfs_jffs_533.cpp",
+ "jffs/full/It_vfs_jffs_534.cpp",
+ "jffs/full/It_vfs_jffs_541.cpp",
+ "jffs/full/It_vfs_jffs_542.cpp",
+ "jffs/full/It_vfs_jffs_543.cpp",
+ "jffs/full/It_vfs_jffs_544.cpp",
+ "jffs/full/It_vfs_jffs_545.cpp",
+ "jffs/full/It_vfs_jffs_546.cpp",
+ "jffs/full/It_vfs_jffs_547.cpp",
+ "jffs/full/It_vfs_jffs_548.cpp",
+ "jffs/full/It_vfs_jffs_549.cpp",
+ "jffs/full/It_vfs_jffs_550.cpp",
+ "jffs/full/It_vfs_jffs_551.cpp",
+ "jffs/full/It_vfs_jffs_552.cpp",
+ "jffs/full/It_vfs_jffs_553.cpp",
+ "jffs/full/It_vfs_jffs_554.cpp",
+ "jffs/full/It_vfs_jffs_555.cpp",
+ "jffs/full/It_vfs_jffs_556.cpp",
+ "jffs/full/It_vfs_jffs_557.cpp",
+ "jffs/full/It_vfs_jffs_560.cpp",
+ "jffs/full/It_vfs_jffs_562.cpp",
+ "jffs/full/It_vfs_jffs_563.cpp",
+ "jffs/full/It_vfs_jffs_564.cpp",
+ "jffs/full/It_vfs_jffs_565.cpp",
+ "jffs/full/It_vfs_jffs_566.cpp",
+ "jffs/full/It_vfs_jffs_567.cpp",
+ "jffs/full/It_vfs_jffs_568.cpp",
+ "jffs/full/It_vfs_jffs_569.cpp",
+ "jffs/full/It_vfs_jffs_570.cpp",
+ "jffs/full/It_vfs_jffs_571.cpp",
+ "jffs/full/It_vfs_jffs_572.cpp",
+ "jffs/full/It_vfs_jffs_573.cpp",
+ "jffs/full/It_vfs_jffs_574.cpp",
+ "jffs/full/It_vfs_jffs_583.cpp",
+ "jffs/full/It_vfs_jffs_584.cpp",
+ "jffs/full/It_vfs_jffs_586.cpp",
+ "jffs/full/It_vfs_jffs_589.cpp",
+ "jffs/full/It_vfs_jffs_590.cpp",
+ "jffs/full/It_vfs_jffs_591.cpp",
+ "jffs/full/It_vfs_jffs_592.cpp",
+ "jffs/full/It_vfs_jffs_593.cpp",
+ "jffs/full/It_vfs_jffs_594.cpp",
+ "jffs/full/It_vfs_jffs_595.cpp",
+ "jffs/full/It_vfs_jffs_596.cpp",
+ "jffs/full/It_vfs_jffs_603.cpp",
+ "jffs/full/It_vfs_jffs_636.cpp",
+ "jffs/full/It_vfs_jffs_643.cpp",
+ "jffs/full/It_vfs_jffs_644.cpp",
+ "jffs/full/It_vfs_jffs_645.cpp",
+ "jffs/full/It_vfs_jffs_646.cpp",
+ "jffs/full/It_vfs_jffs_648.cpp",
+ "jffs/full/It_vfs_jffs_649.cpp",
+ "jffs/full/It_vfs_jffs_650.cpp",
+ "jffs/full/It_vfs_jffs_651.cpp",
+ "jffs/full/It_vfs_jffs_652.cpp",
+ "jffs/full/It_vfs_jffs_653.cpp",
+ "jffs/full/It_vfs_jffs_654.cpp",
+ "jffs/full/It_vfs_jffs_655.cpp",
+ "jffs/full/It_vfs_jffs_656.cpp",
+ "jffs/full/It_vfs_jffs_663.cpp",
+ "jffs/full/It_vfs_jffs_664.cpp",
+ "jffs/full/It_vfs_jffs_665.cpp",
+ "jffs/full/It_vfs_jffs_666.cpp",
+ "jffs/full/It_vfs_jffs_668.cpp",
+ "jffs/full/It_vfs_jffs_669.cpp",
+ "jffs/full/It_vfs_jffs_670.cpp",
+ "jffs/full/It_vfs_jffs_671.cpp",
+ "jffs/full/It_vfs_jffs_672.cpp",
+ "jffs/full/It_vfs_jffs_673.cpp",
+ "jffs/full/It_vfs_jffs_674.cpp",
+ "jffs/full/It_vfs_jffs_675.cpp",
+ "jffs/full/It_vfs_jffs_676.cpp",
+ "jffs/full/It_vfs_jffs_690.cpp",
+ "jffs/full/It_vfs_jffs_694.cpp",
+ "jffs/full/It_vfs_jffs_696.cpp",
+ "jffs/full/It_vfs_jffs_697.cpp",
+ "jffs/full/It_vfs_jffs_700.cpp",
+ "jffs/full/It_vfs_jffs_701.cpp",
+ "jffs/full/It_vfs_jffs_807.cpp",
+ "jffs/full/It_vfs_jffs_808.cpp",
+ ]
+ sources += sources_full
+ }
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+ configs = [ "//kernel/liteos_a/testsuites/unittest:public_config" ]
+}
diff --git a/testsuites/unittest/fs/jffs/It_vfs_jffs.h b/testsuites/unittest/fs/jffs/It_vfs_jffs.h
new file mode 100644
index 0000000000000000000000000000000000000000..7d5ac5220985423ba951c00fd6d9468532ec9ef3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/It_vfs_jffs.h
@@ -0,0 +1,1124 @@
+/*
+ * 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
+#include
+#include "sys/capability.h"
+#include "sys/ioctl.h"
+#include "sys/select.h"
+#include "sys/stat.h"
+#include "sys/statfs.h"
+#include "sys/types.h"
+#include "sys/uio.h"
+#include "syslog.h"
+
+#include "fcntl.h"
+#include "stdlib.h"
+#include "time.h"
+#include "unistd.h"
+#include "utime.h"
+
+#include "dirent.h"
+#include "ftw.h"
+#include "libgen.h"
+#include "limits.h"
+#include "los_typedef.h"
+#include "osTest.h"
+#include "pthread.h"
+#include "sched.h"
+#include "semaphore.h"
+#include "signal.h"
+#include "wchar.h"
+
+constexpr int F_RDO = 0x01; /* Read only */
+constexpr int F_HID = 0x02; /* Hidden */
+constexpr int F_SYS = 0x04; /* System */
+constexpr int F_ARC = 0x20; /* Archive */
+constexpr int CONFIG_NFILE_DESCRIPTORS = 512;
+constexpr int LOS_WAIT_FOREVER = 0xFFFFFFFF;
+#if 0
+constexpr int DT_UNKNOWN = 0;
+constexpr int DT_FIFO = 1;
+constexpr int DT_CHR = 2;
+constexpr int DT_DIR = 4;
+constexpr int DT_BLK = 6;
+constexpr int DT_REG = 8;
+constexpr int DT_LNK = 10;
+constexpr int DT_SOCK = 12;
+constexpr int DT_WHT = 14;
+constexpr int MS_RDONLY = 1;
+#endif
+
+#if 0
+constexpr const char* JFFS_MAIN_DIR0 = "/storage";
+constexpr const char* JFFS_MOUNT_DIR0 = "/storage";
+constexpr const char* JFFS_MAIN_DIR1 = "/storage1";
+constexpr const char* JFFS_PATH_NAME0 = "/storage/test";
+constexpr const char* JFFS_PATH_NAME01 = "/storage/test1";
+constexpr const char* JFFS_PATH_NAME02 = "/storage/test2";
+constexpr const char* JFFS_PATH_NAME00 = "/storage/test/test00";
+constexpr const char* JFFS_PATH_NAME11 = "/storage/test1/test11";
+constexpr const char* JFFS_PATH_NAME22 = "/storage/test2/test22";
+constexpr const char* JFFS_PATH_NAME_0 = "/storage/test/test0";
+constexpr const char* JFFS_PATH_NAME_01 = "/storage/test/test0/test1";
+constexpr const char* JFFS_PATH_NAME1 = "/storage1/test";
+constexpr const char* JFFS_DEV_PATH0 = "/dev/spinorblk2";
+constexpr const char* JFFS_DEV_PATH1 = "/dev/spinorblk1";
+constexpr const char* JFFS_FILESYS_TYPE = "jffs2";
+constexpr const char* JFFS_CHINESE_NAME1 = "���Ϻ�";
+constexpr const char* JFFS_BASE_DIR = "/";
+#endif
+
+#define JFFS_MAIN_DIR0 "/storage"
+#define JFFS_MOUNT_DIR0 "/storage"
+#define JFFS_MAIN_DIR1 "/storage1"
+#define JFFS_PATH_NAME0 "/storage/test"
+#define JFFS_PATH_NAME01 "/storage/test1"
+#define JFFS_PATH_NAME02 "/storage/test2"
+#define JFFS_PATH_NAME00 "/storage/test/test00"
+#define JFFS_PATH_NAME11 "/storage/test1/test11"
+#define JFFS_PATH_NAME22 "/storage/test2/test22"
+#define JFFS_PATH_NAME_0 "/storage/test/test0"
+#define JFFS_PATH_NAME_01 "/storage/test/test0/test1"
+#define JFFS_PATH_NAME1 "/storage1/test"
+#define JFFS_DEV_PATH0 "/dev/spinorblk2"
+#define JFFS_DEV_PATH1 "/dev/spinorblk1"
+#define JFFS_FILESYS_TYPE "jffs2"
+#define JFFS_CHINESE_NAME1 "���Ϻ�"
+#define JFFS_BASE_DIR "/"
+
+constexpr int MSECS_PER_SEC = 1000;
+constexpr int USECS_PER_SEC = 1000000;
+constexpr int BYTES_PER_KBYTE = 1024;
+constexpr int BYTES_PER_MBYTE = (1024 * 1024);
+constexpr int BYTES_PER_GBYTES = (1024 * 1024 * 1024);
+
+constexpr int FILE_BUF_SIZE = 260;
+constexpr int HIGHEST_AUTHORITY = 0777;
+constexpr int JFFS_MAX_NUM_TEST = 1000;
+constexpr int JFFS_NAME_LIMITTED_SIZE = 300;
+constexpr int JFFS_STANDARD_NAME_LENGTH = 50;
+
+constexpr int JFFS_LONG_ARRAY_LENGTH = 100;
+constexpr int JFFS_MIDDLE_ARRAY_LENGTH = 50;
+constexpr int JFFS_SHORT_ARRAY_LENGTH = 10;
+constexpr int JFFS_WR_CAP_SIZE_TEST = 0x100000; // the size is 1MB for each speed calculation
+constexpr int JFFS_MAX_DEF_BUF_NUM = 21;
+
+constexpr int JFFS_FILE_LIMITTED_NUM = 200;
+
+constexpr int JFFS_FILE_SIZE_TEST = 100 * 1024 * 1024; // *1024
+constexpr int JFFS_PERFORMANCE_W_R_SIZE = 10 * 1024 * 1024;
+constexpr int JFFS_FILE_PER_WRITE_SIZE = 5 * 1024 * 1024;
+constexpr int JFFS_PRESSURE_W_R_SIZE1 = 1 * 1024 * 1024;
+constexpr int JFFS_PRESSURE_W_R_SIZE2 = 5 * 1024 * 1024;
+constexpr int JFFS_PRESSURE_W_R_SIZE3 = 10 * 1024 * 1024;
+constexpr int JFFS_PRESSURE_W_R_SIZE4 = 50 * 1024 * 1024;
+constexpr int JFFS_PRESSURE_W_R_SIZE5 = 100 * 1024 * 1024;
+constexpr int JFFS_PRESSURE_W_R_SIZE = JFFS_PRESSURE_W_R_SIZE3;
+constexpr int JFFS_THREAD_NUM_TEST = 3;
+
+constexpr int SLEEP_TIME = 10;
+constexpr int TASK_PRIO_TEST2 = TASK_PRIO_TEST - 2;
+
+constexpr int JFFS_MIDDLE_CYCLES = 3;
+constexpr int JFFS_MIDDLE_NUM = 6;
+constexpr int JFFS_MAX_CYCLES = 5;
+constexpr int JFFS_CREATFILE_NUM = 5;
+constexpr int JFFS_WR_TYPE_TEST1 = 0; // 0:use fwrite and fread for test
+constexpr int JFFS_WR_TYPE_TEST2 = 1; // 1:use write and read for test
+constexpr int JFFS_WR_TYPE_TEST = JFFS_WR_TYPE_TEST2;
+
+constexpr int JFFS_PRESSURE_CYCLES = 10;
+constexpr int JFFS_MAXIMUM_OPERATIONS = 10;
+constexpr int JFFS_MAXIMUM_SIZES = 10;
+constexpr int JFFS_MAX_THREADS = 3;
+#define JFFS_NO_ERROR 0
+#define JFFS_IS_ERROR -1
+#define JFFS_TO_NULL NULL
+
+constexpr int JFFS_UTIME_SUPPORT = -1; // 0 means utime is supported,-1 means utime is not supported
+constexpr int JFFS_BASE_ADDR = 0x1900000;
+constexpr int JFFS_MTD_SIZE = 0x200000;
+constexpr int JFFS_SECOND_MDT = 1;
+
+constexpr int JFFS2NUM_JFFS2_GC_THREAD_PRIORITY = 10;
+constexpr int JFFS2NUM_JFFS2_GC_THREAD_PRIORITY1 = JFFS2NUM_JFFS2_GC_THREAD_PRIORITY - 1;
+constexpr int JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2 = JFFS2NUM_JFFS2_GC_THREAD_PRIORITY - 2;
+constexpr int JFFS2NUM_JFFS2_GC_THREAD_PRIORITY3 = JFFS2NUM_JFFS2_GC_THREAD_PRIORITY - 3;
+constexpr int JFFS2NUM_JFFS2_GC_THREAD_PRIORITY4 = JFFS2NUM_JFFS2_GC_THREAD_PRIORITY - 4;
+constexpr int JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5 = JFFS2NUM_JFFS2_GC_THREAD_PRIORITY - 5;
+
+
+constexpr int JFFS_PRESSURE_MTD_SIZE = 0x6A00000; /* The size is 106MB */
+#if defined TEST3516A || defined TEST3516EV200
+constexpr int JFFS_PRESSURE_ADDRESS_BEGIN = 0xe00000;
+constexpr int JFFS_PRESSURE_ADDRESS_END = 0X7f00000;
+#elif defined TEST3518E || defined TEST3516CV300
+constexpr int JFFS_PRESSURE_ADDRESS_BEGIN = 0xe00000;
+constexpr int JFFS_PRESSURE_ADDRESS_END = 0X7f00000;
+#endif
+
+extern INT32 g_jffsFilesMax;
+extern INT32 g_jffsFlag;
+extern INT32 g_jffsFlagF01;
+extern INT32 g_jffsFlagF02;
+extern INT32 g_jffsFd;
+extern DIR *g_jffsDir;
+extern BOOL isCpuAffiMaskTest;
+extern INT32 g_TestCnt;
+
+extern INT32 g_jffsFd11[JFFS_MAXIMUM_SIZES];
+extern INT32 g_jffsFd12[JFFS_MAXIMUM_SIZES][JFFS_MAXIMUM_SIZES];
+
+extern CHAR g_jffsPathname1[JFFS_STANDARD_NAME_LENGTH];
+extern CHAR g_jffsPathname2[JFFS_STANDARD_NAME_LENGTH];
+extern CHAR g_jffsPathname3[JFFS_STANDARD_NAME_LENGTH];
+extern CHAR g_jffsPathname4[JFFS_STANDARD_NAME_LENGTH];
+
+extern CHAR g_jffsPathname6[JFFS_NAME_LIMITTED_SIZE];
+extern CHAR g_jffsPathname7[JFFS_NAME_LIMITTED_SIZE];
+extern CHAR g_jffsPathname8[JFFS_NAME_LIMITTED_SIZE];
+
+extern CHAR g_jffsPathname11[JFFS_MAXIMUM_SIZES][JFFS_NAME_LIMITTED_SIZE];
+extern CHAR g_jffsPathname12[JFFS_MAXIMUM_SIZES][JFFS_NAME_LIMITTED_SIZE];
+extern CHAR g_jffsPathname13[JFFS_MAXIMUM_SIZES][JFFS_NAME_LIMITTED_SIZE];
+
+extern struct iovec g_jffsIov[10];
+
+extern pthread_mutex_t g_jffs2GlobalLock1;
+extern pthread_mutex_t g_jffs2GlobalLock2;
+
+INT32 JffsFixWrite(CHAR *path, INT64 fileSize, INT32 writeSize, INT32 interfaceType);
+INT32 JffsFixRead(CHAR *path, INT64 fileSize, INT32 readSize, INT32 interfaceType);
+INT32 JffsMultiWrite(CHAR *path, INT64 fileSize, INT32 writeSize, int oflags, INT32 interfaceType);
+INT32 JffsMultiRead(CHAR *path, INT64 fileSize, INT32 readSize, int oflags, INT32 interfaceType);
+INT32 JffsRandWrite(CHAR *path, INT64 fileSize, INT32 interfaceType);
+INT32 JffsRandRead(CHAR *path, INT64 fileSize, INT32 interfaceType);
+
+INT32 JffsDeleteDirs(char *str, int n);
+INT32 JffsDeletefile(int fd, char *pathname);
+INT32 JffsStrcat2(char *pathname, char *str, int len);
+INT32 JffsScandirFree(struct dirent **namelist, int n);
+INT32 JffsStatPrintf(struct stat sb);
+INT32 JffsStatfsPrintf(struct statfs buf);
+INT32 JffsStat64Printf(struct stat64 sb);
+
+extern int open64(const char *__path, int __oflag, ...);
+extern int fcntl64(int fd, int cmd, ...);
+
+extern int osShellCmdPartitionShow(int argc, char **argv);
+
+extern int alphasort(const struct dirent **a, const struct dirent **b);
+extern int mount(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags,
+ const void *data);
+extern int umount(const char *target);
+extern bool IS_MOUNTPT(const char *dev);
+extern int chattr(const char *path, mode_t mode);
+
+extern VOID ItSuite_Vfs_Jffs(VOID);
+
+#if defined(LOSCFG_USER_TEST_SMOKE)
+VOID ItTestDac001(VOID);
+VOID ItFsJffs001(VOID);
+VOID ItFsJffs002(VOID);
+VOID ItFsJffs003(VOID);
+VOID ItFsJffs005(VOID);
+VOID ItFsJffs021(VOID);
+VOID ItFsJffs022(VOID);
+VOID ItFsJffs026(VOID);
+VOID ItFsJffs027(VOID);
+VOID ItFsJffs034(VOID);
+VOID ItFsJffs035(VOID);
+VOID ItFsJffs094(VOID);
+VOID ItFsJffs095(VOID);
+VOID ItFsJffs103(VOID);
+VOID ItFsJffs535(VOID);
+#endif
+
+#if defined(LOSCFG_USER_TEST_FULL)
+VOID ItJffs001(VOID);
+VOID ItJffs002(VOID);
+VOID ItJffs003(VOID);
+VOID ItJffs004(VOID);
+VOID ItJffs005(VOID);
+VOID ItJffs006(VOID);
+VOID ItJffs007(VOID);
+VOID ItJffs008(VOID);
+VOID ItJffs009(VOID);
+VOID ItJffs010(VOID);
+VOID ItJffs011(VOID);
+VOID ItJffs012(VOID);
+VOID ItJffs013(VOID);
+VOID ItJffs014(VOID);
+VOID ItJffs015(VOID);
+VOID ItJffs016(VOID);
+VOID ItJffs017(VOID);
+VOID ItJffs018(VOID);
+VOID ItJffs019(VOID);
+VOID ItJffs020(VOID);
+VOID ItJffs021(VOID);
+VOID ItJffs022(VOID);
+VOID ItJffs023(VOID);
+VOID ItJffs024(VOID);
+VOID ItJffs025(VOID);
+VOID ItJffs026(VOID);
+VOID ItJffs027(VOID);
+VOID ItJffs028(VOID);
+VOID ItJffs029(VOID);
+VOID ItJffs030(VOID);
+VOID ItJffs031(VOID);
+VOID ItJffs032(VOID);
+VOID ItJffs033(VOID);
+VOID ItJffs034(VOID);
+VOID ItJffs035(VOID);
+VOID ItJffs036(VOID);
+VOID ItJffs037(VOID);
+VOID ItJffs038(VOID);
+VOID ItJffs039(VOID);
+VOID ItJffs040(VOID);
+VOID ItJffs041(VOID);
+VOID ItJffs042(VOID);
+VOID ItJffs043(VOID);
+VOID ItJffs044(VOID);
+
+VOID ItFsJffs004(VOID);
+VOID ItFsJffs006(VOID);
+VOID ItFsJffs007(VOID);
+VOID ItFsJffs008(VOID);
+VOID ItFsJffs009(VOID);
+VOID ItFsJffs010(VOID);
+VOID ItFsJffs011(VOID);
+VOID ItFsJffs012(VOID);
+VOID ItFsJffs013(VOID);
+VOID ItFsJffs014(VOID);
+VOID ItFsJffs015(VOID);
+VOID ItFsJffs016(VOID);
+VOID ItFsJffs017(VOID);
+VOID ItFsJffs018(VOID);
+VOID ItFsJffs019(VOID);
+VOID ItFsJffs020(VOID);
+VOID ItFsJffs023(VOID);
+VOID ItFsJffs024(VOID);
+VOID ItFsJffs025(VOID);
+VOID ItFsJffs028(VOID);
+VOID ItFsJffs029(VOID);
+VOID ItFsJffs030(VOID);
+VOID ItFsJffs031(VOID);
+VOID ItFsJffs032(VOID);
+VOID ItFsJffs033(VOID);
+VOID ItFsJffs037(VOID);
+VOID ItFsJffs038(VOID);
+VOID ItFsJffs039(VOID);
+VOID ItFsJffs040(VOID);
+VOID ItFsJffs041(VOID);
+VOID ItFsJffs042(VOID);
+VOID ItFsJffs043(VOID);
+VOID ItFsJffs044(VOID);
+VOID ItFsJffs045(VOID);
+VOID ItFsJffs046(VOID);
+VOID ItFsJffs047(VOID);
+VOID ItFsJffs048(VOID);
+VOID ItFsJffs049(VOID);
+VOID ItFsJffs050(VOID);
+VOID ItFsJffs052(VOID);
+VOID ItFsJffs053(VOID);
+VOID ItFsJffs054(VOID);
+VOID ItFsJffs055(VOID);
+VOID ItFsJffs056(VOID);
+VOID ItFsJffs057(VOID);
+VOID ItFsJffs058(VOID);
+VOID ItFsJffs059(VOID);
+VOID ItFsJffs060(VOID);
+VOID ItFsJffs061(VOID);
+VOID ItFsJffs062(VOID);
+VOID ItFsJffs063(VOID);
+VOID ItFsJffs064(VOID);
+VOID ItFsJffs065(VOID);
+VOID ItFsJffs066(VOID);
+VOID ItFsJffs067(VOID);
+VOID ItFsJffs068(VOID);
+VOID ItFsJffs069(VOID);
+VOID ItFsJffs070(VOID);
+VOID ItFsJffs071(VOID);
+VOID ItFsJffs072(VOID);
+VOID ItFsJffs073(VOID);
+VOID ItFsJffs074(VOID);
+VOID ItFsJffs075(VOID);
+VOID ItFsJffs076(VOID);
+VOID ItFsJffs077(VOID);
+VOID ItFsJffs078(VOID);
+VOID ItFsJffs079(VOID);
+VOID ItFsJffs080(VOID);
+VOID ItFsJffs081(VOID);
+VOID ItFsJffs082(VOID);
+VOID ItFsJffs083(VOID);
+VOID ItFsJffs084(VOID);
+VOID ItFsJffs085(VOID);
+VOID ItFsJffs086(VOID);
+VOID ItFsJffs088(VOID);
+VOID ItFsJffs089(VOID);
+VOID ItFsJffs090(VOID);
+VOID ItFsJffs091(VOID);
+VOID ItFsJffs092(VOID);
+VOID ItFsJffs093(VOID);
+VOID ItFsJffs096(VOID);
+VOID ItFsJffs097(VOID);
+VOID ItFsJffs098(VOID);
+VOID ItFsJffs099(VOID);
+VOID ItFsJffs100(VOID);
+VOID ItFsJffs101(VOID);
+VOID ItFsJffs102(VOID);
+VOID ItFsJffs104(VOID);
+VOID ItFsJffs105(VOID);
+VOID ItFsJffs106(VOID);
+VOID ItFsJffs107(VOID);
+VOID ItFsJffs109(VOID);
+VOID ItFsJffs110(VOID);
+VOID ItFsJffs111(VOID);
+VOID ItFsJffs112(VOID);
+VOID ItFsJffs113(VOID);
+VOID ItFsJffs114(VOID);
+VOID ItFsJffs115(VOID);
+VOID ItFsJffs116(VOID);
+VOID ItFsJffs117(VOID);
+VOID ItFsJffs118(VOID);
+VOID ItFsJffs119(VOID);
+VOID ItFsJffs120(VOID);
+VOID ItFsJffs121(VOID);
+VOID ItFsJffs122(VOID);
+VOID ItFsJffs123(VOID);
+VOID ItFsJffs124(VOID);
+VOID ItFsJffs125(VOID);
+VOID ItFsJffs126(VOID);
+VOID ItFsJffs127(VOID);
+VOID ItFsJffs128(VOID);
+VOID ItFsJffs129(VOID);
+VOID ItFsJffs130(VOID);
+VOID ItFsJffs131(VOID);
+VOID ItFsJffs132(VOID);
+VOID ItFsJffs133(VOID);
+VOID ItFsJffs134(VOID);
+VOID ItFsJffs135(VOID);
+VOID ItFsJffs136(VOID);
+VOID ItFsJffs137(VOID);
+VOID ItFsJffs138(VOID);
+VOID ItFsJffs139(VOID);
+VOID ItFsJffs140(VOID);
+VOID ItFsJffs141(VOID);
+VOID ItFsJffs142(VOID);
+VOID ItFsJffs143(VOID);
+VOID ItFsJffs144(VOID);
+VOID ItFsJffs145(VOID);
+VOID ItFsJffs146(VOID);
+VOID ItFsJffs147(VOID);
+VOID ItFsJffs148(VOID);
+VOID ItFsJffs149(VOID);
+VOID ItFsJffs150(VOID);
+VOID ItFsJffs151(VOID);
+VOID ItFsJffs152(VOID);
+VOID ItFsJffs153(VOID);
+VOID ItFsJffs154(VOID);
+VOID ItFsJffs155(VOID);
+VOID ItFsJffs156(VOID);
+VOID ItFsJffs157(VOID);
+VOID ItFsJffs158(VOID);
+VOID ItFsJffs159(VOID);
+VOID ItFsJffs160(VOID);
+VOID ItFsJffs161(VOID);
+VOID ItFsJffs162(VOID);
+VOID ItFsJffs163(VOID);
+VOID ItFsJffs164(VOID);
+VOID ItFsJffs165(VOID);
+VOID ItFsJffs166(VOID);
+VOID ItFsJffs167(VOID);
+VOID ItFsJffs168(VOID);
+VOID ItFsJffs169(VOID);
+VOID ItFsJffs170(VOID);
+VOID ItFsJffs171(VOID);
+VOID ItFsJffs172(VOID);
+VOID ItFsJffs173(VOID);
+VOID ItFsJffs174(VOID);
+VOID ItFsJffs175(VOID);
+VOID ItFsJffs176(VOID);
+VOID ItFsJffs177(VOID);
+VOID ItFsJffs178(VOID);
+VOID ItFsJffs179(VOID);
+VOID ItFsJffs180(VOID);
+VOID ItFsJffs182(VOID);
+VOID ItFsJffs183(VOID);
+VOID ItFsJffs184(VOID);
+VOID ItFsJffs185(VOID);
+VOID ItFsJffs187(VOID);
+VOID ItFsJffs188(VOID);
+VOID ItFsJffs189(VOID);
+VOID ItFsJffs190(VOID);
+VOID ItFsJffs191(VOID);
+VOID ItFsJffs192(VOID);
+VOID ItFsJffs193(VOID);
+VOID ItFsJffs194(VOID);
+VOID ItFsJffs195(VOID);
+VOID ItFsJffs196(VOID);
+VOID ItFsJffs197(VOID);
+VOID ItFsJffs198(VOID);
+VOID ItFsJffs199(VOID);
+VOID ItFsJffs200(VOID);
+VOID ItFsJffs201(VOID);
+VOID ItFsJffs202(VOID);
+VOID ItFsJffs203(VOID);
+VOID ItFsJffs204(VOID);
+VOID ItFsJffs205(VOID);
+VOID ItFsJffs206(VOID);
+VOID ItFsJffs207(VOID);
+VOID ItFsJffs208(VOID);
+VOID ItFsJffs209(VOID);
+VOID ItFsJffs210(VOID);
+VOID ItFsJffs211(VOID);
+VOID ItFsJffs212(VOID);
+VOID ItFsJffs213(VOID);
+VOID ItFsJffs214(VOID);
+VOID ItFsJffs215(VOID);
+VOID ItFsJffs216(VOID);
+VOID ItFsJffs217(VOID);
+VOID ItFsJffs218(VOID);
+VOID ItFsJffs219(VOID);
+VOID ItFsJffs220(VOID);
+VOID ItFsJffs221(VOID);
+VOID ItFsJffs222(VOID);
+VOID ItFsJffs223(VOID);
+VOID ItFsJffs224(VOID);
+VOID ItFsJffs225(VOID);
+VOID ItFsJffs226(VOID);
+VOID ItFsJffs227(VOID);
+VOID ItFsJffs228(VOID);
+VOID ItFsJffs229(VOID);
+VOID ItFsJffs230(VOID);
+VOID ItFsJffs231(VOID);
+VOID ItFsJffs232(VOID);
+VOID ItFsJffs233(VOID);
+VOID ItFsJffs234(VOID);
+VOID ItFsJffs235(VOID);
+VOID ItFsJffs236(VOID);
+VOID ItFsJffs237(VOID);
+VOID ItFsJffs238(VOID);
+VOID ItFsJffs239(VOID);
+VOID ItFsJffs240(VOID);
+VOID ItFsJffs241(VOID);
+VOID ItFsJffs242(VOID);
+VOID ItFsJffs243(VOID);
+VOID ItFsJffs244(VOID);
+VOID ItFsJffs245(VOID);
+VOID ItFsJffs246(VOID);
+VOID ItFsJffs247(VOID);
+VOID ItFsJffs248(VOID);
+VOID ItFsJffs249(VOID);
+VOID ItFsJffs250(VOID);
+VOID ItFsJffs251(VOID);
+VOID ItFsJffs252(VOID);
+VOID ItFsJffs253(VOID);
+VOID ItFsJffs254(VOID);
+VOID ItFsJffs255(VOID);
+VOID ItFsJffs256(VOID);
+VOID ItFsJffs257(VOID);
+VOID ItFsJffs258(VOID);
+VOID ItFsJffs259(VOID);
+VOID ItFsJffs260(VOID);
+VOID ItFsJffs261(VOID);
+VOID ItFsJffs262(VOID);
+VOID ItFsJffs263(VOID);
+VOID ItFsJffs264(VOID);
+VOID ItFsJffs265(VOID);
+VOID ItFsJffs266(VOID);
+VOID ItFsJffs267(VOID);
+VOID ItFsJffs268(VOID);
+VOID ItFsJffs269(VOID);
+VOID ItFsJffs270(VOID);
+VOID ItFsJffs271(VOID);
+VOID ItFsJffs272(VOID);
+VOID ItFsJffs273(VOID);
+VOID ItFsJffs274(VOID);
+VOID ItFsJffs275(VOID);
+VOID ItFsJffs276(VOID);
+VOID ItFsJffs277(VOID);
+VOID ItFsJffs278(VOID);
+VOID ItFsJffs279(VOID);
+VOID ItFsJffs280(VOID);
+VOID ItFsJffs281(VOID);
+VOID ItFsJffs282(VOID);
+VOID ItFsJffs283(VOID);
+VOID ItFsJffs284(VOID);
+VOID ItFsJffs285(VOID);
+VOID ItFsJffs286(VOID);
+VOID ItFsJffs287(VOID);
+VOID ItFsJffs288(VOID);
+VOID ItFsJffs289(VOID);
+VOID ItFsJffs290(VOID);
+VOID ItFsJffs291(VOID);
+VOID ItFsJffs292(VOID);
+VOID ItFsJffs293(VOID);
+VOID ItFsJffs294(VOID);
+VOID ItFsJffs295(VOID);
+VOID ItFsJffs296(VOID);
+VOID ItFsJffs297(VOID);
+VOID ItFsJffs298(VOID);
+VOID ItFsJffs299(VOID);
+VOID ItFsJffs300(VOID);
+VOID ItFsJffs301(VOID);
+VOID ItFsJffs302(VOID);
+VOID ItFsJffs303(VOID);
+VOID ItFsJffs304(VOID);
+VOID ItFsJffs305(VOID);
+VOID ItFsJffs306(VOID);
+VOID ItFsJffs307(VOID);
+VOID ItFsJffs308(VOID);
+VOID ItFsJffs309(VOID);
+VOID ItFsJffs310(VOID);
+VOID ItFsJffs311(VOID);
+VOID ItFsJffs312(VOID);
+VOID ItFsJffs313(VOID);
+VOID ItFsJffs314(VOID);
+VOID ItFsJffs315(VOID);
+VOID ItFsJffs316(VOID);
+VOID ItFsJffs317(VOID);
+VOID ItFsJffs318(VOID);
+VOID ItFsJffs319(VOID);
+VOID ItFsJffs320(VOID);
+VOID ItFsJffs321(VOID);
+VOID ItFsJffs322(VOID);
+VOID ItFsJffs323(VOID);
+VOID ItFsJffs324(VOID);
+VOID ItFsJffs325(VOID);
+VOID ItFsJffs326(VOID);
+VOID ItFsJffs327(VOID);
+VOID ItFsJffs328(VOID);
+VOID ItFsJffs329(VOID);
+VOID ItFsJffs330(VOID);
+VOID ItFsJffs331(VOID);
+VOID ItFsJffs332(VOID);
+VOID ItFsJffs333(VOID);
+VOID ItFsJffs334(VOID);
+VOID ItFsJffs335(VOID);
+VOID ItFsJffs336(VOID);
+VOID ItFsJffs337(VOID);
+VOID ItFsJffs338(VOID);
+VOID ItFsJffs339(VOID);
+VOID ItFsJffs340(VOID);
+VOID ItFsJffs341(VOID);
+VOID ItFsJffs342(VOID);
+VOID ItFsJffs343(VOID);
+VOID ItFsJffs344(VOID);
+VOID ItFsJffs345(VOID);
+VOID ItFsJffs346(VOID);
+VOID ItFsJffs347(VOID);
+VOID ItFsJffs348(VOID);
+VOID ItFsJffs349(VOID);
+VOID ItFsJffs350(VOID);
+VOID ItFsJffs351(VOID);
+VOID ItFsJffs352(VOID);
+VOID ItFsJffs353(VOID);
+VOID ItFsJffs354(VOID);
+VOID ItFsJffs355(VOID);
+VOID ItFsJffs356(VOID);
+VOID ItFsJffs357(VOID);
+VOID ItFsJffs358(VOID);
+VOID ItFsJffs359(VOID);
+VOID ItFsJffs360(VOID);
+VOID ItFsJffs361(VOID);
+VOID ItFsJffs362(VOID);
+VOID ItFsJffs363(VOID);
+VOID ItFsJffs364(VOID);
+VOID ItFsJffs365(VOID);
+VOID ItFsJffs366(VOID);
+VOID ItFsJffs367(VOID);
+VOID ItFsJffs368(VOID);
+VOID ItFsJffs369(VOID);
+VOID ItFsJffs370(VOID);
+VOID ItFsJffs371(VOID);
+VOID ItFsJffs372(VOID);
+VOID ItFsJffs373(VOID);
+VOID ItFsJffs374(VOID);
+VOID ItFsJffs375(VOID);
+VOID ItFsJffs376(VOID);
+VOID ItFsJffs377(VOID);
+VOID ItFsJffs378(VOID);
+VOID ItFsJffs379(VOID);
+VOID ItFsJffs380(VOID);
+VOID ItFsJffs381(VOID);
+VOID ItFsJffs382(VOID);
+VOID ItFsJffs383(VOID);
+VOID ItFsJffs384(VOID);
+VOID ItFsJffs385(VOID);
+VOID ItFsJffs386(VOID);
+VOID ItFsJffs387(VOID);
+VOID ItFsJffs388(VOID);
+VOID ItFsJffs389(VOID);
+VOID ItFsJffs390(VOID);
+VOID ItFsJffs391(VOID);
+VOID ItFsJffs392(VOID);
+VOID ItFsJffs393(VOID);
+VOID ItFsJffs394(VOID);
+VOID ItFsJffs395(VOID);
+VOID ItFsJffs396(VOID);
+VOID ItFsJffs397(VOID);
+VOID ItFsJffs398(VOID);
+VOID ItFsJffs399(VOID);
+VOID ItFsJffs400(VOID);
+VOID ItFsJffs401(VOID);
+VOID ItFsJffs402(VOID);
+VOID ItFsJffs403(VOID);
+VOID ItFsJffs404(VOID);
+VOID ItFsJffs405(VOID);
+VOID ItFsJffs406(VOID);
+VOID ItFsJffs407(VOID);
+VOID ItFsJffs408(VOID);
+VOID ItFsJffs409(VOID);
+VOID ItFsJffs410(VOID);
+VOID ItFsJffs411(VOID);
+VOID ItFsJffs412(VOID);
+VOID ItFsJffs413(VOID);
+VOID ItFsJffs414(VOID);
+VOID ItFsJffs415(VOID);
+VOID ItFsJffs416(VOID);
+VOID ItFsJffs417(VOID);
+VOID ItFsJffs418(VOID);
+VOID ItFsJffs419(VOID);
+VOID ItFsJffs420(VOID);
+VOID ItFsJffs421(VOID);
+VOID ItFsJffs422(VOID);
+VOID ItFsJffs423(VOID);
+VOID ItFsJffs424(VOID);
+VOID ItFsJffs425(VOID);
+VOID ItFsJffs426(VOID);
+VOID ItFsJffs427(VOID);
+VOID ItFsJffs428(VOID);
+VOID ItFsJffs429(VOID);
+VOID ItFsJffs430(VOID);
+VOID ItFsJffs431(VOID);
+VOID ItFsJffs432(VOID);
+VOID ItFsJffs433(VOID);
+VOID ItFsJffs434(VOID);
+VOID ItFsJffs435(VOID);
+VOID ItFsJffs436(VOID);
+VOID ItFsJffs437(VOID);
+VOID ItFsJffs438(VOID);
+VOID ItFsJffs439(VOID);
+VOID ItFsJffs440(VOID);
+VOID ItFsJffs441(VOID);
+VOID ItFsJffs442(VOID);
+VOID ItFsJffs443(VOID);
+VOID ItFsJffs444(VOID);
+VOID ItFsJffs445(VOID);
+VOID ItFsJffs446(VOID);
+VOID ItFsJffs447(VOID);
+VOID ItFsJffs448(VOID);
+VOID ItFsJffs449(VOID);
+VOID ItFsJffs450(VOID);
+VOID ItFsJffs451(VOID);
+VOID ItFsJffs452(VOID);
+VOID ItFsJffs453(VOID);
+VOID ItFsJffs454(VOID);
+VOID ItFsJffs455(VOID);
+VOID ItFsJffs456(VOID);
+VOID ItFsJffs457(VOID);
+VOID ItFsJffs458(VOID);
+VOID ItFsJffs459(VOID);
+VOID ItFsJffs460(VOID);
+VOID ItFsJffs461(VOID);
+VOID ItFsJffs462(VOID);
+VOID ItFsJffs463(VOID);
+VOID ItFsJffs464(VOID);
+VOID ItFsJffs465(VOID);
+VOID ItFsJffs466(VOID);
+VOID ItFsJffs467(VOID);
+VOID ItFsJffs468(VOID);
+VOID ItFsJffs469(VOID);
+VOID ItFsJffs470(VOID);
+VOID ItFsJffs471(VOID);
+VOID ItFsJffs472(VOID);
+VOID ItFsJffs473(VOID);
+VOID ItFsJffs475(VOID);
+VOID ItFsJffs476(VOID);
+VOID ItFsJffs477(VOID);
+VOID ItFsJffs478(VOID);
+VOID ItFsJffs479(VOID);
+VOID ItFsJffs480(VOID);
+VOID ItFsJffs481(VOID);
+VOID ItFsJffs482(VOID);
+VOID ItFsJffs483(VOID);
+VOID ItFsJffs484(VOID);
+VOID ItFsJffs485(VOID);
+VOID ItFsJffs486(VOID);
+VOID ItFsJffs487(VOID);
+VOID ItFsJffs488(VOID);
+VOID ItFsJffs489(VOID);
+VOID ItFsJffs490(VOID);
+VOID ItFsJffs491(VOID);
+VOID ItFsJffs492(VOID);
+VOID ItFsJffs493(VOID);
+VOID ItFsJffs494(VOID);
+VOID ItFsJffs495(VOID);
+VOID ItFsJffs496(VOID);
+VOID ItFsJffs497(VOID);
+VOID ItFsJffs498(VOID);
+VOID ItFsJffs499(VOID);
+VOID ItFsJffs500(VOID);
+VOID ItFsJffs501(VOID);
+VOID ItFsJffs502(VOID);
+VOID ItFsJffs503(VOID);
+VOID ItFsJffs504(VOID);
+VOID ItFsJffs505(VOID);
+VOID ItFsJffs506(VOID);
+VOID ItFsJffs507(VOID);
+VOID ItFsJffs508(VOID);
+VOID ItFsJffs509(VOID);
+VOID ItFsJffs510(VOID);
+VOID ItFsJffs511(VOID);
+VOID ItFsJffs512(VOID);
+VOID ItFsJffs513(VOID);
+VOID ItFsJffs514(VOID);
+VOID ItFsJffs515(VOID);
+VOID ItFsJffs516(VOID);
+VOID ItFsJffs517(VOID);
+VOID ItFsJffs518(VOID);
+VOID ItFsJffs519(VOID);
+VOID ItFsJffs520(VOID);
+VOID ItFsJffs521(VOID);
+VOID ItFsJffs522(VOID);
+VOID ItFsJffs523(VOID);
+VOID ItFsJffs524(VOID);
+VOID ItFsJffs525(VOID);
+VOID ItFsJffs526(VOID);
+VOID ItFsJffs528(VOID);
+VOID ItFsJffs529(VOID);
+VOID ItFsJffs530(VOID);
+VOID ItFsJffs531(VOID);
+VOID ItFsJffs532(VOID);
+VOID ItFsJffs533(VOID);
+VOID ItFsJffs534(VOID);
+VOID ItFsJffs536(VOID);
+VOID ItFsJffs537(VOID);
+VOID ItFsJffs538(VOID);
+VOID ItFsJffs539(VOID);
+VOID ItFsJffs540(VOID);
+VOID ItFsJffs541(VOID);
+VOID ItFsJffs542(VOID);
+VOID ItFsJffs543(VOID);
+VOID ItFsJffs544(VOID);
+VOID ItFsJffs545(VOID);
+VOID ItFsJffs546(VOID);
+VOID ItFsJffs547(VOID);
+VOID ItFsJffs548(VOID);
+VOID ItFsJffs549(VOID);
+VOID ItFsJffs550(VOID);
+VOID ItFsJffs551(VOID);
+VOID ItFsJffs552(VOID);
+VOID ItFsJffs553(VOID);
+VOID ItFsJffs554(VOID);
+VOID ItFsJffs555(VOID);
+VOID ItFsJffs556(VOID);
+VOID ItFsJffs557(VOID);
+VOID ItFsJffs560(VOID);
+VOID ItFsJffs562(VOID);
+VOID ItFsJffs563(VOID);
+VOID ItFsJffs564(VOID);
+VOID ItFsJffs565(VOID);
+VOID ItFsJffs566(VOID);
+VOID ItFsJffs567(VOID);
+VOID ItFsJffs568(VOID);
+VOID ItFsJffs569(VOID);
+VOID ItFsJffs570(VOID);
+VOID ItFsJffs571(VOID);
+VOID ItFsJffs572(VOID);
+VOID ItFsJffs573(VOID);
+VOID ItFsJffs574(VOID);
+
+VOID ItFsJffs124(VOID);
+VOID ItFsJffs125(VOID);
+VOID ItFsJffs577(VOID);
+VOID ItFsJffs578(VOID);
+VOID ItFsJffs578(VOID);
+VOID ItFsJffs579(VOID);
+VOID ItFsJffs580(VOID);
+VOID ItFsJffs581(VOID);
+VOID ItFsJffs582(VOID);
+VOID ItFsJffs583(VOID);
+VOID ItFsJffs584(VOID);
+VOID ItFsJffs585(VOID);
+VOID ItFsJffs586(VOID);
+VOID ItFsJffs589(VOID);
+VOID ItFsJffs590(VOID);
+VOID ItFsJffs591(VOID);
+VOID ItFsJffs592(VOID);
+VOID ItFsJffs593(VOID);
+VOID ItFsJffs594(VOID);
+VOID ItFsJffs595(VOID);
+VOID ItFsJffs596(VOID);
+VOID ItFsJffs603(VOID);
+VOID ItFsJffs605(VOID);
+VOID ItFsJffs606(VOID);
+VOID ItFsJffs607(VOID);
+VOID ItFsJffs608(VOID);
+VOID ItFsJffs609(VOID);
+VOID ItFsJffs610(VOID);
+VOID ItFsJffs611(VOID);
+VOID ItFsJffs612(VOID);
+VOID ItFsJffs613(VOID);
+VOID ItFsJffs614(VOID);
+VOID ItFsJffs615(VOID);
+VOID ItFsJffs618(VOID);
+VOID ItFsJffs619(VOID);
+VOID ItFsJffs620(VOID);
+VOID ItFsJffs621(VOID);
+VOID ItFsJffs622(VOID);
+VOID ItFsJffs623(VOID);
+VOID ItFsJffs624(VOID);
+VOID ItFsJffs625(VOID);
+VOID ItFsJffs626(VOID);
+VOID ItFsJffs627(VOID);
+VOID ItFsJffs628(VOID);
+VOID ItFsJffs629(VOID);
+VOID ItFsJffs636(VOID);
+VOID ItFsJffs643(VOID);
+VOID ItFsJffs644(VOID);
+VOID ItFsJffs645(VOID);
+VOID ItFsJffs646(VOID);
+VOID ItFsJffs648(VOID);
+VOID ItFsJffs649(VOID);
+VOID ItFsJffs650(VOID);
+VOID ItFsJffs651(VOID);
+VOID ItFsJffs652(VOID);
+VOID ItFsJffs653(VOID);
+VOID ItFsJffs654(VOID);
+VOID ItFsJffs655(VOID);
+VOID ItFsJffs656(VOID);
+VOID ItFsJffs663(VOID);
+VOID ItFsJffs664(VOID);
+VOID ItFsJffs665(VOID);
+VOID ItFsJffs666(VOID);
+VOID ItFsJffs668(VOID);
+VOID ItFsJffs669(VOID);
+VOID ItFsJffs670(VOID);
+VOID ItFsJffs671(VOID);
+VOID ItFsJffs672(VOID);
+VOID ItFsJffs673(VOID);
+VOID ItFsJffs674(VOID);
+VOID ItFsJffs675(VOID);
+VOID ItFsJffs676(VOID);
+VOID ItFsJffs690(VOID);
+VOID ItFsJffs694(VOID);
+VOID ItFsJffs696(VOID);
+VOID ItFsJffs697(VOID);
+VOID ItFsJffs700(VOID);
+VOID ItFsJffs701(VOID);
+VOID ItFsJffs800(VOID);
+VOID ItFsJffs807(VOID);
+VOID ItFsJffs808(VOID);
+
+VOID ItFsJffsLSFD_001(VOID);
+VOID ItFsJffsLSFD_002(VOID);
+VOID ItFsJffsLSFD_003(VOID);
+VOID ItFsJffsLSFD_004(VOID);
+VOID ItFsJffsLSFD_005(VOID);
+VOID ItFsJffsLSFD_006(VOID);
+VOID ItFsJffsLSFD_007(VOID);
+#endif
+
+#if defined(LOSCFG_USER_TESTSUIT_SHELL)
+VOID ItFsJffsLSFD_008(VOID);
+VOID ItFsJffsLSFD_009(VOID);
+#endif
+
+#if defined(LOSCFG_USER_TEST_PRESSURE)
+VOID ItFsJffsMultipthread001(VOID);
+VOID ItFsJffsMultipthread002(VOID);
+VOID ItFsJffsMultipthread003(VOID);
+VOID ItFsJffsMultipthread004(VOID);
+VOID ItFsJffsMultipthread005(VOID);
+VOID ItFsJffsMultipthread006(VOID);
+VOID ItFsJffsMultipthread007(VOID);
+VOID ItFsJffsMultipthread008(VOID);
+VOID ItFsJffsMultipthread009(VOID);
+VOID ItFsJffsMultipthread010(VOID);
+VOID ItFsJffsMultipthread011(VOID);
+VOID ItFsJffsMultipthread012(VOID);
+VOID ItFsJffsMultipthread013(VOID);
+VOID ItFsJffsMultipthread014(VOID);
+VOID ItFsJffsMultipthread015(VOID);
+VOID ItFsJffsMultipthread016(VOID);
+VOID ItFsJffsMultipthread017(VOID);
+VOID ItFsJffsMultipthread018(VOID);
+VOID ItFsJffsMultipthread019(VOID);
+VOID ItFsJffsMultipthread020(VOID);
+VOID ItFsJffsMultipthread021(VOID);
+VOID ItFsJffsMultipthread022(VOID);
+VOID ItFsJffsMultipthread023(VOID);
+VOID ItFsJffsMultipthread024(VOID);
+VOID ItFsJffsMultipthread025(VOID);
+VOID ItFsJffsMultipthread026(VOID);
+VOID ItFsJffsMultipthread027(VOID);
+VOID ItFsJffsMultipthread028(VOID);
+VOID ItFsJffsMultipthread029(VOID);
+VOID ItFsJffsMultipthread030(VOID);
+VOID ItFsJffsMultipthread031(VOID);
+VOID ItFsJffsMultipthread032(VOID);
+VOID ItFsJffsMultipthread033(VOID);
+VOID ItFsJffsMultipthread034(VOID);
+VOID ItFsJffsMultipthread035(VOID);
+VOID ItFsJffsMultipthread036(VOID);
+VOID ItFsJffsMultipthread037(VOID);
+VOID ItFsJffsMultipthread038(VOID);
+VOID ItFsJffsMultipthread039(VOID);
+VOID ItFsJffsMultipthread040(VOID);
+VOID ItFsJffsMultipthread041(VOID);
+VOID ItFsJffsMultipthread042(VOID);
+VOID ItFsJffsMultipthread043(VOID);
+VOID ItFsJffsMultipthread044(VOID);
+VOID ItFsJffsMultipthread045(VOID);
+VOID ItFsJffsMultipthread046(VOID);
+VOID ItFsJffsMultipthread047(VOID);
+VOID ItFsJffsMultipthread048(VOID);
+VOID ItFsJffsMultipthread049(VOID);
+VOID ItFsJffsMultipthread050(VOID);
+VOID ItFsJffsMultipthread051(VOID);
+VOID ItFsJffsMultipthread052(VOID);
+VOID ItFsJffsMultipthread053(VOID);
+VOID ItFsJffsMultipthread054(VOID);
+VOID ItFsJffsMultipthread055(VOID);
+VOID ItFsJffsMultipthread056(VOID);
+VOID ItFsJffsMultipthread057(VOID);
+VOID ItFsJffsMultipthread058(VOID);
+VOID ItFsJffsMultipthread059(VOID);
+VOID ItFsJffsMultipthread060(VOID);
+VOID ItFsJffsMultipthread061(VOID);
+VOID ItFsJffsMultipthread062(VOID);
+VOID ItFsJffsMultipthread063(VOID);
+
+VOID ItFsJffsPressure001(VOID);
+VOID ItFsJffsPressure002(VOID);
+VOID ItFsJffsPressure003(VOID);
+VOID ItFsJffsPressure004(VOID);
+VOID ItFsJffsPressure005(VOID);
+VOID ItFsJffsPressure006(VOID);
+VOID ItFsJffsPressure007(VOID);
+VOID ItFsJffsPressure008(VOID);
+VOID ItFsJffsPressure009(VOID);
+VOID ItFsJffsPressure010(VOID);
+VOID ItFsJffsPressure011(VOID);
+VOID ItFsJffsPressure012(VOID);
+VOID ItFsJffsPRESSURE_013(VOID);
+VOID ItFsJffsPressure014(VOID);
+VOID ItFsJffsPressure015(VOID);
+VOID ItFsJffsPressure016(VOID);
+VOID ItFsJffsPressure017(VOID);
+VOID ItFsJffsPressure018(VOID);
+VOID ItFsJffsPressure019(VOID);
+VOID ItFsJffsPressure020(VOID);
+VOID ItFsJffsPressure021(VOID);
+VOID ItFsJffsPressure022(VOID);
+VOID ItFsJffsPressure023(VOID);
+VOID ItFsJffsPressure024(VOID);
+VOID ItFsJffsPressure025(VOID);
+VOID ItFsJffsPressure026(VOID);
+VOID ItFsJffsPressure027(VOID);
+VOID ItFsJffsPressure028(VOID);
+VOID ItFsJffsPressure029(VOID);
+VOID ItFsJffsPressure030(VOID);
+VOID ItFsJffsPressure031(VOID);
+VOID ItFsJffsPressure032(VOID);
+VOID ItFsJffsPressure033(VOID);
+VOID ItFsJffsPressure034(VOID);
+VOID ItFsJffsPressure035(VOID);
+VOID ItFsJffsPressure036(VOID);
+VOID ItFsJffsPressure037(VOID);
+VOID ItFsJffsPressure038(VOID);
+VOID ItFsJffsPressure039(VOID);
+VOID ItFsJffsPressure040(VOID);
+VOID ItFsJffsPressure041(VOID);
+VOID ItFsJffsPressure042(VOID);
+VOID ItFsJffsPressure043(VOID);
+VOID ItFsJffsPressure044(VOID);
+VOID ItFsJffsPressure045(VOID);
+VOID ItFsJffsPressure046(VOID);
+VOID ItFsJffsPressure047(VOID);
+VOID ItFsJffsPressure048(VOID);
+VOID ItFsJffsPressure049(VOID);
+VOID ItFsJffsPressure050(VOID);
+VOID ItFsJffsPressure051(VOID);
+VOID ItFsJffsPressure052(VOID);
+VOID ItFsJffsPressure053(VOID);
+
+VOID ItFsJffsPressure301(VOID);
+VOID ItFsJffsPressure302(VOID);
+VOID ItFsJffsPressure303(VOID);
+VOID ItFsJffsPressure304(VOID);
+VOID ItFsJffsPressure305(VOID);
+VOID ItFsJffsPressure306(VOID);
+VOID ItFsJffsPressure307(VOID);
+VOID ItFsJffsPressure308(VOID);
+VOID ItFsJffsPressure309(VOID);
+VOID ItFsJffsPressure310(VOID);
+VOID ItFsJffsPressure311(VOID);
+VOID ItFsJffsPressure312(VOID);
+VOID ItFsJffsPressure313(VOID);
+VOID ItFsJffsPressure314(VOID);
+VOID ItFsJffsPressure315(VOID);
+
+VOID ItFsJffsPerformance001(VOID);
+VOID ItFsJffsPerformance002(VOID);
+VOID ItFsJffsPerformance003(VOID);
+VOID ItFsJffsPerformance004(VOID);
+VOID ItFsJffsPerformance005(VOID);
+VOID ItFsJffsPerformance006(VOID);
+VOID ItFsJffsPerformance007(VOID);
+VOID ItFsJffsPerformance008(VOID);
+VOID ItFsJffsPerformance009(VOID);
+VOID ItFsJffsPerformance010(VOID);
+VOID ItFsJffsPerformance011(VOID);
+VOID ItFsJffsPerformance012(VOID);
+VOID ItFsJffsPerformance013(VOID);
+#endif
+
+#if defined(LOSCFG_USER_TEST_LLT)
+VOID ItFsJffs036(VOID);
+VOID ItFsJffs087(VOID);
+VOID ItFsJffs108(VOID);
+VOID ItFsJffs181(VOID);
+VOID ItFsJffs186(VOID);
+VOID ItFsJffs474(VOID);
+VOID ItFsJffs527(VOID);
+VOID ItFsJffs558(VOID);
+VOID ItFsJffs559(VOID);
+VOID ItFsJffs561(VOID);
+VOID ItFsJffs616(VOID);
+VOID ItFsJffs698(VOID);
+VOID ItFsJffs699(VOID);
+VOID LLT_VFS_JFFS_003(VOID);
+VOID LLT_VFS_JFFS_014(VOID);
+#endif
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_001.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..89f467e166704626630f9e0ce2fb6dbfffe55639
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_001.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, dirFd, len;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ dirFd = dirfd(dir);
+ ICUNIT_GOTO_NOT_EQUAL(dirFd, JFFS_IS_ERROR, dirFd, EXIT1);
+
+ fd = openat(dirFd, "test.txt", O_CREAT | O_RDWR | O_TRUNC);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, "01234567890123456789012345", 16); // 16 means length which will be writed
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = unlinkat(dirFd, "test.txt", 0);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME01);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(fd);
+ unlink(pathname1);
+ closedir(dir);
+EXIT:
+ rmdir(JFFS_PATH_NAME01);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_002.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8c6e3f38c579b25ebfc9b0dae40609a1ac051aa8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_002.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "/test1/test2/test3";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "/test1/test2";
+ CHAR *dname = NULL;
+ INT32 ret;
+
+ dname = dirname(pathname1);
+ ret = strcmp(pathname2, dname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs002(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_003.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..286f0a03f0c2f90ed4bc29eda1cc9a548450a1dc
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_003.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR *dname = NULL;
+ INT32 ret;
+ INT32 fd = -1;
+ DIR *dir1 = NULL;
+ DIR *dir2 = NULL;
+
+ dir1 = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir1, NULL, dir1, EXIT);
+
+ ret = closedir(dir1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test123");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ dir2 = fdopendir(fd);
+ ICUNIT_GOTO_NOT_EQUAL(dir2, NULL, dir2, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+
+ ret = closedir(dir2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ closedir(dir2);
+EXIT1:
+ unlink(pathname2);
+ return JFFS_NO_ERROR;
+EXIT:
+ closedir(dir1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs003(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_004.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b22c3de0b8eaee30949a75360d6023188ceab63f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_004.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ CHAR dname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *dname2 = NULL;
+ CHAR *pret = NULL;
+ INT32 ret;
+
+ pret = getcwd(dname1, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT);
+
+ dname2 = get_current_dir_name();
+ ICUNIT_GOTO_NOT_EQUAL(dname2, NULL, dname2, EXIT);
+
+ ret = strcmp(dname1, dname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs004(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_005.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0521a56348cef73e57483c89060b869a11a335d8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_005.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret1, ret2;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+
+ ret1 = getdtablesize();
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ ret2 = getdtablesize();
+ ICUNIT_GOTO_EQUAL(ret2, (ret1 + 1), ret2, EXIT2);
+
+ ret1 = close(fd);
+ ICUNIT_GOTO_EQUAL(ret1, JFFS_NO_ERROR, ret1, EXIT2);
+
+ ret1 = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret1, JFFS_NO_ERROR, ret1, EXIT1);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs005(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_006.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0defff83ad31a493ac6193fd1e3cb6b2f3a35dc3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_006.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret1, ret2;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ struct mntent *mnt = NULL;
+ FILE *fp = NULL;
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "test12");
+ fp = setmntent(pathname1, "w+b");
+ ICUNIT_GOTO_NOT_EQUAL(fp, NULL, fp, EXIT);
+
+ mnt = getmntent(fp);
+ ICUNIT_GOTO_NOT_EQUAL(mnt, NULL, mnt, EXIT);
+
+ printf("[%s:%d] mnt->mnt_fsname=%s\n", __FUNCTION__, __LINE__, mnt->mnt_fsname);
+ printf("[%s:%d] mnt->mnt_dir=%s\n", __FUNCTION__, __LINE__, mnt->mnt_dir);
+ printf("[%s:%d] mnt->mnt_type=%s\n", __FUNCTION__, __LINE__, mnt->mnt_type);
+ printf("[%s:%d] mnt->mnt_opts=%s\n", __FUNCTION__, __LINE__, mnt->mnt_opts);
+ printf("[%s:%d] mnt->mnt_freq=%d\n", __FUNCTION__, __LINE__, mnt->mnt_freq);
+ printf("[%s:%d] mnt->mnt_passno=%d\n", __FUNCTION__, __LINE__, mnt->mnt_passno);
+
+ endmntent(fp);
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+EXIT:
+ endmntent(fp);
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs006(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_007.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3bcc2b995723b59982de2f0a2b361f26ae8b2e10
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_007.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MOUNT_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MOUNT_DIR0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MOUNT_DIR0 };
+ glob_t buf;
+ int i, ret;
+ int fd1 = -1;
+ int fd2 = -2;
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test1");
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, JFFS_IS_ERROR, fd1, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test2");
+ fd2 = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, JFFS_IS_ERROR, fd2, EXIT2);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ glob("/storage/*", GLOB_NOSORT, NULL, &buf);
+ ICUNIT_GOTO_EQUAL(buf.gl_pathc, 2, buf.gl_pathc, EXIT1); // 2 means size of path
+
+ ret = strcmp(pathname1, buf.gl_pathv[0]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = strcmp(pathname2, buf.gl_pathv[1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ globfree(&buf);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd2);
+ unlink(pathname2);
+EXIT1:
+ close(fd1);
+ unlink(pathname1);
+EXIT:
+ globfree(&buf);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs007(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_008.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f75b0ef4c1f860e48314b83015c59d6560185247
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_008.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ DIR *dir = NULL;
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ fd = dirfd(dir);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ ret = mkdirat(fd, "TEST", HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+
+ ret = rmdir("/storage/TEST");
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ rmdir("/storage/TEST");
+EXIT1:
+ closedir(dir);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs008(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_009.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_009.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3119f6f2d3c83adf6285be1fa2847bc81efe9ce7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_009.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR tempFile[] = "tmp_XXXXXX";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ fd = mkstemp(tempFile);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = unlink(tempFile);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ unlink(tempFile);
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs009(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_010.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..022e8ce33be5aabf212a6d7d984a75954727a5d6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_010.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR tempFile[] = "tmp_XXXXXX_hello";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ fd = mkstemps(tempFile, 6); // 6 means size of file
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = unlink(tempFile);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ unlink(tempFile);
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs010(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_011.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_011.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..451e274ac598f0d5e054fab67cb29a8bf6f86060
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_011.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR tempFile[] = "test.XXXXXX";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR *pfd = NULL;
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ pfd = mktemp(tempFile);
+ ICUNIT_GOTO_NOT_EQUAL(pfd, NULL, pfd, EXIT1);
+ printf("temp_file = %s\n", tempFile);
+
+ fd = open(pfd, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = unlink(pfd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ unlink(pfd);
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs011(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_012.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_012.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..29ea6a29c318affb5fb630a9d7d032f04a8ade81
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_012.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR tempFile[] = "test_XXXXXX";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR *pfd = NULL;
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ pfd = mkdtemp(tempFile);
+ ICUNIT_GOTO_NOT_EQUAL(pfd, NULL, pfd, EXIT1);
+ printf("temp_file = %s, pfd=%s\n", tempFile, pfd);
+
+ ret = rmdir(tempFile);
+ printf("%s-%d temp=%s ret=%d\n", __FUNCTION__, __LINE__, tempFile, ret);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(pfd);
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs012(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_013.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_013.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9224707221ba829b403373acb6722a1b208e9637
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_013.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR tempFile[] = "test_XXXXXX";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ fd = mkostemp(tempFile, O_APPEND);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = unlink(tempFile);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ unlink(tempFile);
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs013(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_014.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_014.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2f4eb1035b97bd57ee5696929e47a4ba7cf36d19
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_014.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+
+ openlog("Test", LOG_CONS | LOG_PID, LOG_USER);
+ syslog(LOG_INFO, "This is a massage just for test");
+ closelog();
+
+ return JFFS_NO_ERROR;
+EXIT:
+ close(fd);
+ unlink("Test");
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs014(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_015.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_015.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8112716c22459b22444c01f39594a82dfbfa79d3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_015.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ long ret;
+
+ ret = pathconf(pathname1, _PC_LINK_MAX);
+ ICUNIT_GOTO_EQUAL(ret, _POSIX_LINK_MAX, ret, EXIT);
+
+ ret = pathconf(pathname1, _PC_NAME_MAX);
+ ICUNIT_GOTO_EQUAL(ret, NAME_MAX, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs015(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_016.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_016.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..61a1325ab9aabe2143dd43f6ec4678074eacaa5b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_016.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret1, ret2;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ struct mntent *mnt = NULL;
+ char *buf = NULL;
+ static struct mntent mnt1;
+ FILE *fp = NULL;
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "test12");
+ fp = setmntent(pathname1, "w+b");
+ ICUNIT_GOTO_NOT_EQUAL(fp, NULL, fp, EXIT);
+
+ mnt = getmntent_r(fp, &mnt1, buf, 1);
+ ICUNIT_GOTO_NOT_EQUAL(mnt, NULL, mnt, EXIT);
+
+ printf("[%s:%d] mnt->mnt_fsname=%s\n", __FUNCTION__, __LINE__, mnt->mnt_fsname);
+ printf("[%s:%d] mnt->mnt_dir=%s\n", __FUNCTION__, __LINE__, mnt->mnt_dir);
+ printf("[%s:%d] mnt->mnt_type=%s\n", __FUNCTION__, __LINE__, mnt->mnt_type);
+ printf("[%s:%d] mnt->mnt_opts=%s\n", __FUNCTION__, __LINE__, mnt->mnt_opts);
+ printf("[%s:%d] mnt->mnt_freq=%d\n", __FUNCTION__, __LINE__, mnt->mnt_freq);
+ printf("[%s:%d] mnt->mnt_passno=%d\n", __FUNCTION__, __LINE__, mnt->mnt_passno);
+
+ endmntent(fp);
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+EXIT:
+ endmntent(fp);
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItJffs016(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_017.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_017.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a7628c007ac3e8e36292800944fc2980a6b9562a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_017.cpp
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 DisplayInfo(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftwbuf)
+{
+ printf("%-3s %2d ",
+ (tflag == FTW_D) ? "d" : (tflag == FTW_DNR) ? "dnr" :
+ (tflag == FTW_DP) ? "dp" : (tflag == FTW_F) ? "f" :
+ (tflag == FTW_NS) ? "ns" : (tflag == FTW_SL) ? "sl" :
+ (tflag == FTW_SLN) ? "sln" : "???",
+ ftwbuf->level);
+
+ if (tflag == FTW_NS) {
+ printf("-------");
+ } else {
+ printf("%7jd", (intmax_t)sb->st_size);
+ }
+
+ printf(" %-40s %d %s\n", fpath, ftwbuf->base, fpath + ftwbuf->base);
+
+ return 0;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 flags = 0;
+ CHAR *pathnamedir = { JFFS_MAIN_DIR0 };
+ CHAR pathname01[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR pathname11[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR pathname02[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+
+ ret = mkdir(pathname01, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = mkdir(pathname11, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mkdir(pathname02, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = nftw(pathnamedir, DisplayInfo, 20, flags); // 20 means max fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = rmdir(pathname02);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = rmdir(pathname11);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname01);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ rmdir(pathname02);
+EXIT2:
+ rmdir(pathname11);
+EXIT1:
+ rmdir(pathname01);
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs017(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_018.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_018.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d285c6fe4b011beeb71134e8eb7be50c31f88696
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_018.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+#define TEST_STR "hello world"
+static UINT32 Testcase(VOID)
+{
+ FILE *fd = NULL;
+ INT32 ret;
+ size_t size;
+ char *ptr = NULL;
+ char *ptr1 = TEST_STR;
+
+ fd = open_memstream(&ptr, &size);
+ ICUNIT_GOTO_NOT_EQUAL(fd, NULL, fd, EXIT1);
+
+ fprintf(fd, TEST_STR);
+
+ ret = fclose(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = strcmp(ptr, ptr1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = strlen(ptr);
+ ICUNIT_GOTO_EQUAL(size, ret, size, EXIT);
+
+ free(ptr);
+ return JFFS_NO_ERROR;
+EXIT1:
+ fclose(fd);
+EXIT:
+ free(ptr);
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs018(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_019.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_019.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cc9c954bd862916c93685935d954f37279d4c981
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_019.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static constexpr wchar_t* TEST_STR = L"hello world";
+static UINT32 Testcase(VOID)
+{
+ FILE *fd = NULL;
+ INT32 ret;
+ size_t size;
+ wchar_t *ptr = NULL;
+ wchar_t *ptr1 = { TEST_STR };
+
+ fd = open_wmemstream(&ptr, &size);
+ ICUNIT_GOTO_NOT_EQUAL(fd, NULL, fd, EXIT1);
+
+ fwprintf(fd, ptr1);
+
+ ret = fclose(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = wcscmp(ptr, ptr1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = wcslen(ptr);
+ ICUNIT_GOTO_EQUAL(size, ret, size, EXIT);
+
+ free(ptr);
+ return JFFS_NO_ERROR;
+EXIT1:
+ fclose(fd);
+EXIT:
+ free(ptr);
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs019(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_020.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_020.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e813bff00ba70026797ad0f2c3d48a439052ec03
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_020.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+static constexpr int LINE_LENGTH = 50;
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathnamedir[LINE_LENGTH] = { JFFS_MAIN_DIR0 };
+ FILE *file = nullptr;
+ CHAR line[LINE_LENGTH];
+ CHAR *ptr = NULL;
+
+ ret = chdir(pathnamedir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ file = popen("pwd", "r");
+ ICUNIT_GOTO_NOT_EQUAL(file, NULL, file, EXIT);
+
+ ptr = fgets(line, LINE_LENGTH, file);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT1);
+
+ strcat_s(pathnamedir, LINE_LENGTH, "\n");
+ ret = strcmp(line, pathnamedir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = pclose(file);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ pclose(file);
+EXIT:
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs020(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_021.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_021.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fb14b4cdd191a222bccf058fc1fd259df5c77e28
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_021.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ DIR *dirp = NULL;
+ INT32 ret;
+ CHAR *pathnamedir = { JFFS_MAIN_DIR0 };
+ CHAR pathname01[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct dirent *dp1 = (struct dirent *)malloc(sizeof(struct dirent));
+ struct dirent *dp2 = (struct dirent *)malloc(sizeof(struct dirent));
+ struct dirent *dp2Bak = dp2;
+
+ strcat_s(pathname01, JFFS_STANDARD_NAME_LENGTH, "/test1");
+ ret = mkdir(pathname01, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dirp = opendir(pathnamedir);
+ ICUNIT_GOTO_NOT_EQUAL(dirp, NULL, dirp, EXIT2);
+
+ while (1) {
+ readdir_r(dirp, dp1, &dp2);
+
+ if (dp2 == NULL) {
+ break;
+ }
+
+ ret = strcmp(dp2->d_name, "test1");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ret = rmdir(pathname01);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ closedir(dirp);
+ free(dp1);
+ free(dp2Bak);
+ return JFFS_NO_ERROR;
+EXIT2:
+ rmdir(pathname01);
+ closedir(dirp);
+ free(dp1);
+ free(dp2Bak);
+ return JFFS_IS_ERROR;
+EXIT1:
+ rmdir(pathname01);
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs021(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_022.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_022.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8f27f5dfd44d2df3f15295b0497c62c98fc4f15f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_022.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static constexpr int MB = 1024 * 1024;
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR *pathname = { JFFS_MAIN_DIR0 };
+ struct statvfs vfs;
+ fsblkcnt_t blockSize;
+ fsblkcnt_t blockCount;
+ fsblkcnt_t totalSize;
+ fsblkcnt_t freeSize;
+ fsblkcnt_t usedSize;
+ fsblkcnt_t availSize;
+
+ ret = statvfs(pathname, &vfs);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ blockSize = vfs.f_bsize;
+ totalSize = vfs.f_blocks * blockSize;
+ freeSize = vfs.f_bfree * blockSize;
+ usedSize = (vfs.f_blocks - vfs.f_bavail) * blockSize;
+ availSize = vfs.f_bavail * blockSize;
+
+ printf("total_size = %0.2lf MB\n", (double)totalSize / (MB));
+ printf("free_size = %0.2lf MB\n", (double)freeSize / (MB));
+ printf("used_size = %0.2lf MB\n", (double)usedSize / (MB));
+ printf("avail_size = %0.2lf MB\n", (double)availSize / (MB));
+
+ return JFFS_NO_ERROR;
+EXIT:
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs022(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_023.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_023.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3bb14f82cbf535a3e5dbc70ee3d0e40118ab0a75
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_023.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, dirFd, len;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ dirFd = dirfd(dir);
+ ICUNIT_GOTO_NOT_EQUAL(dirFd, JFFS_IS_ERROR, dirFd, EXIT1);
+ printf("dirFd = %d\n", dirFd);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test.txt");
+ fd = open(pathname2, O_CREAT | O_RDWR | O_TRUNC);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, "01234567890123456789012345", 16); // 16 means write len
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = unlinkat(dirFd, "test.txt", 0);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME01);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(fd);
+ unlink(pathname1);
+ closedir(dir);
+EXIT:
+ rmdir(JFFS_PATH_NAME01);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs023(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_024.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_024.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eab44ec7bb75449afd53d21499e781e3ec068b0a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_024.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, dirFd, len;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ dirFd = dirfd(dir);
+ ICUNIT_GOTO_NOT_EQUAL(dirFd, JFFS_IS_ERROR, dirFd, EXIT1);
+ printf("dirFd = %d\n", dirFd);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test.txt");
+ fd = open(pathname2, O_CREAT | O_RDWR | O_TRUNC);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, "01234567890123456789012345", 16); // 16 means write len
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = renameat(dirFd, "test.txt", dirFd, "TEST.txt");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/TEST.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME01);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(fd);
+EXIT2:
+ unlink(pathname1);
+ closedir(dir);
+EXIT:
+ rmdir(JFFS_PATH_NAME01);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs024(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_025.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_025.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..756fb6fa25d71a114915792012680e1e520afc66
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_025.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ FILE *fp = NULL;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+
+ fp = fopen(pathname1, "w+");
+ ICUNIT_GOTO_NOT_EQUAL(fp, NULL, fp, EXIT);
+
+ ret = fclose(fp);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ fclose(fp);
+EXIT:
+ unlink(pathname1);
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs025(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_026.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_026.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..22c98fe493ebb8427e0711dae19e3fedae454b3d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_026.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EEXIST, errno, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs026(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_027.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_027.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6138c427e8e4e0c6b74899224f4e9942de1eb965
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_027.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs027(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_028.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_028.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5cc50c2152e94e4b9a75764d79946a5e6f84f3da
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_028.cpp
@@ -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 "It_vfs_jffs.h"
+
+static constexpr int TEST_STRLEN = 30;
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname[TEST_STRLEN] = { JFFS_BASE_DIR };
+ CHAR pathname1[TEST_STRLEN] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[TEST_STRLEN] = { JFFS_PATH_NAME0 };
+ CHAR *pathname3 = NULL;
+ CHAR buf1[TEST_STRLEN] = "";
+ CHAR buf2[TEST_STRLEN] = "";
+ CHAR *pret = NULL;
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ pathname3 = pathname2;
+ strcat_s(pathname2, TEST_STRLEN, "/test1");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ pret = getcwd(buf1, TEST_STRLEN);
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(buf1, pathname, buf1, EXIT1);
+
+ ret = fchdir(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ pret = getcwd(buf2, TEST_STRLEN);
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(buf2, pathname3, buf2, EXIT1);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ unlink(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs028(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_029.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_029.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2168a0c82b6e012659d7c231133eeea8a3a06e0f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_029.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static constexpr int TEST_STRLEN = 30;
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname1[TEST_STRLEN] = { JFFS_PATH_NAME0 };
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = fchmod(fd, S_IREAD);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ unlink(pathname1);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs029(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_030.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_030.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e24b569cc4e49de68b5be9df547369ff95a0517f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_030.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufname[PATH_MAX] = "";
+ CHAR *realName = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ realName = realpath(pathname1, bufname);
+ ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/////");
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "test");
+
+ realName = realpath(pathname2, bufname);
+ ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItJffs030(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_031.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_031.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b70ae91d6841fa6d7871aa75300f74e707ae8762
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_031.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+#define TEST_STR "abcdefghijk"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[JFFS_STANDARD_NAME_LENGTH] = { TEST_STR };
+ CHAR str[JFFS_STANDARD_NAME_LENGTH];
+ FILE *ptr = NULL;
+
+ fd = open(pathname1, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ len = write(fd, buf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
+
+ ptr = freopen(pathname1, "r", stdin);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT1);
+
+ scanf_s("%s", str, sizeof(str));
+ ret = strcmp(buf, str);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fclose(ptr);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs031(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_032.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_032.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..72e6a21ceefbb61a7ebfe8faa656657fd86bc23f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_032.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+
+ ret = lstat64(pathname1, &buf1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = lstat64(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = lstat64(pathname1, &buf1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs032(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_033.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_033.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..47d738774254b1f5f5f34bc2e8bab1eeeaa86e60
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_033.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+
+ ret = lstat(pathname1, &buf1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = lstat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = lstat(pathname1, &buf1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs033(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_034.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_034.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8a545054183a759727b2e848885b514d2723b1c5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_034.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+#define TEST_STR "abcdefghijk"
+#define EXPECT_TEST_STR "ghijk"
+static constexpr int OFFSET_NUM = 6;
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[JFFS_STANDARD_NAME_LENGTH] = { TEST_STR };
+ CHAR str[JFFS_STANDARD_NAME_LENGTH];
+ FILE *ptr = NULL;
+ off_t offset = OFFSET_NUM;
+ size_t fret;
+
+ fd = open(pathname1, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ len = write(fd, buf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
+
+ ptr = fopen(pathname1, "r+");
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT2);
+
+ ret = fseeko(ptr, offset, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ fret = fread(str, 1, JFFS_STANDARD_NAME_LENGTH, ptr);
+ ICUNIT_GOTO_EQUAL(fret, (JFFS_STANDARD_NAME_LENGTH - OFFSET_NUM), fret, EXIT2);
+
+ ret = strcmp(EXPECT_TEST_STR, str);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = fclose(ptr);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ fclose(ptr);
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs034(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_035.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_035.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..00e7ddc647a2670bc9385a196aa4d1c15f2c0acc
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_035.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+#define TEST_STR "abcdefghijk"
+#define EXPECT_TEST_STR "ghijk"
+static constexpr int OFFSET_NUM = 6;
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[JFFS_STANDARD_NAME_LENGTH] = { TEST_STR };
+ CHAR str[JFFS_STANDARD_NAME_LENGTH];
+ FILE *ptr = NULL;
+ off_t offset1 = OFFSET_NUM;
+ off_t offset2;
+ size_t fret;
+
+ fd = open(pathname1, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ len = write(fd, buf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
+
+ ptr = fopen(pathname1, "r+");
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT2);
+
+ ret = fseeko(ptr, offset1, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ offset2 = ftello(ptr);
+ ICUNIT_GOTO_EQUAL(offset2, offset1, offset2, EXIT2);
+
+ ret = fclose(ptr);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ fclose(ptr);
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs035(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_036.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_036.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c5e1a5415c4af967fb19092d2bfd25b6d4772024
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_036.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname2);
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ closedir(dir);
+ rmdir(pathname2);
+ return JFFS_IS_ERROR;
+EXIT1:
+ closedir(dir);
+EXIT:
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs036(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_037.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_037.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3f051912943d4128deb139c683b9e833387ea7c7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_037.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ dir = opendir(pathname2);
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOTDIR, errno, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd);
+EXIT2:
+ unlink(pathname2);
+ return JFFS_IS_ERROR;
+EXIT1:
+ closedir(dir);
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs037(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_038.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_038.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9f231318e3e8eb8ba354e1d42a241e6453cc5334
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_038.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ long offset;
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ closedir(dir);
+ rmdir(pathname2);
+ return JFFS_IS_ERROR;
+EXIT1:
+ closedir(dir);
+EXIT:
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs038(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_039.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_039.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9c093f4bb0f44b8f5670e9d803b412f07cc5f669
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_039.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ closedir(dir);
+ rmdir(pathname2);
+ return JFFS_IS_ERROR;
+EXIT1:
+ closedir(dir);
+EXIT:
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs039(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_040.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_040.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..640f1cbc88d9679d9bc6c667032b04668e2a5f4c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_040.cpp
@@ -0,0 +1,218 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+typedef struct __dirstream {
+ off_t tell;
+ int fd;
+ int bufPos;
+ int bufEnd;
+ volatile int lock[1];
+ void *dirk;
+ void *resv;
+ /* Any changes to this struct must preserve the property:
+ * offsetof(struct __dirent, buf) % sizeof(off_t) == 0 */
+ char buf[2048];
+} DIR;
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, scandirCount;
+ INT32 fd = -1;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR adir = { 0 };
+ DIR *dir1 = &adir;
+ struct dirent *ptr = NULL;
+ off_t offset, offset1, offset2, offset3, offset4;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname, sizeof(pathname), "/0test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT5);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ offset1 = telldir(dir1);
+ ptr = readdir(dir1);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT4);
+
+ offset2 = telldir(dir1);
+ ptr = readdir(dir1);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT4);
+
+ offset3 = telldir(dir1);
+ ptr = readdir(dir1);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT4);
+
+ offset4 = telldir(dir1);
+ ptr = readdir(dir1);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT4);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT5);
+
+ ptr = readdir(dir);
+ offset1 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset2 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset3 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset4 = ptr->d_off;
+
+ seekdir(dir, offset2);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset2, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "1test", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ seekdir(dir, offset1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset1, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ seekdir(dir, offset4);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset4, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT5);
+
+ seekdir(dir, offset3);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset3, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0test", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 4, scandirCount, EXIT5); // 4 means total scaned file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[0]->d_name, "0file", namelist[0]->d_name, EXIT); // 0 means first file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[1]->d_name, "0test", namelist[1]->d_name, EXIT); // 1 means second file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[2]->d_name, "1test", namelist[2]->d_name, EXIT); // 2 means third file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[3]->d_name, "2test", namelist[3]->d_name, EXIT); // 3 means four file
+
+ seekdir(dir, namelist[3]->d_off); // 3 means four file
+ offset = telldir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(offset, -1, offset, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset1, namelist[3]->d_off, offset1, EXIT5); // 3 means four file
+ ICUNIT_GOTO_EQUAL(offset, namelist[3]->d_off, offset, EXIT5); // 3 means four file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+
+ seekdir(dir, namelist[2]->d_off); // 2 means third file
+ offset = telldir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(offset, -1, offset, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset3, namelist[2]->d_off, offset3, EXIT5); // 2 means third file
+ ICUNIT_GOTO_EQUAL(offset, namelist[2]->d_off, offset, EXIT5); // 2 means third file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0test", ptr->d_name, EXIT5);
+
+ JffsScandirFree(namelist, scandirCount);
+
+ scandirCount = 0;
+
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, 0, NULL);
+ ICUNIT_GOTO_EQUAL(scandirCount, 4, scandirCount, EXIT5); // 4 means total scaned file
+
+ seekdir(dir, namelist[3]->d_off); // 3 means four file
+ ICUNIT_GOTO_EQUAL(offset4, namelist[3]->d_off, offset4, EXIT5); // 3 means four file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT5);
+
+ seekdir(dir, namelist[0]->d_off); // 0 means first file
+ ICUNIT_GOTO_EQUAL(offset1, namelist[0]->d_off, offset1, EXIT5); // 0 means first file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+
+EXIT6:
+ JffsScandirFree(namelist, scandirCount);
+EXIT5:
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+EXIT4:
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ rmdir(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ rmdir(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs040(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_041.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_041.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..00aec4a371b7d511090652c49ffcd8bf9d08f03d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_041.cpp
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+typedef struct __dirstream {
+ off_t tell;
+ int fd;
+ int bufPos;
+ int bufEnd;
+ volatile int lock[1];
+ void *dirk;
+ void *resv;
+ /* Any changes to this struct must preserve the property:
+ * offsetof(struct __dirent, buf) % sizeof(off_t) == 0 */
+ char buf[2048];
+} DIR;
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, scandirCount;
+ INT32 fd = -1;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR adir = { 0 };
+ DIR *dir1 = &adir;
+ struct dirent *ptr = NULL;
+ off_t offset, offset1, offset2, offset3, offset4;
+ struct dirent **namelist = NULL;
+
+ errno = 0;
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, 0, NULL);
+ ICUNIT_GOTO_EQUAL(scandirCount, -1, scandirCount, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname, sizeof(pathname), "/0test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT5);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ offset1 = telldir(dir1);
+ ptr = readdir(dir1);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT4);
+
+ offset2 = telldir(dir1);
+ ptr = readdir(dir1);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT4);
+
+ offset3 = telldir(dir1);
+ ptr = readdir(dir1);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT4);
+
+ offset4 = telldir(dir1);
+ ptr = readdir(dir1);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT4);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT5);
+
+ ptr = readdir(dir);
+ offset1 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset2 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset3 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset4 = ptr->d_off;
+
+ seekdir(dir, offset2);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset2, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "1test", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ seekdir(dir, offset1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset1, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ seekdir(dir, offset4);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset4, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT5);
+
+ seekdir(dir, offset3);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset3, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0test", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 4, scandirCount, EXIT5); // 4 means total scaned file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[0]->d_name, "0file", namelist[0]->d_name, EXIT); // 0 means first file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[1]->d_name, "0test", namelist[1]->d_name, EXIT); // 1 means second file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[2]->d_name, "1test", namelist[2]->d_name, EXIT); // 2 means third file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[3]->d_name, "2test", namelist[3]->d_name, EXIT); // 3 means four file
+
+ seekdir(dir, namelist[3]->d_off); // 3 means four file
+ offset = telldir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(offset, -1, offset, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset1, namelist[3]->d_off, offset1, EXIT5); // 3 means four file
+ ICUNIT_GOTO_EQUAL(offset, namelist[3]->d_off, offset, EXIT5); // 3 means four file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+
+ seekdir(dir, namelist[2]->d_off); // 2 means third file
+ offset = telldir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(offset, -1, offset, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset3, namelist[2]->d_off, offset3, EXIT5); // 2 means third file
+ ICUNIT_GOTO_EQUAL(offset, namelist[2]->d_off, offset, EXIT5); // 2 means third file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0test", ptr->d_name, EXIT5);
+
+ JffsScandirFree(namelist, scandirCount);
+
+ scandirCount = 0;
+
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, 0, NULL);
+ ICUNIT_GOTO_EQUAL(scandirCount, 4, scandirCount, EXIT5); // 4 means total scaned file
+
+ seekdir(dir, namelist[3]->d_off); // 3 means four file
+ ICUNIT_GOTO_EQUAL(offset4, namelist[3]->d_off, offset4, EXIT5); // 3 means four file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT5);
+
+ seekdir(dir, namelist[0]->d_off); // 0 means first file
+ ICUNIT_GOTO_EQUAL(offset1, namelist[0]->d_off, offset1, EXIT5); // 0 means first file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+
+EXIT6:
+ JffsScandirFree(namelist, scandirCount);
+EXIT5:
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+EXIT4:
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ rmdir(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ rmdir(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs041(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_042.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_042.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7e8413eaf690fe5be43814bb86fe2af81f6e032c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_042.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, scandirCount;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent **namelist = NULL;
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ scandirCount = scandir(pathname2, &namelist, 0, NULL);
+ ICUNIT_GOTO_EQUAL(scandirCount, -1, scandirCount, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOTDIR, errno, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd);
+EXIT2:
+ unlink(pathname2);
+ return JFFS_IS_ERROR;
+EXIT1:
+ closedir(dir);
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs042(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_043.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_043.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..06f93d47e4f388b05b28b7ce408edaf08a2a3e57
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_043.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+typedef struct __dirstream {
+ off_t tell;
+ int fd;
+ int bufPos;
+ int bufEnd;
+ volatile int lock[1];
+ void *dirk;
+ void *resv;
+ /* Any changes to this struct must preserve the property:
+ * offsetof(struct __dirent, buf) % sizeof(off_t) == 0 */
+ char buf[2048];
+} DIR;
+
+static UINT32 Testcase(VOID)
+{
+ DIR *dirp = NULL;
+ INT32 ret;
+ CHAR *pathnamedir = (CHAR *)JFFS_MAIN_DIR0;
+ CHAR pathname01[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct dirent *dp1 = (struct dirent *)malloc(sizeof(struct dirent));
+ struct dirent *dp2 = (struct dirent *)malloc(sizeof(struct dirent));
+ struct dirent *dp2Bak = dp2;
+ DIR adir = { 0 };
+ DIR *dir1 = &adir;
+
+ strcat_s(pathname01, JFFS_STANDARD_NAME_LENGTH, "/test1");
+ ret = mkdir(pathname01, HIGHEST_AUTHORITY);
+ if (ret != 0) {
+ if (errno != EEXIST) {
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ }
+
+ dirp = opendir(pathnamedir);
+ ICUNIT_GOTO_NOT_EQUAL(dirp, NULL, dirp, EXIT2);
+
+ while (1) {
+ ret = readdir_r(dir1, dp1, &dp2);
+ printf("ret=%d\n", ret);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT2);
+ break;
+ }
+
+ ret = rmdir(pathname01);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ closedir(dirp);
+ free(dp1);
+ free(dp2Bak);
+ return JFFS_NO_ERROR;
+EXIT2:
+ rmdir(pathname01);
+ if (dirp) closedir(dirp);
+ free(dp1);
+ free(dp2Bak);
+ return JFFS_IS_ERROR;
+EXIT1:
+ rmdir(pathname01);
+ return JFFS_IS_ERROR;
+}
+
+VOID ItJffs043(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_jffs_044.cpp b/testsuites/unittest/fs/jffs/full/It_jffs_044.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..deff624993bf9734fa800f91827cce21fa67adf3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_jffs_044.cpp
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+typedef struct __dirstream {
+ off_t tell;
+ int fd;
+ int bufPos;
+ int bufEnd;
+ volatile int lock[1];
+ void *dirk;
+ void *resv;
+ /* Any changes to this struct must preserve the property:
+ * offsetof(struct __dirent, buf) % sizeof(off_t) == 0 */
+ char buf[2048];
+} DIR;
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, scandirCount;
+ INT32 fd = -1;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR adir = { 0 };
+ DIR *dir1 = &adir;
+ struct dirent *ptr = NULL;
+ off_t offset, offset1, offset2, offset3, offset4;
+ off_t offsetTest;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname, sizeof(pathname), "/0test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT5);
+
+ ptr = readdir(dir);
+ offset1 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset2 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset3 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset4 = ptr->d_off;
+
+ errno = 0;
+ seekdir(dir, offset2);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, EXIT5);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset2, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "1test", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ seekdir(dir, offset1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset1, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ seekdir(dir, offset4);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset4, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT5);
+
+ seekdir(dir, offset3);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset3, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0test", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 4, scandirCount, EXIT5); // 4 means total scaned file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[0]->d_name, "0file", namelist[0]->d_name, EXIT); // 0 means first file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[1]->d_name, "0test", namelist[1]->d_name, EXIT); // 1 means second file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[2]->d_name, "1test", namelist[2]->d_name, EXIT); // 2 means third file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[3]->d_name, "2test", namelist[3]->d_name, EXIT); // 3 means four file
+
+ seekdir(dir, namelist[3]->d_off); // 3 means four file
+ offset = telldir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(offset, -1, offset, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset1, namelist[3]->d_off, offset1, EXIT5); // 3 means four file
+ ICUNIT_GOTO_EQUAL(offset, namelist[3]->d_off, offset, EXIT5); // 3 means four file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+
+ seekdir(dir, namelist[2]->d_off); // 2 means third file
+ offset = telldir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(offset, -1, offset, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset3, namelist[2]->d_off, offset3, EXIT5); // 2 means third file
+ ICUNIT_GOTO_EQUAL(offset, namelist[2]->d_off, offset, EXIT5); // 2 means third file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0test", ptr->d_name, EXIT5);
+
+ JffsScandirFree(namelist, scandirCount);
+
+ scandirCount = 0;
+
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, 0, NULL);
+ ICUNIT_GOTO_EQUAL(scandirCount, 4, scandirCount, EXIT5); // 4 means total scaned file
+
+ seekdir(dir, namelist[3]->d_off); // 3 means four file
+ ICUNIT_GOTO_EQUAL(offset4, namelist[3]->d_off, offset4, EXIT5); // 3 means four file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT5);
+
+ seekdir(dir, namelist[0]->d_off); // 0 means first file
+ ICUNIT_GOTO_EQUAL(offset1, namelist[0]->d_off, offset1, EXIT5); // 0 means first file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+
+EXIT6:
+ JffsScandirFree(namelist, scandirCount);
+EXIT5:
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+EXIT4:
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ rmdir(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ rmdir(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItJffs044(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_004.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2e12343653a5348a40cdfcc3dc3676c1eb99570b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_004.cpp
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, scandirCount;
+ INT32 fd = -1;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset, offset1, offset2, offset3, offset4;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname, sizeof(pathname), "/0test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT5);
+
+ ptr = readdir(dir);
+ offset1 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset2 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset3 = ptr->d_off;
+
+ ptr = readdir(dir);
+ offset4 = ptr->d_off;
+
+ seekdir(dir, offset2);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset2, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "1test", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ seekdir(dir, offset1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset1, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ seekdir(dir, offset4);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset4, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT5);
+
+ seekdir(dir, offset3);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, offset3, offset, EXIT5);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0test", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 4, scandirCount, EXIT5); // 4 means total scaned file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[0]->d_name, "0file", namelist[0]->d_name, EXIT); // 0 means first file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[1]->d_name, "0test", namelist[1]->d_name, EXIT); // 1 means second file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[2]->d_name, "1test", namelist[2]->d_name, EXIT); // 2 means third file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[3]->d_name, "2test", namelist[3]->d_name, EXIT); // 3 means four file
+
+ seekdir(dir, namelist[3]->d_off); // 3 means four file
+ offset = telldir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(offset, -1, offset, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset1, namelist[3]->d_off, offset1, EXIT5); // 3 means four file
+ ICUNIT_GOTO_EQUAL(offset, namelist[3]->d_off, offset, EXIT5); // 3 means four file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+
+ seekdir(dir, namelist[2]->d_off); // 2 means third file
+ offset = telldir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(offset, -1, offset, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset3, namelist[2]->d_off, offset3, EXIT5); // 2 means third file
+ ICUNIT_GOTO_EQUAL(offset, namelist[2]->d_off, offset, EXIT5); // 2 means third file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0test", ptr->d_name, EXIT5);
+
+ JffsScandirFree(namelist, scandirCount);
+
+ scandirCount = 0;
+
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, 0, NULL);
+ ICUNIT_GOTO_EQUAL(scandirCount, 4, scandirCount, EXIT5); // 4 means total scaned file
+
+ seekdir(dir, namelist[3]->d_off); // 3 means four file
+ ICUNIT_GOTO_EQUAL(offset4, namelist[3]->d_off, offset4, EXIT5); // 3 means four file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT5);
+
+ seekdir(dir, namelist[0]->d_off); // 0 means first file
+ ICUNIT_GOTO_EQUAL(offset1, namelist[0]->d_off, offset1, EXIT5); // 0 means first file
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+
+EXIT6:
+ JffsScandirFree(namelist, scandirCount);
+EXIT5:
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+EXIT4:
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ rmdir(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ rmdir(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs004(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_004", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_006.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8a0613cb01667445efb4a7fd84941f761a28c0e8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_006.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret;
+ CHAR *pret = NULL;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ CHAR buf[30] = "";
+ struct dirent *ptr = NULL;
+ INT32 offset, offset1, offset2, offset3, offset4;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ pret = getcwd(buf, 30); // 30 means name length
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(buf, pathname, buf, EXIT);
+
+ strcat_s(pathname, sizeof(pathname), "/0test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ pret = getcwd(buf, 30); // 30 means name length
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(buf, pathname, buf, EXIT1);
+
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ pret = getcwd(buf, 30); // 30 means name length
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(buf, pathname, buf, EXIT3);
+
+ strcat_s(pathname, sizeof(pathname), "/1file");
+ fd1 = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT4);
+
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+ pret = getcwd(buf, 30); // 30 means name length
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(buf, pathname, buf, EXIT5);
+
+ ret = chdir("/storage");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+ pret = getcwd(buf, 30); // 30 means name length
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(buf, "/storage", buf, EXIT5);
+
+EXIT5:
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ rmdir(pathname);
+EXIT4:
+ JffsStrcat2(pathname, "/2test/1file", sizeof(pathname));
+ close(fd1);
+ remove(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ rmdir(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs006(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_006", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_007.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ffb42563b6615c0eaf59b4cf2db7f4d7e4109c59
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_007.cpp
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 fd3 = -1;
+ INT32 ret, scandirCount;
+ CHAR *pret = NULL;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ CHAR buf[50] = "";
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ struct stat statfile;
+ struct statfs statfsfile;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ pret = getcwd(buf, 20); // 20 means path name len
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(buf, pathname, buf, EXIT);
+
+ strcat_s(pathname, sizeof(pathname), "/0test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ strcat_s(pathname, sizeof(pathname), "/1file");
+ fd1 = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT4);
+
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ pret = getcwd(buf, 20); // 20 means path name len
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(buf, pathname, buf, EXIT5);
+
+ fd2 = open("2file", O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ fd3 = open("2file", O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd3, -1, fd3, EXIT6);
+
+ ret = mkdir("3dir", HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT7);
+
+ ret = mkdir("3dir", HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT7);
+
+ dir = opendir("3dir");
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT8);
+
+ scandirCount = scandir(".", &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 3, scandirCount, EXIT8); // 3 means scan file num
+ ICUNIT_GOTO_STRING_EQUAL(namelist[0]->d_name, "1file", namelist[0]->d_name, EXIT9); // 0 means first file
+
+ ret = rename("2file", "file2");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT10);
+
+ ret = stat("file2", &statfile);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT10);
+ ICUNIT_GOTO_EQUAL(statfile.st_size, 0, statfile.st_size, EXIT10);
+
+ ret = statfs("file2", &statfsfile);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT10);
+
+ ret = access("file2", R_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT10);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT10);
+
+ ret = unlink("file2");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT10);
+
+ ret = chdir("3dir");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT9);
+ strcat_s(pathname, sizeof(pathname), "/3dir");
+ pret = getcwd(buf, 30); // 30 means path name len
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT9);
+ ICUNIT_GOTO_STRING_EQUAL(buf, pathname, buf, EXIT9);
+
+ ret = chdir("../");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT9);
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ pret = getcwd(buf, 20); // 20 means path name len
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT9);
+ ICUNIT_GOTO_STRING_EQUAL(buf, pathname, buf, EXIT9);
+
+EXIT10:
+ JffsStrcat2(pathname, "/2test/file2", sizeof(pathname));
+ close(fd2);
+ remove(pathname);
+EXIT9:
+ JffsScandirFree(namelist, scandirCount);
+EXIT8:
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT8);
+EXIT7:
+ JffsStrcat2(pathname, "/2test/3dir", sizeof(pathname));
+ rmdir(pathname);
+EXIT6:
+ JffsStrcat2(pathname, "/2test/2file", sizeof(pathname));
+ close(fd2);
+ close(fd3);
+ remove(pathname);
+EXIT5:
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ rmdir(pathname);
+EXIT4:
+ JffsStrcat2(pathname, "/2test/1file", sizeof(pathname));
+ close(fd1);
+ remove(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ rmdir(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs007(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_007", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_008.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fee0df33185208675a6505a031f6f7b8b4714a91
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_008.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, scandirCount;
+ CHAR *pret = NULL;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ struct dirent **namelist = NULL;
+ INT32 offset, offset1, offset2, offset3, offset4;
+ CHAR buf[20];
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname, sizeof(pathname), "/0test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ strcat_s(pathname, sizeof(pathname), "/1file");
+ fd1 = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT4);
+
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset1 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset1 - 1, offset, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset2 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset2 - 1, offset, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset3 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset3 - 1, offset, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset4 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset4 - 1, offset, EXIT6);
+
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, NULL, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 4, scandirCount, EXIT6); // 4 means total scaned file
+
+ ICUNIT_GOTO_STRING_EQUAL(namelist[0]->d_name, "0file", namelist[0]->d_name, EXIT7); // 0 means first file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[1]->d_name, "0test", namelist[1]->d_name, EXIT7); // 1 means second file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[2]->d_name, "1test", namelist[2]->d_name, EXIT7); // 2 means third file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[3]->d_name, "2test", namelist[3]->d_name, EXIT7); // 3 means four file
+ ICUNIT_GOTO_EQUAL(namelist[0]->d_off, offset2, namelist[0]->d_off, EXIT7); // 0 means first file
+ ICUNIT_GOTO_EQUAL(namelist[2]->d_off, offset3, namelist[2]->d_off, EXIT7); // 2 means third file
+
+EXIT7:
+ JffsScandirFree(namelist, scandirCount);
+EXIT6:
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+EXIT5:
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ rmdir(pathname);
+EXIT4:
+ JffsStrcat2(pathname, "/2test/1file", sizeof(pathname));
+ close(fd1);
+ remove(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ rmdir(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs008(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_008", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_009.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_009.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..99da60b27ff7d8f92b645180193ef7ea1630017e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_009.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 ScandirF01(const struct dirent *ent)
+{
+ // read out a file while the name begined with "test"
+ return (strncmp(ent->d_name, "test", 4) == 0);
+}
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, scandirCount;
+ CHAR *pret = NULL;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ struct dirent **namelist = NULL;
+ INT32 offset, offset1, offset2, offset3, offset4;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname, sizeof(pathname), "/test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/testfile", 50); // 50 means name length
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ JffsStrcat2(pathname, "/0test1", 50); // 50 means name length
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ strcat_s(pathname, sizeof(pathname), "/test1file");
+ fd1 = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT4);
+
+ JffsStrcat2(pathname, "/test2", 50); // 50 means name length
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset1 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset1 - 1, offset, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset2 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset2 - 1, offset, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset3 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset3 - 1, offset, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset4 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset4 - 1, offset, EXIT6);
+
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, ScandirF01, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 3, scandirCount, EXIT6); // 3 means total scaned file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[0]->d_name, "test", namelist[0]->d_name, EXIT7); // 0 means first file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[1]->d_name, "test2", namelist[1]->d_name, EXIT7); // 1 means second file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[2]->d_name, "testfile", namelist[2]->d_name, EXIT7); // 2 means third file
+ ICUNIT_GOTO_EQUAL(namelist[0]->d_type, DT_DIR, namelist[0]->d_name, EXIT7); // 0 means first file
+
+EXIT7:
+ JffsScandirFree(namelist, scandirCount);
+EXIT6:
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+EXIT5:
+ JffsStrcat2(pathname, "/test2", sizeof(pathname));
+ rmdir(pathname);
+EXIT4:
+ JffsStrcat2(pathname, "/0test1/test1file", sizeof(pathname));
+ close(fd1);
+ remove(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/0test1", sizeof(pathname));
+ rmdir(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/testfile", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/test", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs009(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_009", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_010.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b4e6e104883b9db49a8af60678ba6baca21b3a62
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_010.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 ScandirF01(const struct dirent *ent)
+{
+ return (strncmp(ent->d_name, "test", 4) == 0);
+}
+
+static INT32 ScandirF02(const struct dirent **a, const struct dirent **b)
+{
+ return -1;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, scandirCount;
+ CHAR *pret = NULL;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ struct dirent **namelist = NULL;
+ INT32 offset, offset1, offset2, offset3, offset4;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname, sizeof(pathname), "/test0");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/testfile", sizeof(pathname));
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ JffsStrcat2(pathname, "/0test1", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ strcat_s(pathname, sizeof(pathname), "/test1file");
+ fd1 = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT4);
+
+ JffsStrcat2(pathname, "/test1", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset1 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset1, offset, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset2 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset2, offset, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset3 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset3, offset, EXIT6);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ offset4 = ptr->d_off;
+ ICUNIT_GOTO_EQUAL(offset, offset4, offset, EXIT6);
+
+ scandirCount = scandir(JFFS_PATH_NAME0, &namelist, ScandirF01, ScandirF02);
+ ICUNIT_GOTO_EQUAL(scandirCount, 3, scandirCount, EXIT7); // 3 means total scaned file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[0]->d_name, "test0", namelist[0]->d_name, EXIT7); // 0 means first file
+ ICUNIT_GOTO_STRING_EQUAL(namelist[1]->d_name, "test1", namelist[1]->d_name, EXIT7); // 1 means second file
+ ICUNIT_GOTO_EQUAL(namelist[0]->d_type, DT_DIR, namelist[0]->d_name, EXIT7); // 0 means first file
+
+EXIT7:
+ JffsScandirFree(namelist, scandirCount);
+EXIT6:
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+EXIT5:
+ JffsStrcat2(pathname, "/test1", sizeof(pathname));
+ rmdir(pathname);
+EXIT4:
+ JffsStrcat2(pathname, "/0test1/test1file", sizeof(pathname));
+ close(fd1);
+ remove(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/0test1", sizeof(pathname));
+ rmdir(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/testfile", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/test0", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs010(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_010", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_011.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_011.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f2be1f732f4e28ce34a874eebe954058ac8052ce
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_011.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ INT32 offset;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ strcat_s(pathname, sizeof(pathname), "/0test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ strcat_s(pathname, sizeof(pathname), "/1test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ strcat_s(pathname, sizeof(pathname), "/2test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ strcat_s(pathname, sizeof(pathname), "/0file");
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT5);
+
+ JffsStrcat2(pathname, "/0test/1test/2test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT5);
+
+ JffsStrcat2(pathname, "/0test/1test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT5);
+
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT5);
+
+ JffsStrcat2(pathname, "/0test/1test/2test/0file", sizeof(pathname));
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+ ret = remove(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ JffsStrcat2(pathname, "/0test/1test/2test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname, "/0test/1test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT5:
+ JffsStrcat2(pathname, "/0test/1test/2test/0file", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT4:
+ JffsStrcat2(pathname, "/0test/1test/2test", sizeof(pathname));
+ rmdir(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/0test/1test", sizeof(pathname));
+ rmdir(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ rmdir(pathname);
+EXIT1:
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs011(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_011", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_012.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_012.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0f1965c949ad8735d038d3a6910e39bff38a85d1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_012.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir1 = NULL;
+ DIR *dir2 = NULL;
+ DIR *dir3 = NULL;
+ DIR *dir4 = NULL;
+ struct dirent *ptr = NULL;
+ INT32 offset;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir1 = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir1, NULL, dir1, EXIT1);
+
+ strcat_s(pathname, sizeof(pathname), "/0test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ dir2 = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir2, NULL, dir2, EXIT3);
+
+ strcat_s(pathname, sizeof(pathname), "/1test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ dir3 = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir3, NULL, dir3, EXIT5);
+
+ strcat_s(pathname, sizeof(pathname), "/2test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ dir4 = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir4, NULL, dir4, EXIT7);
+
+ strcat_s(pathname, sizeof(pathname), "/0file");
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT8);
+
+ ret = closedir(dir1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT8);
+
+ ret = closedir(dir2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT8);
+
+ ret = closedir(dir3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT8);
+
+ ret = closedir(dir4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT8);
+
+ JffsStrcat2(pathname, "/0test/1test/2test/0file", sizeof(pathname));
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT8);
+ ret = remove(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT8);
+
+ JffsStrcat2(pathname, "/0test/1test/2test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname, "/0test/1test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT8:
+ JffsStrcat2(pathname, "/0test/1test/2test/0file", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT7:
+ closedir(dir4);
+EXIT6:
+ JffsStrcat2(pathname, "/0test/1test/2test", sizeof(pathname));
+ rmdir(pathname);
+EXIT5:
+ closedir(dir3);
+EXIT4:
+ JffsStrcat2(pathname, "/0test/1test", sizeof(pathname));
+ rmdir(pathname);
+EXIT3:
+ closedir(dir2);
+EXIT2:
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ rmdir(pathname);
+EXIT1:
+ closedir(dir1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs012(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_012", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_013.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_013.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..30e7209e4b173cf539d26086e0e41efd2b3ab537
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_013.cpp
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd[5] = { -1 };
+ INT32 ret, len;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[100] = { 0 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd[0] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY); // 0 means first fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[0], -1, fd[0], EXIT); // 0 means first fd
+
+ strcat_s(pathname, sizeof(pathname), "0");
+ fd[1] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY); // 1 means second fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[1], -1, fd[1], EXIT1); // 1 means second fd
+
+ strcat_s(pathname, sizeof(pathname), "1");
+ fd[2] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY); // 2 means third fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[2], -1, fd[2], EXIT2); // 2 means third fd
+
+ strcat_s(pathname, sizeof(pathname), "2");
+ fd[3] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY); // 3 means four fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[3], -1, fd[3], EXIT3); // 3 means four fd
+
+ strcat_s(pathname, sizeof(pathname), "3");
+ fd[4] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY); // 4 means fifth fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[4], -1, fd[4], EXIT4); // 4 means fifth fd
+
+ len = write(fd[0], filebuf, strlen(filebuf)); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT4);
+
+ off = lseek(fd[0], 0, SEEK_SET); // 0 means first fd
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT4);
+
+ len = read(fd[0], readbuf, JFFS_STANDARD_NAME_LENGTH); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT4);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT4);
+
+ len = write(fd[1], filebuf, strlen(filebuf)); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT4);
+
+ off = lseek(fd[1], 0, SEEK_SET); // 1 means second fd
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT4);
+
+ len = read(fd[1], readbuf, JFFS_STANDARD_NAME_LENGTH); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT4);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT4);
+
+ len = write(fd[2], filebuf, strlen(filebuf)); // 2 means third fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT4);
+
+ off = lseek(fd[2], 0, SEEK_SET); // 2 means third fd
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT4);
+
+ len = read(fd[2], readbuf, JFFS_STANDARD_NAME_LENGTH); // 2 means third fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT4);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT4);
+
+ len = write(fd[3], filebuf, strlen(filebuf)); // 3 means four fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT4);
+
+ off = lseek(fd[3], 0, SEEK_SET); // 3 means four fd
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT4);
+
+ len = read(fd[3], readbuf, JFFS_STANDARD_NAME_LENGTH); // 3 means four fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT4);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT4);
+
+ len = write(fd[4], filebuf, strlen(filebuf)); // 4 means fifth fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT4);
+
+ off = lseek(fd[4], 0, SEEK_SET); // 4 means fifth fd
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT4);
+
+ len = read(fd[4], readbuf, JFFS_STANDARD_NAME_LENGTH); // 4 means fifth fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT4);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT4);
+
+EXIT4:
+ JffsStrcat2(pathname, "0123", sizeof(pathname));
+ close(fd[4]); // 4 means fifth fd
+ remove(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "012", sizeof(pathname));
+ close(fd[3]); // 3 means four fd
+ remove(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "01", sizeof(pathname));
+ close(fd[2]); // 2 means third fd
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "0", sizeof(pathname));
+ close(fd[1]); // 1 means second fd
+ remove(pathname);
+EXIT:
+ close(fd[0]); // 0 means first fd
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs013(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_013", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_014.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_014.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eef10fe81b981716c2a78ccd3f87811f521e8a6f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_014.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd[3] = { -1 };
+ INT32 ret, len;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[100] = { 0 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ fd[0] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 0 means first fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[0], -1, fd[0], EXIT1); // 0 means first fd
+
+ fd[1] = open(pathname, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY); // 1 means second fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[1], -1, fd[1], EXIT2); // 1 means second fd
+
+ fd[2] = open(pathname, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY); // 2 means third fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[2], -1, fd[2], EXIT3); // 2 means third fd
+
+ len = write(fd[0], filebuf, strlen(filebuf)); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT3);
+
+ len = read(fd[1], readbuf, JFFS_STANDARD_NAME_LENGTH); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT3);
+
+ len = read(fd[2], readbuf, JFFS_STANDARD_NAME_LENGTH); // 2 means third fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT3);
+
+ len = write(fd[2], filebuf, strlen(filebuf)); // 2 means third fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT3);
+
+ len = read(fd[1], readbuf, JFFS_STANDARD_NAME_LENGTH); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT3);
+
+ len = read(fd[0], readbuf, JFFS_STANDARD_NAME_LENGTH); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT3);
+
+ strcpy_s(filebuf, sizeof(filebuf), "abcdeabcde1");
+ len = write(fd[1], filebuf, strlen(filebuf)); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(len, 11, len, EXIT3); // 11 means write len
+
+ len = read(fd[2], readbuf, JFFS_STANDARD_NAME_LENGTH); // 2 means third fd
+ ICUNIT_GOTO_EQUAL(len, 11, len, EXIT3); // 11 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT3);
+
+ len = read(fd[0], readbuf, JFFS_STANDARD_NAME_LENGTH); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(len, 11, len, EXIT3); // 11 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT3);
+
+ strcpy_s(filebuf, sizeof(filebuf), "fghjkfghjk12");
+ len = write(fd[0], filebuf, strlen(filebuf)); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(len, 12, len, EXIT3); // 12 means write len
+
+ strcpy_s(filebuf, sizeof(filebuf), "qqqqqppppp12");
+ len = write(fd[2], filebuf, strlen(filebuf)); // 2 means third fd
+ ICUNIT_GOTO_EQUAL(len, 12, len, EXIT3); // 12 means write len
+
+ len = read(fd[1], readbuf, JFFS_STANDARD_NAME_LENGTH); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(len, 12, len, EXIT3); // 12 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "qqqqqppppp12", readbuf, EXIT3);
+
+ ret = close(fd[2]); // 2 means third fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd[1]); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd[0]); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd[2]); // 2 means third fd
+EXIT2:
+ close(fd[1]); // 1 means second fd
+EXIT1:
+ close(fd[0]); // 0 means first fd
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs014(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_014", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_015.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_015.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e38d2c309db874ad40aac3168516e6ac32920a6d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_015.cpp
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[20] = { 0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname2, sizeof(pathname2), "/jffs_1015.txt");
+ fd = creat(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname3, sizeof(pathname3), "/1015_123.txt");
+ ret = rename(pathname2, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd = open(pathname2, O_NONBLOCK | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT);
+
+ fd = open(pathname3, O_NONBLOCK | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT3);
+
+ fd1 = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd1, -1, fd1, EXIT4);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT5);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "1015_123.txt", ptr->d_name, EXIT5);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT3);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567890", readbuf, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ return JFFS_NO_ERROR;
+EXIT5:
+ if (dir) ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+EXIT4:
+ close(fd1);
+EXIT3:
+ strcat_s(pathname3, sizeof(pathname3), "/1015_123.txt");
+ close(fd);
+ remove(pathname3);
+EXIT2:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+EXIT1:
+ strcat_s(pathname2, sizeof(pathname2), "/jffs_1015.txt");
+ close(fd);
+ remove(pathname2);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs015(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_015", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_016.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_016.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..10c256fd1b0175385e7a6e352236288f19546625
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_016.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[20] = { 0 };
+ off_t off;
+
+ fd = open(JFFS_PATH_NAME0, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ strcat_s(pathname, sizeof(pathname), "123");
+ fd1 = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT3);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT3);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT3);
+ len = read(fd1, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = rename(JFFS_PATH_NAME0, pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ fd1 = open(pathname, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT3);
+
+ len = read(fd1, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+ return JFFS_NO_ERROR;
+
+EXIT5:
+ close(fd1);
+EXIT4:
+ JffsStrcat2(pathname, "123", strlen(pathname));
+ remove(pathname);
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd1);
+EXIT2:
+ JffsStrcat2(pathname, "123", strlen(pathname));
+ remove(pathname);
+EXIT1:
+ close(fd);
+EXIT:
+ JffsStrcat2(pathname, JFFS_PATH_NAME0, strlen(pathname));
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs016(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_016", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_017.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_017.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ffd2ffa3b083bac44cf7ae57f2f3975d683a8d41
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_017.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/0test");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname, sizeof(pathname), "/dirfiles");
+
+ ret = rename(pathname1, pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT2); // ²»´æÔÚ
+
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ JffsStrcat2(pathname, "/dirfiles", strlen(pathname));
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname1, "/0test", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs017(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_017", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_018.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_018.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..86df9fde13a5e3e65f5d389c3521d07a3d6fee4c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_018.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/0test");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(pathname, sizeof(pathname), "/dirfiles");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rename(pathname1, pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT2); // ²»´æÔÚ
+
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ JffsStrcat2(pathname, "/dirfiles", strlen(pathname));
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname1, "/0test", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs018(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_018", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_019.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_019.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f0c9a9d19be274bfe3ef303b2ff5a8f32c77c41e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_019.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[50] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[20] = "1234567890";
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname2, sizeof(pathname2), "/0test");
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dirfiles");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ strcat_s(pathname3, sizeof(pathname3), "/dirfiles/files");
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT4);
+
+ printf("pathname1: %s pathname2: %s pathname3: %s\n", pathname1, pathname2, pathname3);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT4); // 10 means file name length
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+
+ ret = rename(pathname2, pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT5);
+
+ ret = rename(pathname1, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ JffsStrcat2(pathname3, "/0test/files", sizeof(pathname3));
+ ret = unlink(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT5:
+ JffsStrcat2(pathname3, "/0test/files", strlen(pathname3));
+ remove(pathname3);
+EXIT4:
+ close(fd);
+EXIT3:
+ JffsStrcat2(pathname3, "/dirfiles/files", strlen(pathname3));
+ remove(pathname3);
+EXIT2:
+ JffsStrcat2(pathname2, "/dirfiles", strlen(pathname2));
+ remove(pathname2);
+EXIT1:
+ JffsStrcat2(pathname1, "/0test", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs019(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_019", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_020.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_020.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9fd127c18740231386eeeffaa2c02df49f447f8d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_020.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[20] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(pathname, sizeof(pathname), "/files");
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ ret = rename(pathname1, pathname);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ JffsStrcat2(pathname1, "/files", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir1", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs020(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_020", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_023.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_023.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..208130c06807a38516f07d76a7d8ab2156e6096c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_023.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 ret;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR bufdir1[50] = { JFFS_PATH_NAME0 };
+ CHAR bufdir2[50] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(bufdir1, sizeof(bufdir1), "/dir/dirfile1");
+ ret = mkdir(bufdir1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ strcat_s(bufdir2, sizeof(bufdir2), "/dir/dirfile1/dirfile2");
+ ret = mkdir(bufdir2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = rename(bufdir1, bufdir2);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = rename(bufdir2, bufdir1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT3);
+ ret = rmdir(bufdir1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = rmdir(bufdir2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = rmdir(bufdir1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ JffsStrcat2(pathname1, "/dir/dirfile1/dirfile2", strlen(pathname1));
+ remove(pathname1);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/dirfile1", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs023(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_023", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_024.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_024.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8d907c9e8fdce3b639fe5b74ce5fd5fa7718815e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_024.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1 = -1;
+ INT32 ret;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile1[50] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rename(pathname1, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(buffile1, sizeof(buffile1), "/dir/file1");
+ fd1 = open(buffile1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = rename(buffile1, buffile1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = unlink(buffile1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd1);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/file1", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs024(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_024", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_025.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_025.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..213524421cc4ece7c9bfb851bc8277e77f922fe4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_025.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR bufdir1[50] = { JFFS_PATH_NAME0 };
+ CHAR bufdir2[50] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(bufdir1, sizeof(bufdir1), "/dir/dirfile1");
+ ret = mkdir(bufdir1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ strcat_s(bufdir2, sizeof(bufdir2), "/dir/dirfile1/dirfile2");
+ ret = rename(bufdir2, bufdir1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = rmdir(bufdir1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(bufdir2);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ JffsStrcat2(pathname1, "/dir/dirfile1/dirfile2", strlen(pathname1));
+ remove(pathname1);
+ goto EXIT1;
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/dirfile1", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs025(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_025", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_028.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_028.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..10b6ee566110f337288b05278f516f7bf1015473
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_028.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct stat buf3 = { 0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(buffile, sizeof(buffile), "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ len = write(fd, "012345678901234567890123456789", 30); // 30 means write len
+ ICUNIT_GOTO_EQUAL(len, 30, len, EXIT3); // 30 means write len
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_blocks, buf2.st_blocks, buf1.st_blocks, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_size, buf2.st_size, buf1.st_size, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_blksize, buf2.st_blksize, buf1.st_blksize, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_ino, buf2.st_ino, buf1.st_ino, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_mode, buf2.st_mode, buf1.st_mode, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_mtim.tv_nsec, buf2.st_mtim.tv_nsec, buf1.st_mtim.tv_nsec, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(buffile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/files", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs028(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_028", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_029.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_029.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f6e18c67fba5ce45621176d5028a48276f20f162
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_029.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct stat buf3 = { 0 };
+ INT32 n = 103;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(buffile, sizeof(buffile), "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ while (n--) {
+ len = write(fd, "0123456789012345678901234567890123456789", 40); // 40 means write len
+ ICUNIT_GOTO_EQUAL(len, 40, len, EXIT3); // 40 means write len
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_blocks, buf2.st_blocks, buf1.st_blocks, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_size, buf2.st_size, buf1.st_size, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_blksize, buf2.st_blksize, buf1.st_blksize, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_ino, buf2.st_ino, buf1.st_ino, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_mode, buf2.st_mode, buf1.st_mode, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_mtim.tv_nsec, buf2.st_mtim.tv_nsec, buf1.st_mtim.tv_nsec, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(buffile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/files", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs029(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_029", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_030.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_030.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e7d1d132a4b24e5059e40ee0379edaa2f1fb9385
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_030.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct stat buf3 = { 0 };
+ INT32 n = 256;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(buffile, sizeof(buffile), "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ while (n--) {
+ len = write(fd, "01234567890123456789012345", 16); // 16 means write len
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT3); // 16 means write len
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_size, buf2.st_size, buf1.st_size, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_blksize, buf2.st_blksize, buf1.st_blksize, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(buffile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/files", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs030(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_030", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_031.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_031.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..08a21a6174af2ba95f04bf494abedf9b6110b0e3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_031.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(buffile, sizeof(buffile), "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ len = write(fd, "01234567890123456789012345", 16); // 16 means write len
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT3); // 16 means write len
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(buffile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/files", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs031(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_031", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_032.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_032.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0bb59f07af586d6169bd57bd63ac6b591e0373f6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_032.cpp
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ CHAR readbuf[20] = { 0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(buffile, sizeof(buffile), "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ ret = fstat(fd, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ LosTaskDelay(20); // 20 means timedelay length
+ len = read(fd, readbuf, 20); // 20 means read length
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT3);
+
+ ret = fstat(fd, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ LosTaskDelay(20); // 20 means timedelay length
+ len = write(fd, "01234567890123456789012345", 16); // 16 means write len
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT3); // 16 means write len
+
+ ret = fstat(fd, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(buffile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/files", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs032(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_032", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_033.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_033.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..082f373ac0d35728f23751aecf4858fc694c6be6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_033.cpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ CHAR readbuf[20] = { 0 };
+
+ LosTaskDelay(10); // 10 means delay time length
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ LosTaskDelay(10); // 10 means delay time length
+ strcat_s(buffile, sizeof(buffile), "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ LosTaskDelay(10); // 10 means delay time length
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT3);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ LosTaskDelay(10); // 10 means delay time length
+ len = write(fd, "01234567890123456789012345", 16); // 16 means write len
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT3); // 16 means write len
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(buffile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/files", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs033(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_033", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_037.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_037.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2ceda67d972715e20a07008a4eb3010fbc692912
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_037.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[50] = { 0 };
+ CHAR pathname[50] = "/storage/liteos";
+ CHAR pathname1[50] = "/storage/liteosliteosli";
+ CHAR pathname2[50] = "/storage/liteosliteoslit";
+ CHAR pathname3[50] = "/storage/liteos";
+ CHAR pathname4[50] = "/storage/liteosliteosli";
+ CHAR pathname5[50] = "/jffs/liteosliteoslit";
+ off_t off;
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+ JffsDeletefile(fd, pathname3);
+
+ fd = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT4);
+ JffsDeletefile(fd, pathname4);
+
+ fd = open(pathname5, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT5);
+
+ return JFFS_NO_ERROR;
+EXIT5:
+ close(fd);
+ remove(pathname5);
+ return JFFS_NO_ERROR;
+EXIT4:
+ close(fd);
+ remove(pathname4);
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd);
+ remove(pathname3);
+ return JFFS_NO_ERROR;
+EXIT2:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs037(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_037", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_038.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_038.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bf59e2df99e285b11f9bcfcad8fa87f407b058f0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_038.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+ struct stat buf1;
+
+ fd = creat(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = stat(pathname, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.st_size, 0, buf1.st_size, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs038(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_038", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_039.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_039.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..744cb5de8434ffd04f1c5aa1eb85a97dd4e85360
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_039.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[50] = " ";
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs039(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_039", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_040.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_040.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..339ff5cc4517446e81ed760c22f77f990ede81ab
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_040.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, i;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH][JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0, };
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ DIR *dir = NULL;
+ DIR *dir1[JFFS_STANDARD_NAME_LENGTH] = { NULL, };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ for (i = 0; i < JFFS_STANDARD_NAME_LENGTH; i++) {
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ memset_s(pathname2[i], JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH - 1, JFFS_SHORT_ARRAY_LENGTH, "/test%d", i);
+ JffsStrcat2(pathname2[i], bufname, strlen(bufname));
+
+ ret = mkdir(pathname2[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < JFFS_STANDARD_NAME_LENGTH; i++) {
+ dir1[i] = opendir(pathname2[i]);
+ ICUNIT_GOTO_NOT_EQUAL(dir1[i], NULL, dir1[i], EXIT3);
+ }
+
+ for (i = 0; i < JFFS_STANDARD_NAME_LENGTH; i++) {
+ ret = closedir(dir1[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (i = 0; i < JFFS_STANDARD_NAME_LENGTH; i++) {
+ ret = remove(pathname2[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ for (i = 0; i < JFFS_STANDARD_NAME_LENGTH; i++) {
+ closedir(dir1[i]);
+ }
+EXIT2:
+ for (i = 0; i < JFFS_STANDARD_NAME_LENGTH; i++) {
+ remove(pathname2[i]);
+ }
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs040(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_040", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_041.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_041.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..35b6ef88f0cb801c765018b8c4446b4f9b30a9a2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_041.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = { 0 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDONLY, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_EQUAL(readbuf[0], 0, readbuf[0], EXIT1);
+
+ fd1 = open(pathname, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT2);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT2);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567890", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ close(fd);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs041(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_041", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_042.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_042.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c3e4e88d5cb24ce13b6b6f22a055686446d2a7fe
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_042.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_WRONLY, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT1);
+
+ fd1 = open(pathname, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567890", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ close(fd);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs042(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_042", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_043.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_043.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4863839f5396c363e12af705585ffd73fa5a1909
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_043.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+
+ fd = open(pathname, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs043(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_043", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_044.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_044.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d922b5cb3c6b355ad6c81016b21b8aa0e8e9eaa0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_044.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_WRONLY, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ fd1 = open(pathname, O_NONBLOCK | O_CREAT | O_EXCL | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd1, -1, fd1, EXIT2);
+
+EXIT2:
+ close(fd1);
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs044(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_044", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_045.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_045.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..650663b734e08dd809865d0e89bd6111e5330ca8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_045.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = { 0 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname, O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ fd2 = open(pathname, O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd2, -1, fd2, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT2);
+
+ fd1 = open(pathname, O_APPEND | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT3);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT3);
+
+ len = write(fd1, "abcde", 6); // 6 means write len
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT3);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT3);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT3); // 16 means path name len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567890abcde", readbuf, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ ret = unlink(pathname);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+#if 1
+ close(fd1);
+#endif
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd1);
+EXIT2:
+ close(fd2);
+EXIT1:
+ close(fd);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs045(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_045", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_046.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_046.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..158367c4be2907702ff6d1dc3c575c2d46feedec
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_046.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd1 = open(pathname, O_NONBLOCK | O_TRUNC | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, " ", readbuf, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ ret = unlink(pathname);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+ goto EXIT;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs046(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_046", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_048.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_048.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f484f594060ca32cd234af2965a16c457a84694d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_048.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 len, ret;
+ CHAR filebuf[20] = "1234567890abcde";
+ CHAR readbuf[7] = { 0 };
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 15, len, EXIT1); // 15 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 4); // 4 means read len
+ ICUNIT_GOTO_EQUAL(len, 4, len, EXIT1); // 4 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234", readbuf, EXIT1);
+
+ len = read(fd, readbuf, 5); // 5 means read len
+ ICUNIT_GOTO_EQUAL(len, 5, len, EXIT1); // 5 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "56789", readbuf, EXIT1);
+
+ len = read(fd, readbuf, 6); // 6 means read len
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT1); // 6 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0abcde", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs048(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_048", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_049.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_049.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5fa6a7c154a852ef314c8922bf77b50442f74cae
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_049.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 len, ret;
+ CHAR filebuf[10] = "123456";
+ CHAR readbuf[10] = { 0 };
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT1); // 6 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 9); // 9 means length of data to be read
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT1); // 6 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "123456", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means length of data to be read
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT1); // 6 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "123456", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+ len = read(fd, readbuf, 11); // 11 means length of data to be read
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT1); // 6 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "123456", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs049(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_049", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_050.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_050.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cb1fe87acf9e2cd94200a0c6993c34f6801a9738
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_050.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 len, ret;
+ CHAR filebuf[10] = "123456";
+ CHAR readbuf[10] = { 0 };
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT1); // 6 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT1); // 6 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1", readbuf, EXIT1);
+
+ len = read(fd, readbuf, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs050(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_050", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_051.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_051.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d289e95bbb9e8defbd9926e057f991f06f2e4002
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_051.cpp
@@ -0,0 +1,276 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd[10] = { -1 };
+ INT32 ret;
+ CHAR pathname[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ INT32 offset;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT0);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT0);
+
+ strcat_s(pathname, JFFS_NAME_LIMITTED_SIZE, "/0testwe12rttyututututqweqqfsdfsdfsdf.exe");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/0testwe12rttyututututqweqqfsdfsdfsdffsdf1234567890.TXT", JFFS_NAME_LIMITTED_SIZE);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname,
+ "/0testwe12rttyututututqweqqfsdfsdfsdffsdf12345678900testwe12rttyututututqweqqfsdfsdfsdffsdf1234567890.123",
+ JFFS_NAME_LIMITTED_SIZE);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ JffsStrcat2(pathname, "/12345678901234567890123456789012345678901234567890.123", JFFS_NAME_LIMITTED_SIZE);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname, "/ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghjklmnopqrstuvwxyz.123", JFFS_NAME_LIMITTED_SIZE);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ JffsStrcat2(pathname, "/����ϵͳ������ȱ�δ�δ�.123", JFFS_NAME_LIMITTED_SIZE);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname, "/����ϵͳ������ȱ�δ�δ�123ttt.www", JFFS_NAME_LIMITTED_SIZE);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT7);
+
+ JffsStrcat2(pathname, "/����ϵͳ������ȱ�δ�δ�123ttt.www", JFFS_NAME_LIMITTED_SIZE);
+ fd[0] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(fd[0], -1, fd[0], EXIT7); // 0 means first fd
+
+ JffsStrcat2(pathname, "/0testwe12rttyututututqweqqfsdfsdfsdf.exe", JFFS_NAME_LIMITTED_SIZE);
+ fd[0] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(fd[0], -1, fd[0], EXIT7); // 0 means first fd
+
+ JffsStrcat2(pathname, "/0testwe12rttyututututqweqqfsdfsdfsdf.txt", JFFS_NAME_LIMITTED_SIZE);
+ fd[0] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 0 means first fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[0], -1, fd[0], EXIT8); // 0 means first fd
+
+ JffsStrcat2(pathname, "/0testwe12rttyututututqweqqfsdfsdfsdffsdf1234567890.WWW", JFFS_NAME_LIMITTED_SIZE);
+ fd[1] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 1 means second fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[1], -1, fd[1], EXIT9); // 1 means second fd
+
+ JffsStrcat2(pathname,
+ "/0testwe12rttyututututqweqqfsdfsdfsdffsdf12345678900testwe12rttyututututqweqqfsdfsdfsdffsdf1234567890.AAA",
+ JFFS_NAME_LIMITTED_SIZE);
+ fd[2] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 2 means third fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[2], -1, fd[2], EXIT10); // 2 means third fd
+
+ JffsStrcat2(pathname, "/12345678901234567890123456789012345678901234567890.456", JFFS_NAME_LIMITTED_SIZE);
+ fd[3] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 3 means four fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[3], -1, fd[3], EXIT11); // 3 means four fd
+
+ JffsStrcat2(pathname, "/ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghjklmnopqrstuvwxyz.456", JFFS_NAME_LIMITTED_SIZE);
+ fd[4] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 4 means fifth fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[4], -1, fd[4], EXIT12); // 4 means fifth fd
+
+ JffsStrcat2(pathname, "/����ϵͳ������ȱ�δ�δ�.123.456", JFFS_NAME_LIMITTED_SIZE);
+ fd[5] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 5 means six fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[5], -1, fd[5], EXIT13); // 5 means six fd
+
+ JffsStrcat2(pathname, "/����ϵͳ������ȱ�δ�δ�123ttt.www", JFFS_NAME_LIMITTED_SIZE);
+ fd[6] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 6 means seven fd
+ ICUNIT_GOTO_EQUAL(fd[6], -1, fd[6], EXIT13); // 6 means seven fd
+
+ JffsStrcat2(pathname, "/����ϵͳ������ȱ�δ�δ�123ttt.AAA", JFFS_NAME_LIMITTED_SIZE);
+ fd[6] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 6 means seven fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[6], -1, fd[6], EXIT14); // 6 means seven fd
+
+ JffsStrcat2(pathname, "/����ϵͳ������ȱ�δ�δ�123ttt.AAA", JFFS_NAME_LIMITTED_SIZE);
+ fd[7] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 7 means eight fd
+ ICUNIT_GOTO_EQUAL(fd[7], -1, fd[7], EXIT14); // 7 means eight fd
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT15);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT15);
+ LosTaskDelay(5); // 5 means timedelay len
+
+EXIT14:
+ JffsStrcat2(pathname, "/����ϵͳ������ȱ�δ�δ�123ttt.AAA", JFFS_NAME_LIMITTED_SIZE);
+ ret = close(fd[6]); // 6 means seven fd
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT14_1);
+EXIT14_1:
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT13);
+
+EXIT13:
+ JffsStrcat2(pathname, "/����ϵͳ������ȱ�δ�δ�.123.456", JFFS_NAME_LIMITTED_SIZE);
+ ret = close(fd[5]); // 5 means six fd
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT13_1);
+EXIT13_1:
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT12);
+EXIT12:
+ JffsStrcat2(pathname, "/ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghjklmnopqrstuvwxyz.456", JFFS_NAME_LIMITTED_SIZE);
+ ret = close(fd[4]); // 4 means fifth fd
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT12_1);
+EXIT12_1:
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT11);
+EXIT11:
+ JffsStrcat2(pathname, "/12345678901234567890123456789012345678901234567890.456", JFFS_NAME_LIMITTED_SIZE);
+ ret = close(fd[3]); // 3 means four fd
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT11_1);
+EXIT11_1:
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT10);
+EXIT10:
+ JffsStrcat2(pathname,
+ "/0testwe12rttyututututqweqqfsdfsdfsdffsdf12345678900testwe12rttyututututqweqqfsdfsdfsdffsdf1234567890.AAA",
+ JFFS_NAME_LIMITTED_SIZE);
+ ret = close(fd[2]); // 2 means third fd
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT10_1);
+EXIT10_1:
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT9);
+EXIT9:
+ JffsStrcat2(pathname, "/0testwe12rttyututututqweqqfsdfsdfsdffsdf1234567890.WWW", JFFS_NAME_LIMITTED_SIZE);
+ ret = close(fd[1]); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT9_1);
+EXIT9_1:
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT8);
+
+EXIT8:
+ JffsStrcat2(pathname, "/0testwe12rttyututututqweqqfsdfsdfsdf.txt", JFFS_NAME_LIMITTED_SIZE);
+ ret = close(fd[0]); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT8_1);
+EXIT8_1:
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT7);
+
+EXIT7:
+ JffsStrcat2(pathname, "/����ϵͳ������ȱ�δ�δ�123ttt.www", JFFS_NAME_LIMITTED_SIZE);
+ rmdir(pathname);
+
+EXIT6:
+ JffsStrcat2(pathname, "/����ϵͳ������ȱ�δ�δ�.123", JFFS_NAME_LIMITTED_SIZE);
+ rmdir(pathname);
+EXIT5:
+ JffsStrcat2(pathname, "/ABCDEFGHJKLMNOPQRSTUVWXYZabcdefghjklmnopqrstuvwxyz.123", JFFS_NAME_LIMITTED_SIZE);
+ rmdir(pathname);
+EXIT4:
+ JffsStrcat2(pathname, "/12345678901234567890123456789012345678901234567890.123", JFFS_NAME_LIMITTED_SIZE);
+ rmdir(pathname);
+EXIT3:
+ JffsStrcat2(pathname,
+ "/0testwe12rttyututututqweqqfsdfsdfsdffsdf12345678900testwe12rttyututututqweqqfsdfsdfsdffsdf1234567890.123",
+ JFFS_NAME_LIMITTED_SIZE);
+ rmdir(pathname);
+
+EXIT2:
+ JffsStrcat2(pathname, "/0testwe12rttyututututqweqqfsdfsdfsdffsdf1234567890.TXT", JFFS_NAME_LIMITTED_SIZE);
+ rmdir(pathname);
+
+EXIT1:
+ JffsStrcat2(pathname, "/0testwe12rttyututututqweqqfsdfsdfsdf.exe", JFFS_NAME_LIMITTED_SIZE);
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+EXIT15:
+ closedir(dir);
+ goto EXIT14;
+ return JFFS_NO_ERROR;
+EXIT0:
+ closedir(dir);
+ goto EXIT;
+}
+
+VOID ItFsJffs051(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_051", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_053.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_053.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f11494a28aedea023089358f0086b7de25978d39
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_053.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 len, ret;
+ CHAR filebuf[20] = "1234567890abcde";
+ CHAR readbuf[JFFS_SHORT_ARRAY_LENGTH] = { 0 };
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 4); // 4 means read len
+ ICUNIT_GOTO_EQUAL(len, 4, len, EXIT1); // 4 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ memset_s(readbuf, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+
+ len = read(fd, readbuf, 2); // 2 means read len
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+ ICUNIT_GOTO_EQUAL(readbuf[0], 0, readbuf[0], EXIT);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ fd = open(pathname, O_CREAT | O_RDWR, HIGHEST_AUTHORITY); // Ôٴδò¿ªÎļþ
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 4); // 4 means read len
+ ICUNIT_GOTO_EQUAL(len, 4, len, EXIT1); // 4 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ len = read(fd, readbuf, 2); // 2 means read len
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234", readbuf, EXIT);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs053(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_053", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_055.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_055.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1d5325e1d7e22b83421b4cc361352fe14cfca209
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_055.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 len, ret;
+ CHAR filebuf[20] = "1234567890abcde&";
+ CHAR readbuf[5] = { 0 };
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT1); // 16 means write len
+
+ len = write(fd, filebuf, strlen(filebuf) + 1);
+ ICUNIT_GOTO_EQUAL(len, 17, len, EXIT1); // 17 means write len
+
+ len = write(fd, filebuf, strlen(filebuf) - 1);
+ ICUNIT_GOTO_EQUAL(len, 15, len, EXIT1); // 15 means write len
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs055(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_055", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_056.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_056.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f5addcc58cdd10da6823e6be5fde64fda96ff787
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_056.cpp
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 len, ret;
+ CHAR filebuf[20] = "1234567890abcde&";
+ CHAR readbuf[50] = { 0 };
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT1); // 16 means write len
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT1); // 16 means write len
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT1); // 16 means write len
+
+ len = write(fd, "END", 3); // 3 means name len
+ ICUNIT_GOTO_EQUAL(len, 3, len, EXIT1); // 3 means write len
+
+ off = lseek(fd, 10, SEEK_SET); // 10 means file seek len
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT1); // 10 means current file positon
+
+ len = read(fd, readbuf, 6); // 6 means read len
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT1); // 6 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcde&", readbuf, EXIT1);
+
+ off = lseek(fd, 2, SEEK_CUR); // 2 means file seek len
+ ICUNIT_GOTO_EQUAL(off, 18, off, EXIT1); // 18 means current file positon
+
+ memset_s(readbuf, sizeof(readbuf), 0, sizeof(readbuf));
+
+ len = read(fd, readbuf, 5); // 5 means read len
+ ICUNIT_GOTO_EQUAL(len, 5, len, EXIT1); // 5 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "34567", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 23, off, EXIT1); // 23 means current file positon
+
+ len = read(fd, readbuf, 5); // 5 means read len
+ ICUNIT_GOTO_EQUAL(len, 5, len, EXIT1); // 5 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "890ab", readbuf, EXIT1);
+
+ off = lseek(fd, -2, SEEK_CUR); // -2 means file seek back len
+ ICUNIT_GOTO_EQUAL(off, 26, off, EXIT1); // 26 means current file positon
+
+ len = read(fd, readbuf, 6); // 6 means read len
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT1); // 6 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcde&", readbuf, EXIT1);
+
+ memset_s(readbuf, sizeof(readbuf), 0, sizeof(readbuf));
+
+ off = lseek(fd, -2, SEEK_END); // -2 means file seek back len
+ ICUNIT_GOTO_EQUAL(off, 49, off, EXIT1); // 49 means current file positon
+
+ len = read(fd, readbuf, 5); // 5 means read len
+ ICUNIT_GOTO_EQUAL(len, 2, len, EXIT1); // 2 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "ND", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 51, off, EXIT1); // 51 means current file positon
+
+ len = read(fd, readbuf, 6); // 6 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+
+ off = lseek(fd, 2, SEEK_END); // 2 means file seek len
+ ICUNIT_GOTO_EQUAL(off, 53, off, EXIT1); // 53 means current file positon
+ len = read(fd, readbuf, 6); // 6 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+
+ len = write(fd, "mmm", 3); // 3 means write len
+ ICUNIT_GOTO_EQUAL(len, 3, len, EXIT1); // 3 means write len
+
+ off = lseek(fd, -3, SEEK_END); // -3 means file seek back len
+ ICUNIT_GOTO_EQUAL(off, 53, off, EXIT1); // 53 means current file positon
+
+ len = read(fd, readbuf, 5); // 5 means read len
+ ICUNIT_GOTO_EQUAL(len, 3, len, EXIT1); // 3 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "mmm", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs056(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_056", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_057.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_057.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..874eb88eb7251b14a659be223f222dac95345780
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_057.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, scandirCount;
+ INT32 fd = -1;
+ CHAR pathname[30] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT1);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT1);
+
+ scandirCount = scandir(pathname, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 0, scandirCount, EXIT2);
+
+ JffsScandirFree(namelist, scandirCount);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ if (scandirCount > 0)
+ JffsScandirFree(namelist, scandirCount);
+ else
+ goto EXIT1;
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs057(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_057", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_058.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_058.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..83ba2400b1a13fd880e52c56d6df415c32abd0b6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_058.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname[30] = { JFFS_MAIN_DIR0 };
+ CHAR pathname1[30] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[30] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ struct dirent **namelist = NULL;
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT);
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(pathname2, sizeof(pathname2), "/test");
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = access(pathname2, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = access(pathname2, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ rmdir(pathname2);
+EXIT1:
+ rmdir(pathname1);
+EXIT:
+ closedir(dir);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs058(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_058", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_059.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_059.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ad522df9bc23770a15f897c49870a86c9ec49705
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_059.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static constexpr int FILE_NAME_LEN = 10;
+static constexpr int MAX_FILE_NAME_LEN = 50;
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[MAX_FILE_NAME_LEN] = "liteos";
+ CHAR pathname[MAX_FILE_NAME_LEN] = { JFFS_PATH_NAME0 };
+ off_t off;
+ struct stat buf1;
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, FILE_NAME_LEN, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd = creat(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, MAX_FILE_NAME_LEN);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = stat(pathname, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.st_size, 0, buf1.st_size, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, FILE_NAME_LEN, len, EXIT1);
+
+ len = read(fd, readbuf, MAX_FILE_NAME_LEN);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs059(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_059", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_060.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_060.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2e8dc814693c81a60f6e668fe13e71ec3faefe50
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_060.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[50] = { 0 };
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ off_t off;
+ fd = open(pathname, O_NONBLOCK | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, 0, fd, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs060(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_060", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_061.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_061.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7f1c775e06fd75b0d493fcc1c3d1e8c7893e53cd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_061.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ INT32 offset;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs061(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_061", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_062.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_062.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7cd4633f562e94d40bc12fb5ecd192e7542c1226
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_062.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs062(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_062", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_063.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_063.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..de65202789e421512b3942e1bfc74ce3db2c23ce
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_063.cpp
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static constexpr int FILE_NAME_LEN = 10;
+static constexpr int MAX_FILE_NAME_LEN = 50;
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret;
+ CHAR pathname[MAX_FILE_NAME_LEN] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDONLY | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ fd1 = open(pathname, O_NONBLOCK | O_CREAT | O_WRONLY | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd1, -1, fd1, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_WRONLY, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(ret, FILE_NAME_LEN, ret, EXIT1);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ ret = read(fd, readbuf, FILE_NAME_LEN);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDONLY, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ ret = read(fd, readbuf, FILE_NAME_LEN);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(ret, FILE_NAME_LEN, ret, EXIT1);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ ret = read(fd, readbuf, FILE_NAME_LEN);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs063(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_063", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_064.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_064.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..47dbe0ed4de95a5c502324020d4f4ffeeef19524
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_064.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs064(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_064", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_065.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_065.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..21ddec70908da20bfe6cebe6dcbd7f47d4ed9da5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_065.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static constexpr int MAX_FILE_NUM = 50;
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, i;
+
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR *dir1[MAX_FILE_NUM] = {NULL};
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ while (i < MAX_FILE_NUM) {
+ dir1[i] = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir1[i], NULL, dir1[i], EXIT1);
+
+ i++;
+ }
+ for (i = 0; i < MAX_FILE_NUM; i++) {
+ ret = closedir(dir1[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ return JFFS_NO_ERROR;
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs065(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_065", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_066.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_066.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6f2fa45a4a4b8866588be4436583d5168424c161
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_066.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, i, j;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR bufname[10] = "";
+ CHAR pathname2[10][50] = { 0 };
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ for (i = 0; i < 10; i++) { // 10 means max file num
+ memset_s(bufname, sizeof(bufname), 0, strlen(bufname));
+ snprintf_s(bufname, sizeof(bufname) - 1, sizeof(bufname), "/%d", i);
+ strcat_s(pathname1, sizeof(pathname1), bufname);
+ strcpy_s(pathname2[i], sizeof(pathname2[i]), pathname1);
+
+ ret = mkdir(pathname2[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ }
+
+ for (i = 0; i < 9; i++) { // 9 means max file num
+ ret = rmdir(pathname2[i]);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ }
+ for (i = 9; i >= 0; i--) { // 9 means max file num
+ ret = rmdir(pathname2[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ }
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ for (i = 9; i >= 0; i--) { // 9 means max file num
+ rmdir(pathname2[i]);
+ }
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs066(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_066", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_067.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_067.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..74efa6cfaba0f6f412fad43090035ea78d323024
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_067.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs067(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_067", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_068.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_068.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ee3447fe9a8ddfceb64419cc573cca0056cd7931
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_068.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static constexpr int MAX_FILE_NAME_LEN = 50;
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 pfd = -1;
+ INT32 ret, len;
+ CHAR filebuf1[10] = "liteos ";
+ CHAR filebuf2[10] = "good";
+ CHAR readbuf[MAX_FILE_NAME_LEN] = { 0 };
+ CHAR pathname1[MAX_FILE_NAME_LEN] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[MAX_FILE_NAME_LEN] = { JFFS_PATH_NAME0 };
+ off_t off;
+ struct stat buf1;
+
+ errno = 0;
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ pfd = dup2(20, 20); // 20 means dup length
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT2);
+
+ pfd = dup2(fd, fd);
+ ICUNIT_GOTO_EQUAL(pfd, fd, pfd, EXIT2);
+
+ strcat_s(pathname2, sizeof(pathname2), "T");
+ fd1 = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT4);
+
+ pfd = dup2(fd, fd1);
+ printf("[%d] fd:%d, fd1:%d, pfd:%d, errno:%d\n", __LINE__, fd, fd1, pfd, errno);
+ ICUNIT_GOTO_EQUAL(pfd, fd1, pfd, EXIT4);
+
+ len = write(fd1, filebuf1, strlen(filebuf1));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf1), len, EXIT4);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ len = write(fd, filebuf2, strlen(filebuf2));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf2), len, EXIT4);
+
+ fd2 = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT5);
+
+ errno = 0;
+ len = read(fd2, readbuf, MAX_FILE_NAME_LEN);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT5);
+
+ ICUNIT_GOTO_EQUAL((INT32)lseek(fd2, 0, SEEK_CUR), 0, (INT32)lseek(fd2, 0, SEEK_CUR), EXIT5);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ len = write(fd, filebuf2, strlen(filebuf2));
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT5);
+
+ fd = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT5);
+
+ memset_s(readbuf, sizeof(readbuf), 0, strlen(readbuf));
+ len = read(fd, readbuf, MAX_FILE_NAME_LEN);
+ printf("[%d] fd:%d, errno:%d,readbuf:%s\n", __LINE__, fd, errno, readbuf);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf1) + strlen(filebuf2), len, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos good", readbuf, EXIT5);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ return JFFS_NO_ERROR;
+EXIT5:
+ close(fd2);
+ goto EXIT3;
+EXIT4:
+ close(fd1);
+EXIT3:
+ remove(pathname2);
+EXIT2:
+ close(pfd);
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs068(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_068", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_069.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_069.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fe6f6f67a8441bb21bb14801a1ccf32a0f0d6c94
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_069.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 pfd = -100;
+ INT32 pfd2 = -1;
+ INT32 ret, len;
+ CHAR filebuf1[JFFS_SHORT_ARRAY_LENGTH] = "liteos ";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+ struct stat buf1;
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ pfd = dup(fd);
+ ICUNIT_GOTO_NOT_EQUAL(pfd, -1, pfd, EXIT2);
+
+ len = write(fd, filebuf1, strlen(filebuf1));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf1), len, EXIT2);
+
+ off = lseek(fd, 3, SEEK_SET); // 3 means seek len
+ ICUNIT_GOTO_EQUAL(off, 3, off, EXIT2); // 3 means current file positon
+
+ pfd2 = dup(fd);
+ ICUNIT_GOTO_NOT_EQUAL(pfd2, -1, pfd2, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ memset_s(readbuf, sizeof(readbuf), 0, sizeof(readbuf));
+ len = read(fd, readbuf, 50); // 50 means read len
+ ICUNIT_GOTO_EQUAL(len, 7, len, EXIT1); // 7 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos ", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = close(pfd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = close(pfd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(pfd2);
+EXIT2:
+ close(pfd);
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs069(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_069", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_070.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_070.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ece103a51fe55bfb18c140a7db94a816ecba262b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_070.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ fd1 = open(pathname, O_NONBLOCK | O_TRUNC, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd1 = open(pathname, O_NONBLOCK | O_TRUNC | O_RDONLY, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT1);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd1 = open(pathname, O_NONBLOCK | O_TRUNC | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd1, -1, fd1, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+ goto EXIT;
+EXIT1:
+ close(fd1);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs070(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_070", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_071.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_071.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7b0eda76de8411550c2facddd50087d34f891e43
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_071.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, i;
+ INT32 fileCount = 0;
+ INT32 fd[JFFS_NAME_LIMITTED_SIZE] = { -1 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE][JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0, };
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_NAME_LIMITTED_SIZE; i++) {
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ memset_s(pathname2[i], JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH - 1, JFFS_SHORT_ARRAY_LENGTH, "/test%d", i);
+ JffsStrcat2(pathname2[i], bufname, strlen(bufname));
+
+ if (fd[fileCount] == (CONFIG_NFILE_DESCRIPTORS - 1)) {
+ fd[i] = open(pathname2[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd[i], -1, fd[i], EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EMFILE, errno, EXIT3);
+ continue;
+ }
+ fd[i] = open(pathname2[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT3);
+ fileCount = i;
+ }
+
+ for (i = 0; i < JFFS_NAME_LIMITTED_SIZE; i++) {
+ if (i > fileCount) {
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT3);
+ continue;
+ }
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ for (i = 0; i < JFFS_NAME_LIMITTED_SIZE; i++) {
+ if (i > fileCount) {
+ ret = remove(pathname2[i]);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT2);
+ continue;
+ }
+
+ ret = remove(pathname2[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ for (i = 0; i < JFFS_NAME_LIMITTED_SIZE; i++) {
+ close(fd[i]);
+ }
+EXIT2:
+ for (i = 0; i < JFFS_NAME_LIMITTED_SIZE; i++) {
+ remove(pathname2[i]);
+ }
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs071(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_071", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_072.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_072.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..72e2e87c995c41d364c81f40a7fd3f10a5ac9619
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_072.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, i;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ dir = opendir(JFFS_MAIN_DIR0);
+ printf("#####test72###11111111\n");
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT);
+
+ ret = closedir(dir);
+ printf("#####test72###22222222\n");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ printf("#####test72###333333333\n");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ printf("#####test72###444444444\n");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ printf("#####test72###555555555\n");
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs072(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_072", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_073.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_073.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..095ee361fb5fba31731a31f23d1ebd03c9ab1524
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_073.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, i;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ dir = opendir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs073(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_073", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_074.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_074.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..66c42e75795b6a28e1b9c7d72e2eb11bc5a22022
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_074.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1 = -1;
+ INT32 ret, i, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/test");
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT1);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < 1000; i++) { // 1000 means mount and umount times
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT1);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT1:
+ close(fd1);
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs074(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_074", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_076.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_076.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ed4760da9653e39c84a0afdf01adeabcf04a404f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_076.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1 = -1;
+ INT32 ret, i, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs076(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_076", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_077.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_077.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..127ad1b7042fda5576c868aebb98222db726879a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_077.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, i;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/test");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(pathname2, sizeof(pathname2), "/test");
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ remove(pathname2);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs077(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_077", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_078.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_078.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7399288bfa663e669b9a0a4b64d1eccba965c38f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_078.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 ret, i;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/test");
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT1);
+
+ strcat_s(pathname2, sizeof(pathname2), "/test");
+ fd2 = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd2);
+ remove(pathname2);
+EXIT1:
+ close(fd1);
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs078(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_078", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_079.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_079.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f9fd5ca22992f20ebb676a6e5a91123fc60de24a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_079.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 ret, i;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/test");
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ strcat_s(pathname2, sizeof(pathname2), "/TEst");
+ ret = rename(pathname1, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ fd2 = open(pathname2, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT2);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd2);
+ remove(pathname2);
+EXIT1:
+ close(fd1);
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs079(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_079", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_080.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_080.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0fb083698feae6c567297b20b47668195df2f5da
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_080.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1 = -1;
+ INT32 ret, i, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[50] = "liteos";
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[50] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/test");
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT1);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EBUSY, errno, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, "/storage", JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ mount(JFFS_DEV_PATH0, "/storage", JFFS_FILESYS_TYPE, 0, NULL);
+EXIT1:
+ close(fd1);
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs080(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_080", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_081.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_081.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..224ad0bbee3e00143cc87e495e187098d98bf3f4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_081.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1 = -1;
+ INT32 ret, i, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[50] = "liteos";
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EBUSY, errno, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ mount(JFFS_DEV_PATH0, "/storage", JFFS_FILESYS_TYPE, 0, NULL);
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs081(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_081", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_082.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_082.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cd31aa4610609764ccd7d870c68b66821002de06
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_082.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct dirent *ptr = NULL;
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/1082");
+ fd = open(pathname1, O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(buf1.st_mode & S_IFMT, S_IFREG, buf1.st_mode & S_IFMT, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return LOS_NOK;
+}
+
+VOID ItFsJffs082(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_082", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_083.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_083.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cc05fb854a0bdd4be81be449de1478cac6dbd4c0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_083.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ struct dirent *ptr = NULL;
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/10 77");
+ fd = open(pathname1, O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(buf1.st_mode & S_IFMT, S_IFREG, buf1.st_mode & S_IFMT, EXIT2);
+
+ len = write(fd, buf, sizeof(buf));
+ ICUNIT_GOTO_EQUAL(len, sizeof(buf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return LOS_NOK;
+}
+
+VOID ItFsJffs083(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_083", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_084.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_084.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1b81f594683a485d98364ffdaf9dad92ea17dae2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_084.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ struct dirent *ptr = NULL;
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/10 78");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname3, sizeof(pathname3), "/10 78/test");
+ fd = open(pathname3, O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = stat(pathname3, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(buf1.st_mode & S_IFMT, S_IFREG, buf1.st_mode & S_IFMT, EXIT2);
+
+ len = write(fd, buf, sizeof(buf));
+ ICUNIT_GOTO_EQUAL(len, sizeof(buf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+ remove(pathname3);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return LOS_NOK;
+}
+
+VOID ItFsJffs084(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_084", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_085.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_085.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8894682f40c56499cd45e5783fd29849a8fe5097
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_085.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ struct dirent *ptr = NULL;
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/test\0test");
+ fd = open(pathname1, O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname1, "/test\ntest", JFFS_STANDARD_NAME_LENGTH);
+ fd = open(pathname1, O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname1, "/test\ttest", JFFS_STANDARD_NAME_LENGTH);
+ fd = open(pathname1, O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return LOS_NOK;
+}
+
+VOID ItFsJffs085(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_085", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_086.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_086.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c2ddc86723ab19f0208a63f774b3f8ed1c0d4e9f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_086.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "/jffs111";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "/jffs222";
+ struct stat buf1 = { 0 };
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, pathname2, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, pathname3, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = umount(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = umount(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = stat(pathname2, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = stat(pathname3, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(pathname2);
+ goto EXIT;
+EXIT1:
+ remove(pathname3);
+EXIT:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ return LOS_NOK;
+}
+
+VOID ItFsJffs086(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_086", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_088.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_088.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d5529cdea818b64c4e50eefc0efd0162c5593793
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_088.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, i;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ errno = 0;
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs088(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_088", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_090.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_090.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e66b4633593575b5e5d084b567b31bb952c863f5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_090.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_SHORT_ARRAY_LENGTH] = "lalala";
+ CHAR readbuf[JFFS_SHORT_ARRAY_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, sizeof(pathname2), "/test");
+ fd = open64(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_NO_ERROR, off, EXIT1);
+
+ memset_s(readbuf, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs090(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_090", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_092.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_092.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0ab18405bb9b6d30397f71cd8bbf7759fae6ce21
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_092.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chmod(pathname1, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ strcat_s(pathname2, sizeof(pathname2), "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = chmod(pathname1, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+
+ ret = chmod(pathname1, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs092(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_092", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_093.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_093.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a9162e188d73986bd2855bfefa2730b1c1ff1e83
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_093.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static constexpr int MAX_FILE_LEN = 10;
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd[10] = { -1 };
+ INT32 ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[10][JFFS_STANDARD_NAME_LENGTH] = {JFFS_PATH_NAME0};
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ INT32 randTest1[10] = { 2, 6, 3, 1, 0, 8, 7, 9, 4, 5 };
+ INT32 randTest2[10] = { 5, 3, 1, 6, 7, 2, 4, 9, 0, 8 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < MAX_FILE_LEN; i++) {
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ memset_s(pathname2[i], JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH - 1, JFFS_SHORT_ARRAY_LENGTH, "/1071_%d", i);
+ strcat_s(pathname2[i], JFFS_STANDARD_NAME_LENGTH, pathname1);
+ strcat_s(pathname2[i], JFFS_STANDARD_NAME_LENGTH, bufname);
+ fd[i] = open(pathname2[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT2);
+ }
+ for (i = 0; i < MAX_FILE_LEN; i++) {
+ len = write(fd[randTest1[i]], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ ret = close(fd[randTest1[i]]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < MAX_FILE_LEN; i++) {
+ fd[randTest2[i]] = open(pathname2[randTest2[i]], O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT2);
+
+ len = read(fd[randTest2[i]], readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // 10 means length of actually read data
+
+ ret = close(fd[randTest2[i]]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < MAX_FILE_LEN; i++) {
+ ret = remove(pathname2[randTest2[i]]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = 0; i < MAX_FILE_LEN; i++) {
+ close(fd[randTest1[i]]);
+ }
+EXIT1:
+ for (i = 0; i < MAX_FILE_LEN; i++) {
+ remove(pathname2[randTest2[i]]);
+ }
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs093(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_093", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_096.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_096.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d42e75edbd43cd4b7f7d746ba4f34ddaca169bd2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_096.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 pfd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, sizeof(pathname2), "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ pfd = dup(fd);
+ ICUNIT_GOTO_NOT_EQUAL(pfd, -1, pfd, EXIT2);
+
+ ret = close(pfd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir("..");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(pfd);
+EXIT1:
+ close(fd);
+ remove(pathname2);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs096(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_096", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_097.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_097.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c4745728a1bb5c03d71df18639d4afc14fef1ed0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_097.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1, buf2;
+ struct utimbuf utime1;
+ time_t ttime1;
+ struct tm ttm1;
+
+ ttm1.tm_year = 90; // 90 means year
+ ttm1.tm_mon = 0; // 0 means month
+ ttm1.tm_mday = 1; // 1 means day
+ ttm1.tm_hour = 12; // 12 means hour
+ ttm1.tm_min = 12; // 12 means minute
+ ttm1.tm_sec = 12; // 12 means second
+ ttm1.tm_isdst = 0;
+ ttime1 = mktime(&ttm1);
+ utime1.modtime = ttime1;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/097");
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, 0644); // 0644 means mode of file
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ JffsStatPrintf(buf1);
+
+ ret = utime(pathname1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ JffsStatPrintf(buf1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = utime(pathname1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ JffsStatPrintf(buf1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs097(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_097", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_099.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_099.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c9c98d169ddf3d49ff6db87f3f8ce74da078f2a0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_099.cpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "test12");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = pread(fd, readbuf, JFFS_STANDARD_NAME_LENGTH, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, len, off, EXIT1);
+
+ len = pread(fd, readbuf, JFFS_STANDARD_NAME_LENGTH, off);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = pread(fd, readbuf, JFFS_STANDARD_NAME_LENGTH, 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ strcpy_s(readbuf, JFFS_STANDARD_NAME_LENGTH, "liteos");
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = pread(fd, readbuf, JFFS_STANDARD_NAME_LENGTH, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, len, off, EXIT1);
+
+ len = pread(fd, readbuf, JFFS_STANDARD_NAME_LENGTH, off);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = pread(fd, readbuf, JFFS_STANDARD_NAME_LENGTH, 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs099(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_099", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_100.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_100.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..54c8ef95ada600448641f0b6ea6766bf7a28568e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_100.cpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "test12");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = pwrite(fd, filebuf, strlen(filebuf), 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT); // 10 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ strcpy_s(readbuf, JFFS_STANDARD_NAME_LENGTH, "liteos");
+
+ strcat_s(pathname1, sizeof(pathname1), "test12");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = pwrite64(fd, filebuf, strlen(filebuf), 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT); // 10 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs100(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_100", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_101.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_101.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4dc89a75d995de8adb23b2a8e5fb45c76d6dd5c6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_101.cpp
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, i, scandirCount;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = "";
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "/jf";
+ CHAR pathname5[JFFS_STANDARD_NAME_LENGTH] = "/jf/test";
+ CHAR pathname6[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ memset_s(pathname2, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(pathname3, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(pathname6, sizeof(pathname6), "/");
+
+ while (i < 247) { // 247 means loop times
+ i++;
+ strcat_s(pathname2, sizeof(pathname2), "t");
+ strcat_s(pathname3, sizeof(pathname3), "t");
+ strcat_s(pathname6, sizeof(pathname6), "t");
+ }
+ ICUNIT_GOTO_EQUAL(strlen(pathname6), 259, strlen(pathname6), EXIT); // 259 means current name len
+ ICUNIT_GOTO_EQUAL(strlen(pathname2), 247, strlen(pathname2), EXIT); // 247 means current name len
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = mkdir(pathname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EEXIST, errno, EXIT1);
+
+ strcat_s(pathname3, sizeof(pathname3), "t");
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT2);
+
+ strcat_s(pathname6, sizeof(pathname6), "t");
+ ICUNIT_GOTO_EQUAL(strlen(pathname6), 260, strlen(pathname6), EXIT); // 260 means current name len
+ ret = mkdir(pathname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT2);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = mount(JFFS_DEV_PATH0, pathname4, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = chdir(pathname5);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = access(pathname2, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+
+ scandirCount = scandir(pathname5, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 2, scandirCount, EXIT5); // 2 means total scaned file
+
+ JffsScandirFree(namelist, scandirCount);
+
+ ret = umount(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ scandirCount = scandir(pathname1, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 2, scandirCount, EXIT5); // 2 means total scaned file
+
+ JffsScandirFree(namelist, scandirCount);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT4);
+
+ ret = rmdir(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT4);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mount(JFFS_DEV_PATH0, pathname4, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = chdir(pathname5);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT5:
+ JffsScandirFree(namelist, scandirCount);
+EXIT4:
+ umount(pathname4);
+ remove(pathname4);
+EXIT3:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT2:
+ remove(pathname3);
+ remove(pathname6);
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs101(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_101", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_102.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_102.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..30bd1abbefbd6b30ffdb52bcbf8d10319805f7cd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_102.cpp
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, i, scandirCount;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = { JFFS_MAIN_DIR0 };
+ CHAR pathname4[JFFS_NAME_LIMITTED_SIZE] = "";
+ CHAR pathname5[JFFS_NAME_LIMITTED_SIZE] = "";
+ CHAR pathname6[JFFS_STANDARD_NAME_LENGTH] = "/jf";
+ CHAR pathname7[JFFS_STANDARD_NAME_LENGTH] = "/jf";
+
+ struct dirent **namelist = NULL;
+
+ ret = chdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ memset_s(pathname4, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(pathname5, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(pathname3, sizeof(pathname3), "/");
+
+ while (i < 252) { // 252 means loop times
+ i++;
+ strcat_s(pathname4, sizeof(pathname4), "t");
+ strcat_s(pathname5, sizeof(pathname5), "t");
+ strcat_s(pathname3, sizeof(pathname3), "t");
+ }
+ ICUNIT_GOTO_EQUAL(strlen(pathname3), 259, strlen(pathname3), EXIT); // 259 means current name len
+ ICUNIT_GOTO_EQUAL(strlen(pathname4), 252, strlen(pathname4), EXIT); // 252 means current name len
+
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ fd = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EEXIST, errno, EXIT2);
+
+ strcat_s(pathname5, sizeof(pathname5), "t");
+ fd = open(pathname5, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT2);
+
+ strcat_s(pathname3, sizeof(pathname3), "t");
+ ICUNIT_GOTO_EQUAL(strlen(pathname3), 260, strlen(pathname3), EXIT); // 260 means current name len
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT2);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = mount(JFFS_DEV_PATH0, pathname6, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = chdir(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = access(pathname4, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ fd = open(pathname5, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT4);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+
+ scandirCount = scandir(pathname7, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 2, scandirCount, EXIT5); // 2 means total scaned file
+
+ JffsScandirFree(namelist, scandirCount);
+
+ ret = umount(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ scandirCount = scandir(pathname1, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 2, scandirCount, EXIT5); // 2 means total scaned file
+
+ JffsScandirFree(namelist, scandirCount);
+
+ ret = remove(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT4);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mount(JFFS_DEV_PATH0, pathname6, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = chdir(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname5);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = umount(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ return JFFS_NO_ERROR;
+EXIT5:
+ JffsScandirFree(namelist, scandirCount);
+EXIT4:
+ umount(pathname6);
+ remove(pathname6);
+EXIT3:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT2:
+ close(fd);
+ remove(pathname5);
+ remove(pathname3);
+EXIT1:
+ close(fd);
+ remove(pathname4);
+EXIT:
+ close(fd);
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs102(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_102", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_104.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_104.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..82c0f28ad5f7510674ae999666a545e11ea6b960
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_104.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd[3] = { -1 };
+ INT32 ret, len;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd[0] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY); // 0 means first fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[0], JFFS_IS_ERROR, fd[0], EXIT1); // 0 means first fd
+
+ fd[1] = open(pathname1, O_NONBLOCK | O_RDONLY, HIGHEST_AUTHORITY); // 1 means second fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[1], JFFS_IS_ERROR, fd[1], EXIT2); // 1 means second fd
+
+ ret = close(fd[1]); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd[0]); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd[0] = open(pathname1, O_NONBLOCK | O_CREAT | O_WRONLY, HIGHEST_AUTHORITY); // 0 means first fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[0], JFFS_IS_ERROR, fd[0], EXIT1); // 0 means first fd
+
+ fd[1] = open(pathname1, O_NONBLOCK | O_RDONLY, HIGHEST_AUTHORITY); // 1 means second fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[1], JFFS_IS_ERROR, fd[1], EXIT2); // 1 means second fd
+
+ fd[2] = open(pathname1, O_NONBLOCK | O_WRONLY, HIGHEST_AUTHORITY); // 2 means third fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[2], JFFS_IS_ERROR, fd[2], EXIT3); // 2 means third fd
+
+ ret = close(fd[2]); // 2 means third fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd[1]); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd[0]); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd[0] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDONLY, HIGHEST_AUTHORITY); // 0 means first fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[0], JFFS_IS_ERROR, fd[0], EXIT1); // 0 means first fd
+
+ fd[1] = open(pathname1, O_NONBLOCK | O_RDONLY, HIGHEST_AUTHORITY); // 1 means second fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[1], JFFS_IS_ERROR, fd[1], EXIT2); // 1 means second fd
+
+ ret = close(fd[1]); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd[0]); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd[0] = open(pathname1, O_NONBLOCK | O_RDONLY, HIGHEST_AUTHORITY); // 0 means first fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[0], JFFS_IS_ERROR, fd[0], EXIT1); // 0 means first fd
+
+ fd[1] = open(pathname1, O_NONBLOCK | O_RDONLY, HIGHEST_AUTHORITY); // 1 means second fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[1], JFFS_IS_ERROR, fd[1], EXIT2); // 1 means second fd
+
+ fd[2] = open(pathname1, O_NONBLOCK | O_WRONLY, HIGHEST_AUTHORITY); // 2 means third fd
+ ICUNIT_GOTO_NOT_EQUAL(fd[2], JFFS_IS_ERROR, fd[2], EXIT3); // 2 means third fd
+
+ len = write(fd[0], filebuf, strlen(filebuf)); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(len, JFFS_IS_ERROR, len, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT3);
+
+ len = write(fd[2], filebuf, strlen(filebuf)); // 2 means third fd
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT3);
+
+ off = lseek(fd[0], 0, SEEK_SET); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(off, JFFS_NO_ERROR, off, EXIT3);
+
+ len = read(fd[1], readbuf, JFFS_STANDARD_NAME_LENGTH); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT3);
+
+ ret = close(fd[2]); // 2 means third fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd[1]); // 1 means second fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd[0]); // 0 means first fd
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd[2]); // 2 means third fd
+EXIT2:
+ close(fd[1]); // 1 means second fd
+EXIT1:
+ close(fd[0]); // 0 means first fd
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_104
+* -@tspec The Function test for open
+* -@ttitle Open the file several times in read-only mode
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create one file and opened it in read-write mode;
+2. open the file several times in read-only mode
+3. write and read these fd
+4. close and remove all the file
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs104(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_104", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_105.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_105.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..298c9fa3c35f27e3356417dee5f9546cd08f25b7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_105.cpp
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, F_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_EXCL, S_IRWXU);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_EXCL, S_IRWXU | S_IRWXG);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_EXCL, S_IRWXU | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_105
+* -@tspec The Function test for access
+* -@ttitle Check file existence and permissions normally
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create one file ;
+2. check file existence and permissions normally;
+3. delete the file;
+4. N/A;
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A;
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs105(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_105", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_106.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_106.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4593970255e3dd567213bc1bdd6888f6246843b4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_106.cpp
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_EXCL, 0);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT, S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT, S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT, S_IRWXG);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_106
+* -@tspec The Function test for access
+* -@ttitle Exception check file presence and permissions
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create one file ;
+2. exception check file presence and permissions;
+3. delete the file;
+4. N/A;
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A;
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs106(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_106", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_107.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_107.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..016d5853719095887313b70ab1bfde6b45e32376
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_107.cpp
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname1, S_IRWXU);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, R_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, X_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_107
+* -@tspec The Function test for access
+* -@ttitle Exception Check directory presence and permissions
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create one directory ;
+2. check directory presence and permissions;
+3. delete the directory;
+4. N/A;
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A;
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs107(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_107", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_116.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_116.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4cb074f32efc392c628f138350e47e170c1b6466
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_116.cpp
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/118.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, 0);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // 10 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir("..");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ close(fd);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_116
+* -@tspec The Function test for open
+* -@ttitle Create a file with permission 0 and open an existing file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a file with permission 0 and open an existing file ;
+2. read and write the file;
+3. delete the file;
+4. N/A
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs116(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_116", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_117.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_117.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..50e0b58842c920274d14dc8696af0998accc23e4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_117.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/119.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRUSR | S_IRGRP | S_IROTH);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // 10 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567890", readbuf, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir("..");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ close(fd);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_117
+* -@tspec The Function test for open
+* -@ttitle Create a file with permission 0x444 and open an existing file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a file with permission 0x444 and open an existing file ;
+2. read and write the file;
+3. delete the file;
+4. N/A
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs117(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_117", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_118.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_118.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f7717b3c004227fe4815b7817141160191299b0c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_118.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/120.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, 0x222);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT2);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // 10 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir("..");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ close(fd);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_118
+* -@tspec The Function test for open
+* -@ttitle Create a file with permission 0x222 and open an existing file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a file with permission 0x222 and open an existing file ;
+2. read and write the file;
+3. delete the file;
+4. N/A
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs118(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_118", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_119.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_119.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e41900282544af926e7884ee252f38d5e0611e91
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_119.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/121.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, 0x111);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // 10 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567890", readbuf, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir("..");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ close(fd);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_119
+* -@tspec The Function test for open
+* -@ttitle Create a file with permission 0x111 and open an existing file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a file with permission 0x111 and open an existing file ;
+2. read and write the file;
+3. delete the file;
+4. N/A
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs119(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_119", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_120.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_120.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f2ca20484f8572be619de5a75e96761d7b43a802
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_120.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/122.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, 0x177);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // 10 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir("..");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ close(fd);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_120
+* -@tspec The Function test for open
+* -@ttitle Create a file with permission 0x177 and open an existing file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a file with permission 0x177 and open an existing file ;
+2. read and write the file;
+3. delete the file;
+4. N/A
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs120(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_120", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_121.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_121.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..47216f59bce236fdc4d469724949045953651de4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_121.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/123.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, 0x277);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // 10 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir("..");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ close(fd);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_121
+* -@tspec The Function test for open
+* -@ttitle Create a file with permission 0x277 and open an existing file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a file with permission 0x277 and open an existing file ;
+2. read and write the file;
+3. delete the file;
+4. N/A
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs121(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_121", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_122.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_122.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e6d7ee761bcdc1de0428f8ec8d2aec59178874d1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_122.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = access(pathname1, F_OK | X_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, F_OK | R_OK | W_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, 10); // 10 means access len
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = access(pathname1, -1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = access(pathname1, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_122
+* -@tspec The API test for access
+* -@ttitle Access parameter (mode) exception test
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a file ;
+2. access parameter (mode) exception test;
+3. delete the file;
+4. N/A
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs122(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_122", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_123.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_123.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..175182c0bd4e90e7510b4ecf6949be85146dd768
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_123.cpp
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_JFFS_123
+* -@tspec The API test for write
+* -@ttitle The length of the write data is 0xffff
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a file ;
+2. the length of the write data is 0xffff;
+3. delete the file;
+4. N/A
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsJffs123(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_123", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_124.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_124.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..63529b5d37e94165dbcb0e84aebf190044f151e2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_124.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufbuf[10] = { 0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1124");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs124(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_124", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_125.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_125.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f55e1dfc58883911833349e401dad71507e1cb10
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_125.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[15] = "0123456789";
+ CHAR readbuf[30] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1125.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, 20); // 20 means write len
+ ICUNIT_GOTO_EQUAL(len, 20, len, EXIT1); // 20 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 25); // 25 means write len
+ ICUNIT_GOTO_EQUAL(len, 20, len, EXIT1); // 20 means write len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs125(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_125", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_126.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_126.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..07b6dad542c0a7da4245eb1be4e331ed9761959f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_126.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "1111111111";
+ CHAR readbuf[20] = "liteosliteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1110");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1); // 10 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteosliteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1111111111os", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs126(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_126", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_127.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_127.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eaff815379b2cfc3bfb0f6338ff1cfdc484ccddd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_127.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "111111111122222";
+ CHAR readbuf[20] = "liteosliteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1111");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteosliteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1111111111os", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs127(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_127", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_128.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_128.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ed04cf83574db8cf8ca5fce17fc8b108e2baa722
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_128.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "1111111111";
+ CHAR readbuf[20] = "liteosliteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1112");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteosliteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 15); // 15 means read len
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1111111111os", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs128(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_128", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_129.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_129.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..712faef4f80d38a840cc479e78f9fb93c5001a27
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_129.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[11] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1113");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs129(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_129", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_130.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_130.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3734b94b7261c18b7bde798aabc0980ee13170e3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_130.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[20] = "liteosliteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1114");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteosliteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 15); // 15 means read len
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcdeos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs130(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_130", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_131.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_131.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..653d053778276b8cb0d67bcb0a129daef5c5f706
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_131.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufbuf[10] = { 0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1115");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 0xffff);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means read len
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs131(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_131", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_132.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_132.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f65f3bf4d22307dd8a5cc25214a1e0b49820b645
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_132.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1122.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, NULL, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs132(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_132", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_133.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_133.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7736992cc13a4d7014053c7027cfe600e0a98f90
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_133.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1123.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs133(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_133", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_134.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_134.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..27e8775bb46af576c2515c461bdd63e66ee5c8d8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_134.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufbuf[10] = { 0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1124");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs134(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_134", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_135.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_135.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a3a8c20d6b3d314747916e31add7fa48e5358fe7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_135.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[15] = "0123456789";
+ CHAR readbuf[30] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1125.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, 20); // 20 means write len
+ ICUNIT_GOTO_EQUAL(len, 20, len, EXIT1); // 20 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 25); // 25 means read len
+ ICUNIT_GOTO_EQUAL(len, 20, len, EXIT1); // 20 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs135(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_135", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_136.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_136.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fa85295f78c90590634f44b4f927e79f14b39dee
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_136.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[25] = "01234567890123456789";
+ CHAR readbuf[25] = "liteosliteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1126.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteosliteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, 15); // 15 means write len
+ ICUNIT_GOTO_EQUAL(len, 15, len, EXIT1); // 15 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 15, len, EXIT1); // 15 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "012345678901234", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs136(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_136", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_137.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_137.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d4ece6aae6b098fe582bf2261ba1986e7d1a2686
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_137.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[20] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1127.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, 10); // 10 means write len
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT1);
+
+ len = read(fd, readbuf, 15); // 15 means read len
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means read len
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs137(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_137", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_138.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_138.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e4e92d22e9ff3c3f8b8ad9cf8e0d97b739e35920
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_138.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1134.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek(fd, -1, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, -1, off, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ off = lseek(fd, -10, SEEK_CUR); // -10 means seek back len
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs138(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_138", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_139.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_139.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b5152e00a80da7b639ade8364b4042c635db3b61
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_139.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1135.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0xffff, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0xffff, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs139(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_139", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_140.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_140.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..99d3b28706f3f616e0f9cd30052846f510b2e36d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_140.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1136.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, len, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, len, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs140(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_140", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_141.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_141.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c6b0c2789ba0ad553ef8eba5eaf78d1d0896f004
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_141.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1137.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, (len + 2), SEEK_SET); // 2 means seek len
+ ICUNIT_GOTO_EQUAL(off, (len + 2), off, EXIT1); // 2 means seek len
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs141(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_141", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_142.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_142.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ca159649f45a5e7a606f2f25e3b65cb7242a07a9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_142.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1138.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, -1, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 9, off, EXIT1); // 9 means current file positon
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "eiteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs142(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_142", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_143.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_143.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cd5dbbe8ee87add3c6abda9c58de407e57095f9a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_143.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1139.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT1); // 10 means current file positon
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs143(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_143", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_144.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_144.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f8bf8158a0c5db51ff269888a3007cf93f4bdd2f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_144.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1140.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0xffff, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 0x10009, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs144(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_144", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_145.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_145.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2d291d0a40d0d043c6c7c66a886663090694bc5a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_145.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1141.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, len, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 0x14, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs145(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_145", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_146.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_146.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..351304f9c50108390e4bb8b99f4097b1f9e2f610
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_146.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1142.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, (len + 2), SEEK_CUR); // 2 means seek len
+ ICUNIT_GOTO_EQUAL(off, (len + len + 2), off, EXIT1); // 2 means seek len
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs146(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_146", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_147.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_147.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..54a3743d44a66d413dd7b7ca4b68e19961956ed8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_147.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1143.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT1); // 10 means current file positon
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs147(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_147", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_148.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_148.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..705628737bad3be691cffa6599f8a808cece1a2f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_148.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1144.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, -1, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 9, off, EXIT1); // 9 means current positon
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT1); // 1 means length of actually read data
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "9iteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs148(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_148", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_149.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_149.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eaaa2d90f9897b03ed1fe20731857288ee3b5add
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_149.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1145.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0xffff, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, (0xffff + 10), off, EXIT1); // 10 means seek len
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs149(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_149", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_150.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_150.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..26976ad3df23da471f112a0632fb214f197ef306
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_150.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1146.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, len, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, (len + len), off, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs150(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_150", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_151.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_151.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..92b87029ec7aa7b692116c4b24576462574b9b44
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_151.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1147.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, (len + 2), SEEK_END); // 2 means seek len
+ ICUNIT_GOTO_EQUAL(off, (len + len + 2), off, EXIT1); // 2 means seek len
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs151(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_151", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_152.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_152.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e7e10a51d94b322be51bf0d401f61adf9970a827
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_152.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1147.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, -1);
+ ICUNIT_GOTO_EQUAL(off, -1, off, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs152(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_152", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_153.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_153.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7a949eb8897493bc11d34fc5fe3de9be8346136a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_153.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1147.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, 0xffff);
+ ICUNIT_GOTO_EQUAL(off, -1, off, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs153(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_153", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_154.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_154.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d588b0432ca02a49ba11dad5d12eed5af5093d1a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_154.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ strcat_s(pathname1, sizeof(pathname1), "1150xt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 10); // 10 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // 10 means write len
+
+ off = lseek(fd, 0, 10); // 10 means seek len
+ ICUNIT_GOTO_EQUAL(off, -1, off, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
+
+ len = read(fd, readbuf, 20); // 20 means read len
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs154(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_154", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_155.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_155.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a989152db9f0ec368a79e781543134e63e7f765c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_155.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = unlink("//");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs155(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_155", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_156.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_156.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9e7428368818500bd7b478535caca7aad8faafc5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_156.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = unlink("/");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs156(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_156", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_157.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_157.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ab77af9f8d7683105215e16c06efb24e8138e7cc
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_157.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = unlink("aaaaa");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs157(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_157", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_158.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_158.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..01d764c85ff74897407e177bfa0639129bfd4cb3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_158.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = unlink("+-/*%^@");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs158(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_158", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_159.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_159.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f9531d9614c8776ba00332ed942f58ce13e887d3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_159.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = unlink("");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs159(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_159", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_160.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_160.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f6340e5124d63e8958f6703a206ba39be07aa782
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_160.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = unlink("..");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EISDIR, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs160(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_160", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_161.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_161.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a58bb29c69bd04d7fd77bcd15f5f592f4712fd11
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_161.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = unlink(".");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs161(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_161", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_162.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_162.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..809c6c11001b9458baada0bdff131086d71e1390
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_162.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = unlink("''");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs162(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_162", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_163.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_163.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d3d2f2b781b74cc0de1986b043da106c65a286b2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_163.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EISDIR, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs163(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_163", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_164.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_164.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6cd6fad9a110f41826f78f12c6eb2d34fb7a1082
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_164.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname2, sizeof(pathname2), "/");
+ strcat_s(pathname2, sizeof(pathname2), pathname3);
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs164(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_164", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_165.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_165.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..43912f3a11824c3b47fba6ca7d47f4e67a7322f5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_165.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs165(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_165", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_166.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_166.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..41a740c0e3a66c5edfafeab8767e4dee14b6b92d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_166.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname2, sizeof(pathname2), "/abc.txt");
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs166(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_166", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_167.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_167.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4a802fdbf8af15144840400f5512659608d13a9d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_167.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open("//", O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT2);
+
+ strcat_s(pathname2, sizeof(pathname2), "//");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+ goto EXIT;
+EXIT1:
+ close(fd);
+ remove(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs167(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_167", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_168.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_168.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0034e6ade70a9870147d5bcf1e03842e0f4b2541
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_168.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open("/", O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT2);
+
+ strcat_s(pathname2, sizeof(pathname2), "/");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+ goto EXIT;
+EXIT1:
+ close(fd);
+ remove(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs168(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_168", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_169.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_169.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9f861f62cb9f6d2ca3cb62b161ee9845acffda15
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_169.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open("aaaaa", O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink("aaaaa");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove("aaaaa");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs169(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_169", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_170.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_170.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..43971180e7247ef8e4704aac0af612f3d78e715d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_170.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open("+-", O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/+-");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(fd);
+ remove(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs170(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_170", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_171.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_171.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cf8ac38faa0fdfed24d3cd3442be91146ec45fd4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_171.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open("", O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/""");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+ goto EXIT;
+EXIT1:
+ close(fd);
+ remove(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs171(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_171", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_172.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_172.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6118c0b39fc488422032ee3fc0c97bef007d5bb9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_172.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open("..", O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/..");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+ goto EXIT;
+EXIT1:
+ close(fd);
+ remove(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs172(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_172", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_173.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_173.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9faa5bc13caa67fd599e306b5f5014d6053c3ef4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_173.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(".", O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = strcat_s(pathname2, sizeof(pathname2), "/.");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+ remove(".");
+ goto EXIT;
+EXIT1:
+ close(fd);
+ remove(pathname2);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs173(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_173", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_174.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_174.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cbf8c53b65fd00108c7df9df54748a486f957683
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_174.cpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 fd3 = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd1 = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ (void)memset_s(pathname4, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ (void)strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/");
+ ret = strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ fd2 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT3);
+
+ ret = strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, pathname4);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT3);
+
+ fd3 = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd3, -1, fd3, EXIT4);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd3);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT4:
+ close(fd3);
+ goto EXIT1;
+EXIT3:
+ close(fd2);
+ goto EXIT1;
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname2, pathname4, strlen(pathname2));
+ remove(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs174(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_174", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_175.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_175.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..73baf8b81177e8aa5f15fc5935dd852bfc377f96
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_175.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open("""", O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT2);
+
+ fd = open("/""""", O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/""""");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+ goto EXIT;
+EXIT1:
+ close(fd);
+ remove(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs175(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_175", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_176.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_176.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..927af1850ff514276873b70ac7fa4a048e80bfbe
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_176.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test_1176.txt");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove(pathname1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs176(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_176", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_177.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_177.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f2ddd455283e611deb8cd93cd28e05bbfb101862
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_177.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove(pathname1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs177(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_177", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_178.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_178.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fc1d5011d099cf94b84d442c943724c155f89943
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_178.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "ABCDE";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1178.txt");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_NOCTTY | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT3);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT3);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567890", readbuf, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd1);
+ goto EXIT1;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs178(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_178", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_179.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_179.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..305d89ceb2bfc71a5809715d4a187f219ff20c31
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_179.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1179.txt");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_SYNC | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT3);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT3);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567890", readbuf, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd1);
+ goto EXIT1;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs179(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_179", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_180.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_180.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1faa5d17be5e21ab181ce105bf1d6dd68e35a6d6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_180.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, sizeof(pathname1), "/1180.txt");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_ASYNC | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT3);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd1);
+ goto EXIT1;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs180(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_180", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_182.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_182.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..17e79cdc1a2d1fe7598dab58ed764b63425b91dd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_182.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, sizeof(pathname1), "/1182.txt");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_NOFOLLOW | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd1);
+ goto EXIT1;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs182(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_182", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_183.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_183.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1b3640b348a1ae2fdeb982e79e60dd32b1a0b364
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_183.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1183.txt");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_DIRECT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd1);
+ goto EXIT1;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs183(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_183", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_184.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_184.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..312efdc025f4bca67f2571913ea971669b37ca96
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_184.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1184.txt");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_NOATIME | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd1);
+ goto EXIT1;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs184(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_184", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_185.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_185.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..511297a6a2f8aac433870857cd8a3d5bdbc56b08
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_185.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, sizeof(pathname1), "/1185.txt");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_CLOEXEC | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd1);
+ goto EXIT1;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs185(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_185", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_187.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_187.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3b2bef77cf39c15e9d3b1dc15bf2eb0c20daa115
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_187.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ off_t off;
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = " ";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1187.txt");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ fd1 = open(pathname1, O_NONBLOCK | (-1) | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd1, -1, fd1, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, ENOTDIR, errno, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd1);
+ goto EXIT1;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs187(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_187", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_188.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_188.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7e3522f2acfc942027729fd534b12c1813161188
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_188.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir("aaaaa", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir("aaaaa");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir("aaaaa");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs188(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_188", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_189.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_189.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e08359c9229bc741ad69eb09fbf54c03aeff04d6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_189.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir("+-/*%^@", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = rmdir("+-/*%^@");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir("+-/*%^@");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs189(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_189", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_190.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_190.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c7c321c6f98a5bf9f8b523699306ea8a3635b944
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_190.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir("", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir("+-/*%^@");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs190(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_190", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_191.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_191.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c6a61c4cc43263075e3057cab7be05e48c2b6328
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_191.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir("..", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EEXIST, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir("..");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs191(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_191", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_192.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_192.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a27475b68ee193060d06526143716a1ea43f8f06
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_192.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir(".", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(".");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs192(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_192", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_193.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_193.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8479df33586a0f6dda165459242f6b369062ec71
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_193.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(pathname3);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs193(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_193", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_194.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_194.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..03251395e6751c8b3586e3b1a6f08efa81f35c2b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_194.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = creat("/", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove("/");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs194(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_194", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_195.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_195.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1727734ec73487c6773463adcf03fd9a506c56d3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_195.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = creat("//", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove("//");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs195(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_195", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_196.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_196.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2e99f6ffaf768a7ecc3dafe9ca129dfebf71f1e9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_196.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = creat("aaaaa", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove("aaaaa");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove("aaaaa");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs196(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_196", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_197.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_197.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dbfb2257a757d2942b636688431d2bc1a679020a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_197.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = creat("+-/*%^@", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove("+-/*%^@");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs197(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_197", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_198.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_198.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3d93e8cca880feb13f3ea6988a3e97abe99809f6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_198.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = creat("", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove("");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs198(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_198", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_199.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_199.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ed3d413ab0732d80858b3966ad02816a95019471
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_199.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = creat("..", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove("..");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs199(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_199", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_200.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_200.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4c259181af5d3a7ed4879c7fafe6e03e7c21258d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_200.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = creat(".", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove(".");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs200(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_200", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_201.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_201.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..561ae7fc1a2790a5ec53464792b9acd1e8312c12
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_201.cpp
@@ -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 "It_vfs_jffs.h"
+
+static const int PARAM_NUM = 2;
+static int Dup2Test(void)
+{
+ int ret = 0;
+ int number1, number2, sum;
+ int savedStdin = -1;
+ int savedStdout = -1;
+
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ (void)strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/input.txt");
+
+ int inputFds = open(pathname, O_CREAT | O_RDWR, S_IRWXU);
+ ICUNIT_GOTO_NOT_EQUAL(inputFds, -1, inputFds, EXIT);
+
+ savedStdin = dup(STDIN_FILENO);
+ savedStdout = dup(STDOUT_FILENO);
+
+ setbuf(stdout, NULL);
+ setbuf(stdin, NULL);
+
+ ret = dup2(inputFds, STDIN_FILENO);
+ ICUNIT_GOTO_EQUAL(ret, STDIN_FILENO, ret, EXIT);
+
+ ret = dup2(inputFds, STDOUT_FILENO);
+ ICUNIT_GOTO_EQUAL(ret, STDOUT_FILENO, ret, EXIT);
+
+ /* STDIN_FILENO STDOUT_FILENO all be directed */
+ printf("1 1\n");
+ lseek(inputFds, 0, SEEK_SET);
+ ret = scanf_s("%d %d", &number1, &number2);
+ ICUNIT_GOTO_EQUAL(ret, PARAM_NUM, ret, EXIT);
+
+ sum = number1 + number2;
+
+EXIT:
+ close(inputFds);
+ dup2(savedStdin, STDIN_FILENO);
+ dup2(savedStdout, STDOUT_FILENO);
+ close(savedStdin);
+ close(savedStdout);
+ unlink(pathname);
+ return sum;
+}
+
+const int DUP_TEST_RET = 2;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = Dup2Test();
+ ICUNIT_GOTO_EQUAL(ret, DUP_TEST_RET, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs201(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_201", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_202.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_202.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2d78caaf609d165e9e91bf58eab18e37566e006c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_202.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = creat("""", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+ remove("""");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs202(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_202", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_203.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_203.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b2197251ec28713c3f9914b7ba17304344d18004
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_203.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir("""", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir("""");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs203(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_203", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_204.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_204.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..12af9ddf01a8e6e0cd1c38a2cefef11b37944aeb
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_204.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd1 = -1;
+ INT32 fd, ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT1);
+
+ fd1 = creat(pathname1, S_IRWXU | S_IRWXG | S_IRWXO); /* pathname1 already open, cannot creat */
+ ICUNIT_GOTO_NOT_EQUAL(fd1, 0, fd1, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs204(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_204", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_205.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_205.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ba6c6bcbd30250b2d3a475f8981dbf853f6f3345
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_205.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = creat(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(fd);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs205(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_205", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_206.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_206.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6804fcac636c81176cf26191efb9bdd03119c071
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_206.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1, ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufbuf[10] = { 0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "1208");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT);
+
+ len = read(fd, NULL, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(fd);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs206(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_206", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_207.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_207.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cc62c293b007d7b8c3e8533295395f2cefe237de
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_207.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname2, sizeof(pathname2), "/aaaaa");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = access(NULL, F_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, EXIT1);
+
+ ret = access(0, F_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, EXIT1);
+
+ ret = access("//", F_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
+
+ ret = access("/", F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
+
+ ret = access("aaaaaa", F_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT1);
+
+ ret = access("+-/*%^@", F_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT1);
+
+ ret = access("", F_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT1);
+
+ ret = access("..", F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = access(".", F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = access("""", F_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs207(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_207", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_208.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_208.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4c879b46ee133143445e64982518ab57f3a724f3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_208.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/jffs_1239.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EEXIST, errno, EXIT);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs208(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_208", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_209.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_209.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4a5d45f82be3631bf07105a0c85c94d1bec1e60a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_209.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static const int DUP_WRONG_FD = 256;
+static const int DUP_WRONG_FD2 = 250;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 pfd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/1127.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ pfd = dup2(CONFIG_NFILE_DESCRIPTORS, fd);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT3);
+
+ pfd = dup2(DUP_WRONG_FD, fd);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT3);
+
+ pfd = dup2(DUP_WRONG_FD2, fd);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT3);
+
+ pfd = dup2(0xffff, fd);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT3);
+
+ pfd = dup2(CONFIG_NFILE_DESCRIPTORS - 1, fd);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT3);
+
+ pfd = dup2(-1, fd);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(pfd);
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname2);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs209(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_209", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_210.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_210.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7d9a3532204283c8a39769f16a430239d081b220
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_210.cpp
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 pfd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/1128.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ pfd = dup2(fd, CONFIG_NFILE_DESCRIPTORS);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT3);
+
+ pfd = dup2(fd, CONFIG_NFILE_DESCRIPTORS);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT3);
+
+ pfd = dup2(fd, CONFIG_NFILE_DESCRIPTORS + 1);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT3);
+
+ pfd = dup2(fd, 0xffff);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT3);
+
+ pfd = dup2(fd, -1);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(pfd);
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname2);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs210(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_210", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_211.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_211.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b208de0fe80610181d802041019b111bd62ee018
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_211.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static const int DUP_FD1 = 256;
+static const int DUP_FD2 = 250;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 pfd = -1;
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ pfd = dup2(CONFIG_NFILE_DESCRIPTORS, CONFIG_NFILE_DESCRIPTORS);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT1);
+
+ pfd = dup2(DUP_FD1, DUP_FD1);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT1);
+ pfd = dup2(DUP_FD2, DUP_FD2);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT1);
+
+ pfd = dup2(0xffff, 0xffff);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT1);
+
+ pfd = dup2(CONFIG_NFILE_DESCRIPTORS - 1, CONFIG_NFILE_DESCRIPTORS - 1);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT1);
+
+ pfd = dup2(-1, -1);
+ ICUNIT_GOTO_EQUAL(pfd, -1, pfd, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(pfd);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs211(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_211", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_212.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_212.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..95e0efc92004dab4eb3754afbc1f0126d13f5a6c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_212.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *pret = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ pret = getcwd(buf, 0);
+ ICUNIT_GOTO_EQUAL(pret, NULL, pret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs212(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_212", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_213.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_213.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4d02da284fe87f4c8a954ebd0b5a3af06fb9c728
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_213.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[0xff + 2] = "";
+ CHAR *pret = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ pret = getcwd(buf, 0xff);
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(buf, pathname1, buf, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs213(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_213", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_214.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_214.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7a97e2c09db0af61f55262571e0451d416a29a2f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_214.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *pret = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ pret = getcwd(buf, 1);
+ ICUNIT_GOTO_EQUAL(pret, NULL, pret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ERANGE, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs214(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_214", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_215.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_215.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..70ad022a647402d601f383a09127456068e57644
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_215.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *pret = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ pret = getcwd(buf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_NOT_EQUAL(pret, NULL, pret, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(buf, JFFS_PATH_NAME0, buf, EXIT);
+
+ pret = getcwd(buf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(pret, NULL, pret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ERANGE, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs215(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_215", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_216.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_216.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bbb0bd59f6c690a42ed116296008b954c59365b1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_216.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[JFFS_STANDARD_NAME_LENGTH];
+ CHAR *pret = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir("//", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir("//");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs216(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_216", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_217.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_217.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6a5dfc6fd3556de3b9eb0d83d1bc35d5e4be9bf7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_217.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buf[JFFS_STANDARD_NAME_LENGTH];
+ CHAR *pret = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir("/", S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir("/");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs217(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_217", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_218.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_218.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2a3a92a0800089614fe16540790e8173f5cca5c6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_218.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/aaaaa");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = remove("aaaaa");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs218(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_218", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_219.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_219.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..88db7bd0357697b1bdf32a122b4f2756b99ab920
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_219.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove("+-/*%^@");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs219(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_219", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_220.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_220.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..670686dc224a20a975dd927292a4220375a2edab
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_220.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove("");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs220(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_220", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_221.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_221.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cba3e4d98785d1b8cb07fa16e422a804791713db
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_221.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove("..");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs221(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_221", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_222.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_222.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d44c1abaf758c0e7cb34fe05f2a7a0550c2431dd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_222.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove(".");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs222(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_222", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_223.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_223.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0611d05db5b92cf824edec9ad7a7db6dfbb4eec9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_223.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+ DIR *dir = NULL;
+ struct statfs buf1 = {0};
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/");
+ ret = strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = remove(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname3);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs223(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_223", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_224.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_224.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4f76cda288a2f5dd631d29baf46a45d5f4f1e738
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_224.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = {0};
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove("""");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs224(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_224", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_225.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_225.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..00d5730ecac8dc59996f6811abcbe60ed52ce888
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_225.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs225(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_225", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_226.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_226.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b2da2d7d932e567115f204b263b60073753425c4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_226.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs226(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_226", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_227.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_227.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..207919cebdf7e42a22de3bb556ef0c4bb2f9ec6e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_227.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/1241");
+ ret = mkdir(pathname2, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs227(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_227", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_228.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_228.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a5bab8bd0bc747235b16a9a077a524de1dfaafd9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_228.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/1242");
+ ret = mkdir(pathname2, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs228(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_228", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_229.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_229.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0d05725049299215449a19122d75d2f4ebaff6ff
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_229.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/1243");
+ ret = mkdir(pathname2, S_IXUSR | S_IXGRP | S_IXOTH);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs229(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_229", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_230.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_230.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0788d60d95124eb40c6998077ab7ccf71fba1eb1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_230.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/1244");
+
+ ret = mkdir(pathname2, S_IWUSR | S_IWGRP | S_IWOTH);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs230(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_230", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_231.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_231.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..523466bbb2733d36220fa14fcab2fc26c2c1b8a4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_231.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (VOID)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/1245");
+
+ ret = mkdir(pathname2, S_IRUSR | S_IRGRP | S_IROTH);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs231(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_231", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_232.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_232.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6fceebd200ab9a77d3a7f50e0b24e7d5b996e8e2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_232.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (VOID)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/1246");
+
+ ret = mkdir(pathname2, S_IXUSR | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs232(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_232", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_233.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_233.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b096a66d8959e4b6ad06d4f41d566b3928378f7a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_233.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (VOID)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = mkdir(pathname1, S_IWUSR | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs233(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_233", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_234.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_234.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f86dfbbba76afd78f129dec64bcf0beb6645340a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_234.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir("//");
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("//");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs234(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_234", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_235.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_235.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..883a923e56a6fb4e557f521ee51cfa0f0f0ab59d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_235.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir("/");
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("/");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs235(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_235", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_236.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_236.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eebaff7e389569871bbac79c3b440b1d8c740540
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_236.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (VOID)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/aaaaa");
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir("aaaaa");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("aaaaa");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs236(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_236", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_237.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_237.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..efa64941597486738579d702bdea0ba55f3bd8e2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_237.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir("+-/*%^@");
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("+-/*%^@");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs237(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_237", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_238.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_238.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..756160d721e52f4d675e5e68703e3de225de1803
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_238.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir("");
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs238(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_238", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_239.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_239.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bd0d63050c5f5dcc566df0986801674585fb7aa0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_239.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir("..");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("..");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs239(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_239", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_240.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_240.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8599862fcfaedb82d092c43c61ca61d8cf3bfdbf
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_240.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(".");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(".");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs240(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_240", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_241.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_241.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9bd647a043065a8313d37dc446f05049c1c44906
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_241.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir("""");
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(""
+ "");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs241(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_241", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_242.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_242.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d19e41ab9b7b239b719790e718c48e8090a03b5f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_242.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (VOID)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOTDIR, errno, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs242(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_242", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_243.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_243.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..78659959108392733f6198d36f824f0ecac51092
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_243.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (VOID)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("/test");
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs243(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_243", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_244.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_244.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..932b09a13bde5fb7dc48e5e3c03814ead60b2286
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_244.cpp
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (VOID)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs244(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_244", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_245.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_245.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a8d3cd461f022d55775c435c4fd72997393936c3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_245.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("//");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("//");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs245(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_245", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_246.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_246.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d71256ab20ad20c557ee1a42df6b29fc110dc7b7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_246.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("/");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs246(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_246", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_247.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_247.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..04b09e4ddf557a0bb87826364b5f18df49b8922d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_247.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/aaaaa");
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir("aaaaa");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir("..");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("aaaaa");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs247(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_247", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_248.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_248.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..75a16d14e348cb3df53be4594201d09fac0f9301
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_248.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("+-/*%^@");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("+-/*%^@");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs248(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_248", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_249.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_249.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3e5efa529ac529b6d9b055926ac23a8ec68f009d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_249.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs249(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_249", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_250.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_250.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..19a401d38a7de9c5e0dde93213167e97573618df
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_250.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("..");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("..");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs250(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_250", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_251.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_251.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7074031bfe493b96c60ab3f22be63865910c2425
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_251.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(".");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(".");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs251(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_251", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_252.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_252.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c2cc1d3ab99db8d0c142439e4223411e98a58ffe
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_252.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/");
+
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir("..");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(pathname3);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs252(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_252", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_253.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_253.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b4507f8fa72f023f9aafd5cd30732c44b3f3368a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_253.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("""");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(""
+ "");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs253(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_253", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_254.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_254.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cc951423bb3e3b61b1d01a3aea3db760bf29ef22
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_254.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove("test");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs254(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_254", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_255.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_255.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..36646599b698cb55651850966d2a986e9d012fdd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_255.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("test");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs255(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_255", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_256.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_256.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7976790ac0c57d552a0f6ddc277efe680a27eb5a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_256.cpp
@@ -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 "It_vfs_jffs.h"
+
+static const int CAT_TIME = 278;
+static const int PATHNAME_LEN = 292;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 i = 0;
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_NAME_LIMITTED_SIZE, "/");
+
+ while (i < CAT_TIME) {
+ (void)strcat_s(pathname1, JFFS_NAME_LIMITTED_SIZE, "t");
+ i++;
+ }
+ ICUNIT_GOTO_EQUAL(strlen(pathname1), PATHNAME_LEN, strlen(pathname1), EXIT);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir("..");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs256(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_256", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_257.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_257.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ba1577ba33e4ee382295233a48bf8881f1d3dd3a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_257.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir("//");
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs257(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_257", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_258.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_258.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..25d06741a76b0ff04bc1105106d38507aef16af1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_258.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir("/");
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs258(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_258", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_259.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_259.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4b53e5a36051170dfe47069373140300b47a17e0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_259.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/aaaaa");
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ dir = opendir("aaaaa");
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir("aaaaa");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ closedir(dir);
+EXIT1:
+ rmdir("aaaaa");
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs259(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_259", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_260.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_260.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b377358a8e4554838555fd10ba83b95a792f34e8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_260.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir("+-/*%^@");
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs260(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_260", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_261.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_261.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c3aa3c1e16016839cea103cbb6ee6712177c1435
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_261.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir("");
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs261(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_261", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_262.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_262.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..611ea13e62fb08903b8bc092072bdbed450a441b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_262.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir("..");
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs262(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_262", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_263.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_263.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f3cf4a4d3f9e0fea24eed31af07f815c68f907c2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_263.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir(".");
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs263(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_263", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_264.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_264.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..104afe8d84c99bc72d2e103b6f5bac09499e6166
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_264.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/");
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ dir = opendir(pathname3);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ closedir(dir);
+EXIT1:
+ rmdir(pathname3);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs264(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_264", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_265.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_265.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3eda74365a6720357db270c4d0328d3372d511ab
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_265.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1287.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT3);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ closedir(dir);
+EXIT2:
+ close(fd);
+EXIT1:
+ rmdir(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs265(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_265", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_266.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_266.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..36b3b9c294895dcfde6f65c42715688f84274e15
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_266.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ closedir(dir);
+EXIT1:
+ rmdir(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs266(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_266", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_267.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_267.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ef770440c61f55a57e6a69e3c21bde035a83ff87
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_267.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static const int CAT_TIME = 280;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 i = 0;
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_NAME_LIMITTED_SIZE, "/test");
+ while (i < CAT_TIME) {
+ i++;
+ (void)strcat_s(pathname1, JFFS_NAME_LIMITTED_SIZE, "t");
+ }
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT2);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ closedir(dir);
+EXIT1:
+ rmdir(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs267(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_267", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_268.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_268.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..27ce5bb0c1af04e1fcc4c73f420aab90c4c677af
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_268.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 i = 0;
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR *dir1 = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ dir1 = dir;
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ptr = readdir(dir1);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs268(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_268", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_269.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_269.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..57637936532981a8fb4d4b1d1ce64e55dfc1160a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_269.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 i = 0;
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR *dir1 = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ dir1 = dir;
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs269(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_269", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_270.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_270.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3fc9d90ec80e3ba954ddbc5f0c1057d146a602dc
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_270.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 i = 0;
+ INT32 fd, ret, len;
+ INT32 offset;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR *dir1 = NULL;
+ struct dirent *ptr = NULL;
+
+ printf("line:%d\n", __LINE__);
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ printf("line:%d\n", __LINE__);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ printf("line:%d\n", __LINE__);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ printf("line:%d\n", __LINE__);
+
+ dir1 = dir;
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ printf("line:%d\n", __LINE__);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ printf("line:%d\n", __LINE__);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs270(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_270", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_271.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_271.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..976f9aa41ffc51bb19a35367654be34307a9d3cd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_271.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 i = 0;
+ INT32 fd, ret, len;
+ INT32 offset;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR *dir1 = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, 0, offset, EXIT2);
+
+ seekdir(dir, 0xffff);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT2);
+
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, 0, offset, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ closedir(dir);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs271(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_271", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_272.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_272.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..40ca15e4295f0029bd0d457ef25f9f67cf084aa8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_272.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 i = 0;
+ INT32 fd, ret, len;
+ INT32 offset;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR *dir1 = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ seekdir(dir, -1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ closedir(dir);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs272(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_272", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_273.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_273.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1b019c164b2cd588566cf9c4f6680d78248d08bb
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_273.cpp
@@ -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 "It_vfs_jffs.h"
+
+static const int SEEK_OFFSET = 10;
+static UINT32 TestCase(VOID)
+{
+ INT32 i = 0;
+ INT32 fd, ret, len;
+ INT32 offset;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR *dir1 = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ seekdir(dir, SEEK_OFFSET);
+
+ dir1 = opendir(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ seekdir(dir, SEEK_OFFSET);
+
+ ptr = readdir(dir1);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ offset = telldir(dir1);
+ ICUNIT_GOTO_EQUAL(offset, 1, offset, EXIT3);
+
+ ret = closedir(dir1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ closedir(dir1);
+EXIT2:
+ closedir(dir);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs273(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_273", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_274.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_274.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1a5c5c520320c20121a1e430db1223b69f7c6af9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_274.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 offset;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR *dir1 = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, 0, offset, EXIT);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs274(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_274", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_275.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_275.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7934c14895ba4d1f8375b7aa505d2fd5a2507ffe
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_275.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir("//", &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs275(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_275", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_276.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_276.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c2c4401b2a230f4ac4faf30677b8870765159103
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_276.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir("/", &namelist, 0, alphasort);
+ ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
+
+ JffsScandirFree(namelist, ret);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs276(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_276", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_277.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_277.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bf7429fca0c5035d08f9a6d90af74379f58dcc4e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_277.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir("+-/*%^@", &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs277(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_277", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_278.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_278.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0a8fa06b8b84d1e32babbe89f3ab522283da9350
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_278.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir("", &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs278(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_278", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_279.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_279.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bc291ee2c80648880945533ed80682809ab9e3f7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_279.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir("..", &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, 1, ret, EXIT1);
+
+ JffsScandirFree(namelist, ret);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs279(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_279", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_280.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_280.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..28074a2fee22bf73a191756912cbc1cb0b626e8e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_280.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ INT32 scandirCount;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ scandirCount = scandir(".", &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 0, scandirCount, EXIT1);
+
+ JffsScandirFree(namelist, scandirCount);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs280(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_280", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_281.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_281.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ef368b3043eff4ba6a9e09d421a5dc0ece7ecdd6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_281.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/aaaaa");
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = scandir("aaaaa", &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsScandirFree(namelist, ret);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ free(namelist);
+EXIT1:
+ remove("aaaaa");
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs281(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_281", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_282.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_282.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cccc31715916b8469638e852a925c33cf97ddaa6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_282.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = scandir(pathname3, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsScandirFree(namelist, ret);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ free(namelist);
+EXIT1:
+ remove(pathname3);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs282(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_282", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_283.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_283.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6de6b3f4f8d3633e93cf0ffa2401d98de0509759
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_283.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir("""", &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs283(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_283", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_284.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_284.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ad3615b59149e85d9be3d32e8c1f500aa6650dfa
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_284.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/1317.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = scandir(pathname2, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ free(namelist);
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs284(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_284", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_285.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_285.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6f14bd3007112baa524d6b02efb08581fa58e0de
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_285.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = scandir(pathname1, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ free(namelist);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs285(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_285", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_286.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_286.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1defe8ec8d958eddbb7cef5f5dd6a1e0bdbfe65e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_286.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir(pathname1, NULL, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ free(namelist);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs286(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_286", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_287.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_287.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..97e25a68072fff2b368e13717ec5a7b7b6438944
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_287.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir(pathname1, 0, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs287(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_287", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_288.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_288.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ba705b7e1ebfaf843b5c1c0579eb71912bc5eef6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_288.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir(pathname1, &namelist, NULL, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsScandirFree(namelist, ret);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs288(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_288", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_289.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_289.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bad4059e71a8dc56161a62dfe4934cbb56e3da29
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_289.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir(pathname1, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsScandirFree(namelist, ret);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs289(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_289", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_290.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_290.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e555bd6b6299150275359db11bfe58ce48464255
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_290.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 ScandirFunc01(const struct dirent *ent)
+{
+ return -1;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir(pathname1, &namelist, ScandirFunc01, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsScandirFree(namelist, ret);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs290(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_290", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_291.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_291.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e8467aea11ddce4954bca1e35585cb7d5e133237
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_291.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 ScandirFunc01(const struct dirent *ent)
+{
+ return 0xffff;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir(pathname1, &namelist, ScandirFunc01, alphasort);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsScandirFree(namelist, ret);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs291(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_291", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_292.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_292.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..998f415be7dec96f95f0a1be0278fdd2f7d60cdd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_292.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir(pathname1, &namelist, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsScandirFree(namelist, ret);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs292(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_292", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_293.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_293.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8b10a679f9889158ed8ce5cd414a4c7157485a53
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_293.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ off_t offset;
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = scandir(pathname1, &namelist, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsScandirFree(namelist, ret);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(namelist);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs293(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_293", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_294.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_294.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..16e49b0eed845a298c62f8729de2b56e986ffaf2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_294.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret, len;
+ struct flock fl = { 0 };
+ CHAR filebuf[10] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1328.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = fcntl(fd, F_GETLK, &fl);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(fl.l_type, 0, fl.l_type, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs294(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_294", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_295.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_295.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b9060f719846be30566645458df4c7c25e2bded9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_295.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat("//", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs295(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_295", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_296.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_296.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..047a290216796c9619ca1eb69746872a6f89f6fb
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_296.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat("/", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs296(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_296", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_297.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_297.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cd8188aec54f1c9edf1bf2a5519d6aa58b14ea50
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_297.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/aaaaa");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = stat("aaaaa", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(buf1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ close(fd);
+EXIT1:
+ remove("aaaaa");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs297(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_297", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_298.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_298.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..62aa84617aacb92f0237cc8051ef59e300ec68a1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_298.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat("+-/*%^@", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs298(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_298", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_299.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_299.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..27a74d68a5a315996e584aadc77fd1874d0bf6ae
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_299.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat("", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs299(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_299", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_300.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_300.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..58d869021a8c8c0e6f7e62c656216227d32b814a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_300.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat("..", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs300(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_300", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_301.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_301.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..42c203ab2974794e8b83ecd47e3515408dee9361
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_301.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat(".", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs301(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_301", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_302.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_302.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8d82f8b85fbff7f119075aa0a6aa5914bcb3d675
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_302.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/");
+ ret = strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = stat(pathname3, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(buf1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname3);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs302(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_302", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_303.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_303.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e4d0abf29a4f26c126db8f362dec5e1a89af7360
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_303.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat("""", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs303(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_303", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_304.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_304.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fcc003fde6cfa68077d336bf83bc8c91796733ba
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_304.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = stat(pathname2, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ JffsStatPrintf(buf1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs304(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_304", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_305.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_305.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7db64b2ab54991d00892e00b55bd77bb93dbd1f9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_305.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test");
+
+ ret = stat(pathname2, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs305(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_305", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_306.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_306.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..36cd2022ebc3093192a0c0f4b4a1b7117c59bd76
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_306.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs306(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_306", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_307.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_307.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d632e6902fc2dc94189a5eb7f5595e8c77bcd5cd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_307.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs307(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_307", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_308.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_308.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8b490fe08d24dd29ac0e7db4c996e430eb9fcd6d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_308.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/jffs_1350.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = fstat(fd, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs308(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_308", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_309.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_309.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..213ca0666a7a2d4729b03eaaf21dbf487217f0e7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_309.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/1351.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs309(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_309", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_310.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_310.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..226451182aa4dda56c2f3924c5db3f48bc11fd53
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_310.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/1352.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs310(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_310", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_311.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_311.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..00bf23368b9dce5b7c5ab234ef10c1567be4a76a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_311.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = statfs("//", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs311(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_311", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_312.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_312.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8b1ed9fe1040c1bd1109c2434725310e912346e2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_312.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = statfs("/", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs312(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_312", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_313.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_313.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..68f105076817a1d25b47f075d64fc607423a3eaf
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_313.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/aaaaa");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = statfs("aaaaa", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ JffsStatfsPrintf(buf1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs313(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_313", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_314.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_314.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c5eb2704e4dac2f9c23e618c599366ab5688a6b8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_314.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = statfs("+-/*%^@", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs314(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_314", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_315.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_315.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..346e5f54ed6b418b67b4f73baf5d70c1954927db
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_315.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = statfs("", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs315(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_315", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_316.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_316.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d8f50019f4fbd5cc31dda9d9ed2ba545f67cba41
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_316.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = statfs("..", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatfsPrintf(buf1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs316(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_316", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_317.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_317.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a2f24bae098fde0fa80755d661dd64774a7f45ad
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_317.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = statfs(".", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatfsPrintf(buf1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs317(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_317", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+
+#ifdef __cpluscplus
+#if __cplusplus
+}
+#endif
+#endif
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_318.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_318.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..df04584df7d9634572589d41835fb9a8208725ef
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_318.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/");
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = statfs(pathname3, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ JffsStatfsPrintf(buf1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs318(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_318", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_319.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_319.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3d8265b00da1072a5af7c9489c91dd861e9178db
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_319.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+
+ ret = statfs("""", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs319(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_319", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_320.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_320.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..370a043266088f05161b6de6f402e9639d8ba6c7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_320.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1364.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ JffsStatfsPrintf(buf1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ JffsStatfsPrintf(buf1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs320(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_320", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_321.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_321.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..aafc723159dace9923020475ac7f1057041b11ed
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_321.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1365.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs321(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_321", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_322.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_322.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..45b2326bb0c4ac7ea6a77a8353b63178b686e27c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_322.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 pfd, ret, len;
+ INT32 flags;
+ CHAR filebuf[10] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1373.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ pfd = fcntl(fd, F_DUPFD, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_NOT_EQUAL(pfd, -1, pfd, EXIT3);
+
+ flags |= O_NONBLOCK | O_RDWR;
+ ret = fcntl(fd, F_SETFL, flags);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = close(pfd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(pfd);
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs322(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_322", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_323.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_323.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d2a6177d3a6899ef7b93ce299399214bccc85dd8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_323.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static const int ILLEGAL_FD = -10;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 flags;
+ CHAR filebuf[10] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1374.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ flags = fcntl(fd, F_DUPFD, ILLEGAL_FD);
+ ICUNIT_GOTO_EQUAL(flags, -1, flags, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT3);
+
+ flags |= O_NONBLOCK | O_RDWR;
+ flags = fcntl(fd, F_SETFL, flags);
+ ICUNIT_GOTO_EQUAL(flags, 0, flags, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(flags);
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs323(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_323", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_324.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_324.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4fc419138b292c720205a6d0856da1695e9d8d31
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_324.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 flags;
+ CHAR filebuf[10] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1375.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ flags = fcntl(fd, F_DUPFD, 0xffff);
+ ICUNIT_GOTO_EQUAL(flags, -1, flags, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ flags |= O_NONBLOCK | O_RDWR;
+ flags = fcntl(fd, F_SETFL, flags);
+ ICUNIT_GOTO_EQUAL(flags, 0, flags, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(flags);
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs324(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_324", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_325.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_325.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..360637e0d9cb778fe70fb5c7cf208cdbd70581a7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_325.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 flags;
+ CHAR filebuf[10] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1376.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ flags = fcntl(fd, F_DUPFD, 0xffff);
+ ICUNIT_GOTO_EQUAL(flags, -1, flags, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ flags |= O_NONBLOCK | O_RDWR;
+ flags = fcntl(fd, F_SETFL, flags);
+ ICUNIT_GOTO_EQUAL(flags, 0, flags, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(flags);
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs325(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_325", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_326.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_326.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6249a04b7b15fbdee4b903ddb152bd4563a63f66
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_326.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 flags;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/495.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ flags = fcntl(fd, F_SETOWN, &fl);
+ ICUNIT_GOTO_EQUAL(flags, -1, flags, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs326(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_326", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_327.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_327.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9556cc9746d6bbfe3c578c437c96cd11e2b64c81
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_327.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 flags;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/496.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ flags = fcntl(fd, 0xffff, &fl);
+ ICUNIT_GOTO_EQUAL(flags, -1, flags, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs327(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_327", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_328.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_328.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8412d6760b27f250cc7d5e81364722b39f2ec125
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_328.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 flags;
+ CHAR filebuf[10] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount("s-s_s-s_s", JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs328(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_328", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_329.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_329.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dd5d7ff017ca64c34e964b97c6cf5540aa8ea142
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_329.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 flags;
+ CHAR filebuf[10] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount("//", JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs329(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_329", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_330.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_330.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..52788b08f0dc7758bd12026dc54e53aa2f39d030
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_330.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 flags;
+ CHAR filebuf[10] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount("/", JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffs330(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_330", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_331.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_331.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5da9b4780b75131a991b148ca520e4346972670f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_331.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR filebuf[301] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij"
+ "9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789"
+ "abcedfghij9876543210abcdeabcde0123456789abcedfghij987654321011111111112222222222";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(filebuf, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs331(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_331", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_332.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_332.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3646c3e71f76de72297470b6043c6484a84f2ecd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_332.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount("+-*%^@", JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs332(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_332", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_333.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_333.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..37e7322675bb9b284b37965c9eae24799c940fe8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_333.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount("", JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs333(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_333", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_334.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_334.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..144d657d6da7eb0229630e907039084bf582e69b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_334.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount("..", JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs334(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_334", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_335.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_335.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f9efe545882f66086e2f9b92e71ff45f6a0b8df4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_335.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(".", JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs335(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_335", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_336.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_336.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fc0d592a89ce28b38acf4a20e2fd869292a24959
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_336.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(pathname3, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ remove(pathname3);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs336(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_336", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_337.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_337.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..06c7b65b04c2248b4443c3f9258d1804acf84c5c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_337.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(pathname1, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs337(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_337", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_338.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_338.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..be25d2141c88637ba0207827a4c7495ce2f73855
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_338.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount("""", JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs338(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_338", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_339.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_339.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1f7eeee0c98ff91693c6c9f6ce6a59d844224c8d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_339.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1388");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(pathname1, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(pathname1, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd);
+EXIT2:
+ remove(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname1);
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs339(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_339", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_340.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_340.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a3b6d6abe0fdbd6664e0a5865504395e737065ab
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_340.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = mount(pathname1, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(pathname1, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs340(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_340", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_342.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_342.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..264afaf4aea8e1a5803330cf4ccc6a4c9caecce4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_342.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, "//", JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ ret = umount("//");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ ret = rmdir("//");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount("//");
+ rmdir("//");
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs342(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_342", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_343.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_343.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d833b7ef96ccdda9844ecdf54e9593e05d459c87
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_343.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, "/", JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = umount("/");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = rmdir("/");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount("/");
+ rmdir("/");
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs343(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_343", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_344.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_344.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..25552d6e637db007cfb3d8dad9c7ba17c67964d1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_344.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR filebuf[302] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij"
+ "9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789"
+ "abcedfghij9876543210abcdeabcde0123456789abcedfghij987654321011111111112222222222";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, filebuf, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = umount(filebuf);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = rmdir(filebuf);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(filebuf);
+ rmdir(filebuf);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs344(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_344", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_346.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_346.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..91feb05e295ca988f16ac9b92d287cfb4eafd8e0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_346.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, "", JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount("");
+ rmdir("");
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs346(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_346", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_352.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_352.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d78b5e7a118bf0ab2e7c19b2bc3483ec52c4f8b9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_352.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, "s-s_s-s_s", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENODEV, errno, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs352(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_352", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_353.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_353.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bd689d7c35f0155e4271e3b8c370c3ec78a57e5a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_353.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, "//", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENODEV, errno, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs353(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_353", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_354.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_354.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..332b52a627128a5b284b4e356ae6218ffde1921f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_354.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, "/", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENODEV, errno, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs354(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_354", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_355.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_355.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..01d9478b232c3a4f28f1b243021b2fbcf67b1e73
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_355.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR filebuf[302] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij"
+ "9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789"
+ "abcedfghij9876543210abcdeabcde0123456789abcedfghij987654321011111111112222222222";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, filebuf, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENODEV, errno, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs355(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_355", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_356.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_356.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5f3e0638951e0bfab1adc252e6fa225c8affdab2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_356.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, "+-/*%^@", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENODEV, errno, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs356(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_356", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_357.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_357.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..534833a39c2a7d59aa7614f0570f86deee144d5c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_357.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, "", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENODEV, errno, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs357(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_357", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_358.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_358.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cbfd03d0ee88a7be6fe374181793ea475f708f2e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_358.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, "..", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENODEV, errno, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs358(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_358", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_359.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_359.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e33c9dc536843303dff809bbf0928dc77191b8bd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_359.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, ".", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENODEV, errno, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs359(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_359", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_360.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_360.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..47d8dd2c8af3912dadc03013bd8dde90cc22d2b7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_360.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, ".", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENODEV, errno, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs360(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_360", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_361.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_361.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5be33aa04d442501326d9b4306f7b19940c7934d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_361.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, """", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENODEV, errno, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs361(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_361", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_362.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_362.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5e828b755b940d7d26921b9114299b984dccf2f6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_362.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_MAIN_DIR0, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENODEV, errno, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs362(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_362", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_364.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_364.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e4cf6ba2d06db751a3c14ede38baf9eb3f28ff11
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_364.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0xffff, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs364(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_364", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_365.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_365.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1fdeb1f3dd8ac897ecab28fe345534231673e796
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_365.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0xffffffff, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ umount(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs365(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_365", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_366.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_366.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..12e667297ac27192d0b532e9367028f586f5c5dc
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_366.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount("s-s_s-s_s");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs366(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_366", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_367.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_367.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b7f3c486d204e449caf16da5643bf59c6a47f171
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_367.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount("//");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs367(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_367", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_368.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_368.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9b7692eb774595f6322d40d4e94d6dafd16c5377
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_368.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount("/");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ printf("%s-%d \n", __FUNCTION__, __LINE__);
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ printf("%s-%d \n", __FUNCTION__, __LINE__);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs368(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_368", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_369.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_369.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..290ff834e9276f114b4bf242c8cebb240a5ecc75
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_369.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR filebuf[302] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij"
+ "9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789"
+ "abcedfghij9876543210abcdeabcde0123456789abcedfghij987654321011111111112222222222";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(filebuf);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs369(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_369", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_370.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_370.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cada2014d96a90af3c0b7641bb46c2009999a9b0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_370.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount("+-/*%^@");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs370(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_370", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_371.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_371.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4571a88230d915d2a85e2fc5eb243fa3f2d9c920
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_371.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount("");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs371(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_371", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_372.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_372.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..61a10278777a7a616fb41a54234f89358bd391db
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_372.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs372(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_372", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_373.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_373.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2697d68ec9718db77f4b2852d5ec76d3175c4463
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_373.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = umount(".");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs373(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_373", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_374.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_374.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fd3cf8e756ae25038f8251fa53899ec29ded8772
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_374.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = umount("""");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs374(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_374", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_375.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_375.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2242bf167d4c1f726ddeb63a5afc88da9b985d8d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_375.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = umount(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs375(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_375", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_376.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_376.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0f31a0d53723cba45f93846af5c1d4633c6b024f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_376.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ (void)strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = umount(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs376(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_376", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_377.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_377.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fa8d8abe2ecaadab894c605b16b0ec667fdd2470
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_377.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename("s-s_s-s_s", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ strcat(pathname1, "/test");
+ ret = rename("s-s_s-s_s", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove("s-s_s-s_s");
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs377(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_377", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_378.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_378.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b1c1ddbad99ed80c6960fa170747b3589aa8d949
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_378.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename("//", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ strcat(pathname1, "/test");
+ ret = rename("//", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove("//");
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs378(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_378", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_379.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_379.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f31fd019811820d18fb655b40222a08ba0a441a4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_379.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename("/", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ strcat(pathname1, "/test");
+ ret = rename("/", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove("/");
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs379(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_379", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_380.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_380.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7a269f6b945dcfa5ec6cf581a7c90f9a248b1a02
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_380.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR filebuf[302] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij"
+ "9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789"
+ "abcedfghij9876543210abcdeabcde0123456789abcedfghij987654321011111111112222222222";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(filebuf, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ strcat(pathname1, "/test");
+ ret = rename(filebuf, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove(filebuf);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs380(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_380", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_381.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_381.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..315cb4b0150fcbde1946ffb42d1f2efd14f8ff8f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_381.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename("+-/*%^@", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ strcat(pathname1, "/test");
+ ret = rename("+-/*%^@", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove("+-/*%^@");
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs381(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_381", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_382.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_382.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a7aa4e75a3047a5ee51e03e18a58f3dd2f451f99
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_382.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename("+-*%^@", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ strcat(pathname1, "/test");
+ ret = rename("+-*%^@", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove("+-*%^@");
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs382(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_382", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_383.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_383.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e8f05fdb58982f3a292158beb68d3d62a7df1242
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_383.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename("", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ strcat(pathname1, "/test");
+ ret = rename("", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove("");
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs383(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_383", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_384.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_384.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6b8cdef390987783cd8e64196501fa474d64e71a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_384.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename("..", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ strcat(pathname1, "/test");
+ ret = rename("..", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ remove(pathname1);
+ goto EXIT;
+EXIT1:
+ remove("..");
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs384(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_384", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_385.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_385.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c81660a2fc2d0fc3610d59fee830be266df17113
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_385.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(".", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ strcat(pathname1, "/test");
+ ret = rename(".", pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBUSY, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ remove(pathname1);
+EXIT1:
+ remove(".");
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs385(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_385", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_386.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_386.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f6628f73dde9faaa1dc96a818f6be631d55ee20b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_386.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(""
+ "",
+ pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ strcat(pathname1, "/test");
+ ret = rename(""
+ "",
+ pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove(""
+ "");
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs386(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_386", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_387.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_387.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d9600a6e3f77f25bb7c81a2148e7f25047a72a63
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_387.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname3, "/1436");
+ ret = rename(pathname3, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rename(pathname3, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = remove(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname3);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs387(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_387", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_388.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_388.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7ce56296efc985c8db66222c13833c55a0eaa43e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_388.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR filebuf[302] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij"
+ "9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789"
+ "abcedfghij9876543210abcdeabcde0123456789abcedfghij987654321011111111112222222222";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(pathname1, filebuf);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(filebuf);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs388(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_388", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_389.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_389.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3c5cbf9b08152c3c733b96f77626a1bdb6b871ce
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_389.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(pathname1, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs389(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_389", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_390.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_390.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a02e0729632b324c40f4939c7b2664b2ff08aa28
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_390.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname3, "/1439");
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rename(pathname1, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = remove(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname3);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs390(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_390", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_391.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_391.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f0ce7d94fe20e4345ca3e22ea89d6457f9df076b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_391.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname3, "/1440");
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rename(pathname1, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = remove(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname3);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs391(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_391", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_392.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_392.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a3bbf3fb815dddebcc8d8c55c209e4a8ef486d0c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_392.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname3, "/1441");
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ strcat(pathname2, "/test1441");
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rename(pathname2, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd);
+EXIT2:
+ remove(pathname2);
+EXIT1:
+ remove(pathname3);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs392(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_392", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_393.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_393.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..29421f15ed856dbe0e0d856a32aa0619becb323c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_393.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname3, "/1442");
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ strcat(pathname2, "/test1442");
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rename(pathname2, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ remove(pathname2);
+EXIT1:
+ remove(pathname3);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs393(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_393", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_394.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_394.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b6612b5fa6052859f1297811c397ea1bb1739b89
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_394.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname3, "/1443");
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ strcat(pathname2, "/test1443");
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rename(pathname3, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ remove(pathname2);
+EXIT1:
+ remove(pathname3);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs394(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_394", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_395.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_395.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..65c6da707ee8bb32b2bed704ce171252217c9285
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_395.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ getcwd(readbuf, 20); // cwd max length 20
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, pathname1, readbuf, EXIT);
+
+ ret = rename(pathname1, "s-s_s-s_s");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = rmdir("s-s_s-s_s");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("s-s_s-s_s");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs395(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_395", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_396.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_396.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d7911420c94b37d15e969a01a650b4bf5c895351
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_396.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(pathname1, "//");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = rmdir("//");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("//");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs396(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_396", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_397.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_397.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d26c22e3413f231d8d8b50ab6bcbc14c1db431bf
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_397.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(pathname1, "/");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = rmdir("/");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("/");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs397(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_397", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_398.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_398.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3ac89a1f582024a1be058062d6cadc404037bcd4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_398.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR filebuf[302] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij"
+ "9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789"
+ "abcedfghij9876543210abcdeabcde0123456789abcedfghij987654321011111111112222222222";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(pathname1, filebuf);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = rmdir(filebuf);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(filebuf);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs398(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_398", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_399.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_399.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..58372fef861ba9e8c8fd31b0da2472ca6072ad5d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_399.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(pathname1, "+-/*%^@");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = rmdir("+-/*%^@");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("+-/*%^@");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs399(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_399", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_400.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_400.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eb0a8e9dd5e780836c48208388ebedaf50fc0e98
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_400.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(pathname1, "");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = rmdir("");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs400(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_400", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_401.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_401.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f346a06a619ed44d09eaba6d5185a48b7a3b88c1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_401.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(pathname1, "..");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = rmdir("..");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove("..");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs401(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_401", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_402.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_402.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0c456db3e7246dc5030f277b2ad4735801651dbe
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_402.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(pathname1, ".");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = rmdir(".");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(".");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs402(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_402", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_403.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_403.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8370f4c9283c8b53babe6520d70b72d56ef88c98
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_403.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rename(pathname1, ""
+ "");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = rmdir(""
+ "");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(""
+ "");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs403(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_403", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_404.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_404.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..909f60438855e4016b79adacf91b44a44e0ec7ba
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_404.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct utimbuf utime1;
+ struct stat buf1, buf2, buf3;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = utime("s-s_s-s_s", NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_UTIME_SUPPORT, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat("s-s_s-s_s", &buf2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+ JffsStatPrintf(buf2);
+
+ sleep(2); // wait 2s
+
+ ret = utime("s-s_s-s_s", NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_UTIME_SUPPORT, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs404(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_404", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_405.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_405.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..008dab46ca38c034f6a971c7a0a91a0e3c5576f5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_405.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct utimbuf utime1;
+ struct stat buf1, buf2, buf3;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = utime("//", NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat("//", &buf2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+ JffsStatPrintf(buf2);
+
+ sleep(2); // wait 2s
+
+ ret = utime("//", NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs405(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_405", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_406.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_406.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3e280818b3923a7e7743a206a5dd5d7a1e5d755d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_406.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct utimbuf utime1;
+ struct stat buf1, buf2, buf3;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = utime("/", NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat("/", &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ sleep(2); // wait 2s
+
+ ret = utime("/", NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs406(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_406", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_407.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_407.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1734b166c8666a30922f59ea60037ec52a98b6e2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_407.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct utimbuf utime1;
+ struct stat buf1, buf2, buf3;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = utime("", NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat("", &buf2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+ JffsStatPrintf(buf2);
+
+ sleep(2); // wait 2s
+
+ ret = utime("", NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs407(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_407", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_408.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_408.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..897a0dfd4c7eed6db1cb3fd58e0116c5b9b7e5ee
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_408.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct utimbuf utime1;
+ struct stat buf1, buf2, buf3;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = utime("..", NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat("..", &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ sleep(2); // wait 2s
+
+ ret = utime("..", NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs408(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_408", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_409.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_409.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ab99dc46378140d0364a50e97866af0dd6b21ef6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_409.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct utimbuf utime1;
+ struct stat buf1, buf2, buf3;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ sleep(2); // wait 2s
+
+ ret = utime(".", NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ sleep(2); // wait 2s
+
+ ret = utime(".", NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs409(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_409", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_410.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_410.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3b4aa4ade011d3e6c1fe1a40a59bdedfd39ae874
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_410.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct utimbuf utime1;
+ struct stat buf1, buf2, buf3;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ sleep(2); // wait 2s
+
+ ret = utime(""
+ "",
+ NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = stat(""
+ "",
+ &buf2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+ JffsStatPrintf(buf2);
+
+ sleep(2); // wait 2s
+
+ ret = utime(""
+ "",
+ NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs410(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_410", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_411.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_411.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2fc8eef76a68bf206d21f5b213a92a384d295c5c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_411.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct stat buf1, buf2;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = utime(pathname1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_UTIME_SUPPORT, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ sleep(2); // wait 2s
+
+ ret = utime(pathname1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_UTIME_SUPPORT, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs411(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_411", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_412.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_412.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a6ae0f382a5857557864a36779b1e6341f585d4e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_412.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct utimbuf utime1;
+ time_t ttime1;
+ struct tm tm1;
+ struct stat buf1, buf2;
+
+ tm1.tm_year = 90; // test number 90 for year
+ tm1.tm_mon = 1; // test number 1 for mon
+ tm1.tm_mday = 1; // test number 1 for mday
+ tm1.tm_hour = 12; // test number 12 for hour
+ tm1.tm_min = 12; // test number 12 for min
+ tm1.tm_sec = 12; // test number 12 for sec
+ ttime1 = mktime(&tm1);
+ utime1.actime = ttime1;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = utime(pathname1, &utime1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_UTIME_SUPPORT, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs412(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_412", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_413.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_413.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4aba508e7ac97e2cf20c049e1f51f6a44d024f73
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_413.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct stat buf1, buf2;
+ struct utimbuf utime1;
+ time_t ttime1;
+ struct tm ttm1;
+
+ ttm1.tm_year = 90; // random test year 90
+ ttm1.tm_mon = 0; // random test mon 0
+ ttm1.tm_mday = 1; // random test mday 1
+ ttm1.tm_hour = 12; // random test hour 12
+ ttm1.tm_min = 12; // random test min 12
+ ttm1.tm_sec = 12; // random test sec 12
+ ttm1.tm_isdst = 0;
+ ttime1 = mktime(&ttm1);
+ utime1.modtime = ttime1;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname1, "/1463");
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ JffsStatPrintf(buf1);
+
+ ret = utime(pathname1, &utime1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_UTIME_SUPPORT, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ JffsStatPrintf(buf1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd1);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs413(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_413", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_414.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_414.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..66293604c46dd7de34785d094fa83313861e65b1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_414.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct utimbuf utime1;
+ struct stat buf1, buf2, buf3;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname1, "/1464");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ JffsStatPrintf(buf1);
+
+ ret = utime(pathname1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_UTIME_SUPPORT, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ sleep(2); // wait 2s
+
+ ret = utime(pathname1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_UTIME_SUPPORT, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ JffsStatPrintf(buf2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = utime(pathname1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_UTIME_SUPPORT, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ JffsStatPrintf(buf3);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs414(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_414", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_415.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_415.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8d65e4d2fc0ddf44c710ab484e7e89617c4b76a7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_415.cpp
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1465_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1465_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1465_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd3, -1, fd3, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1465_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1465_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1465_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd3, -1, fd3, EXIT6);
+
+ len = read(fd3, bufW3, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 20, len, EXIT6); // compare ret len with target len 20
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1465_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1465_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1465_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1465_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1465_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1465_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs415(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_415", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_416.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_416.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3a84fd927df92ef37d38216c353bf40e1a899830
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_416.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1472_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1472_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1472_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1472_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1472_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = 0;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = 0;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 0, lenV, EXIT6);
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1472_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1472_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1472_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1472_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1472_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1472_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs416(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_416", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_417.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_417.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1c8e2560b8e2c0d95a1d677ba0cf4ab58761e7cb
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_417.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1473_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1473_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1473_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1473_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1473_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH + 1;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH + 1;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 2 * (JFFS_SHORT_ARRAY_LENGTH + 1), lenV, EXIT6);
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1473_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1473_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1473_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1473_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1473_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1473_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs417(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_417", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_418.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_418.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f715046a265a7bdd09cb888b2e835b01be24993c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_418.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1474_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1474_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1474_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1474_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1474_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH + 1;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH + 1;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 2 * (JFFS_SHORT_ARRAY_LENGTH + 1), lenV, EXIT6);
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1474_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1474_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1474_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1474_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1474_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1474_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs418(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_418", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_419.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_419.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a1be828c7865ed3bc67a09013e5042f7a2fe4597
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_419.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1475_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1475_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1475_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1475_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1475_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH - 1;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH - 1;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 2 * (JFFS_SHORT_ARRAY_LENGTH - 1), lenV, EXIT6);
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1475_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1475_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1475_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1475_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1475_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1475_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs419(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_419", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_420.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_420.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b31e171382cc3508846ddfa86696c901e5f54e3a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_420.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1476_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1476_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1476_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1476_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1476_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, -1);
+ ICUNIT_GOTO_EQUAL(lenV, -1, lenV, EXIT6);
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1476_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1476_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1476_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1476_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1476_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1476_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs420(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_420", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_421.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_421.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..39258b97c4717f3c1bd5339e4a7d1373d766c2c3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_421.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1477_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1477_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1477_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1477_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1477_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 1);
+ ICUNIT_GOTO_EQUAL(lenV, 10, lenV, EXIT6); // compare ret lenV to target 10 lenV
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1477_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1477_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1477_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1477_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1477_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1477_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs421(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_421", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_422.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_422.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..aa6ce0b11642477899da9ea318d25d2a4e6ac0ca
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_422.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1478_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1478_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1478_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1478_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1478_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 0);
+ ICUNIT_GOTO_EQUAL(lenV, -1, lenV, EXIT6);
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1478_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1478_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1478_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1478_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1478_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1478_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs422(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_422", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_423.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_423.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..51fe628e983ae683a3647e6189b18ba0d779bec6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_423.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1479_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1479_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1479_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1479_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1479_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 3); // writes 3 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1479_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1479_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1479_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1479_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1479_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1479_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs423(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_423", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_424.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_424.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0802fd32046d844c2d1b732236ba2fe3efe1e274
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_424.cpp
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1480_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1480_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1480_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1480_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1480_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ off = lseek(fd3, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ lenV = readv(fd3, g_jffsIov, 2); // reads 2 buffers from the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1480_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname1, "/1480_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1480_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1480_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1480_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1480_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs424(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_424", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_425.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_425.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8bca7a88b5f4a53207153ca42785ccf62a63537f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_425.cpp
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1481_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1481_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1481_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd3, -1, fd3, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1481_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1481_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ off = lseek(fd3, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = readv(fd3, g_jffsIov, 3); // reads 3 buffers from the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1481_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname1, "/1481_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1481_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1481_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1481_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1481_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs425(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_425", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_426.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_426.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..239a4ead0f2dd6c82255192d0af868bb7b1aaed8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_426.cpp
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1488_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1488_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1488_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd3, -1, fd3, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1488_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1488_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ off = lseek(fd3, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = 0;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = 0;
+
+ lenV = readv(fd3, g_jffsIov, 2); // reads 2 buffers from the fd
+ ICUNIT_GOTO_EQUAL(lenV, 0, lenV, EXIT6);
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1488_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname1, "/1488_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1488_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1488_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1488_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1488_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs426(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_426", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_427.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_427.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a36d242fd521e4cbd60f34f413d60033a78edcdb
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_427.cpp
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1489_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1489_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1489_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd3, -1, fd3, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1489_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1489_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ off = lseek(fd3, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = 0xffff;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = 0xffff;
+
+ lenV = readv(fd3, g_jffsIov, 2); // reads 2 buffers from the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1489_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname1, "/1489_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1489_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1489_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1489_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1489_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs427(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_427", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_428.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_428.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..32b6faa520c564e1bd169ef178180f21d0f34780
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_428.cpp
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1490_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1490_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1490_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd3, -1, fd3, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1490_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1490_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ off = lseek(fd3, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH + 2; // set length to JFFS_SHORT_ARRAY_LENGTH + 2
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH + 2; // set length to JFFS_SHORT_ARRAY_LENGTH + 2
+
+ lenV = readv(fd3, g_jffsIov, 2); // reads 2 buffers from the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1490_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname1, "/1490_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1490_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1490_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1490_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1490_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs428(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_428", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_429.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_429.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f7163e358dc95c7d44941009944a1fc671078d21
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_429.cpp
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1491_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1491_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1491_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd3, -1, fd3, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1491_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1491_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ off = lseek(fd3, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH - 1;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH - 1;
+
+ lenV = readv(fd3, g_jffsIov, 2); // reads 2 buffers from the fd
+ ICUNIT_GOTO_EQUAL(lenV, 2 * (JFFS_SHORT_ARRAY_LENGTH - 1), lenV, EXIT6);
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1491_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname1, "/1491_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1491_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1491_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1491_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1491_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs429(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_429", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_430.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_430.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..35d57a4a9c261d40f0e510d66653a18abb3274bc
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_430.cpp
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1492_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1492_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1492_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd3, -1, fd3, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1492_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1492_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ off = lseek(fd3, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = readv(fd3, g_jffsIov, -1);
+ ICUNIT_GOTO_EQUAL(lenV, -1, lenV, EXIT6);
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1492_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname1, "/1492_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1492_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1492_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1492_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1492_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs430(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_430", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_431.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_431.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..abdbabfa305829b792bfd094254033fd26184cc2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_431.cpp
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1493_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1493_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1493_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd3, -1, fd3, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1493_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1493_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ off = lseek(fd3, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = readv(fd3, g_jffsIov, 1);
+ ICUNIT_GOTO_EQUAL(lenV, 10, lenV, EXIT6); // compare ret lenV to target 10 lenV
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1493_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname1, "/1493_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1493_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1493_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1493_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1493_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs431(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_431", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_432.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_432.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2f350944cb8cb2210809a7bd1ee1c0418dc71e9a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_432.cpp
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd1, fd2, fd3;
+ INT32 ret, len;
+ INT32 flags;
+ ssize_t lenV = 0;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufW1[JFFS_SHORT_ARRAY_LENGTH + 1] = "0123456789";
+ CHAR bufW2[JFFS_SHORT_ARRAY_LENGTH + 1] = "abcefghijk";
+ CHAR bufW3[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/1494_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT2);
+
+ JffsStrcat2(pathname1, "/1494_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ JffsStrcat2(pathname1, "/1494_3", JFFS_STANDARD_NAME_LENGTH);
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd3, -1, fd3, EXIT6);
+
+ len = write(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = write(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1494_1", JFFS_STANDARD_NAME_LENGTH);
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ JffsStrcat2(pathname1, "/1494_2", JFFS_STANDARD_NAME_LENGTH);
+ fd2 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT6);
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ len = read(fd1, bufW1, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ len = read(fd2, bufW2, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT6); // compare ret len with target len 10
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = writev(fd3, g_jffsIov, 2); // writes 2 buffers to the fd
+ ICUNIT_GOTO_EQUAL(lenV, 20, lenV, EXIT6); // compare ret lenV to target 20 lenV
+
+ memset(bufW1, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+ memset(bufW2, 0, JFFS_SHORT_ARRAY_LENGTH + 1);
+
+ off = lseek(fd3, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT6);
+
+ g_jffsIov[0].iov_base = bufW1;
+ g_jffsIov[0].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+ g_jffsIov[1].iov_base = bufW2;
+ g_jffsIov[1].iov_len = JFFS_SHORT_ARRAY_LENGTH;
+
+ lenV = readv(fd3, g_jffsIov, 0);
+ ICUNIT_GOTO_EQUAL(lenV, -1, lenV, EXIT6);
+
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ JffsStrcat2(pathname1, "/1494_3", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname1, "/1494_2", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname1, "/1494_1", JFFS_STANDARD_NAME_LENGTH);
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT6:
+ close(fd3);
+EXIT5:
+ JffsStrcat2(pathname1, "/1494_3", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/1494_2", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT2:
+ close(fd1);
+EXIT1:
+ JffsStrcat2(pathname1, "/1494_1", JFFS_STANDARD_NAME_LENGTH);
+ remove(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs432(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_432", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_433.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_433.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d9f3e4424753a6c7c1e1634b67496a350e5b2265
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_433.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "/dev";
+ struct stat buf1, buf2;
+ struct utimbuf utime1;
+ time_t ttime1;
+ struct tm ttm1;
+
+ ttm1.tm_year = 90; // random test year 90
+ ttm1.tm_mon = 0; // random test mon 0
+ ttm1.tm_mday = 1; // random test mday 1
+ ttm1.tm_hour = 12; // random test hour 12
+ ttm1.tm_min = 12; // random test min 12
+ ttm1.tm_sec = 12; // random test sec 12
+ ttm1.tm_isdst = 0;
+ ttime1 = mktime(&ttm1);
+ utime1.modtime = ttime1;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(pathname2, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = utime(pathname2, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname2, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ sleep(2); // wait 2s
+
+ ret = utime(pathname2, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT);
+
+ ret = stat(pathname2, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs433(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_433", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_434.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_434.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0839be5e27f66cb1ab8d6333f7b80c9981c27481
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_434.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rename(NULL, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ strcat(pathname1, "/test");
+ ret = rename(NULL, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs434(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_434", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_435.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_435.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fbcf1be8b22d248e98ba77a2c19cad317f1f0a6e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_435.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ INT32 flags;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rename(pathname1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs435(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_435", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_454.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_454.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..25d2d3603fce25f8067212a4f9ca9daad893334e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_454.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/589.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = ioctl(fd, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs454(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_454", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_455.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_455.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fd9d148d4afbc39540275cf08a7504582331ade7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_455.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/590.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs455(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_455", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_456.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_456.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ee77adb1218d34155a55fd0d04d8a7295c6f8812
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_456.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/591.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 1, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs456(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_456", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_457.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_457.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0ca9c9ce036c7018ad2ccb14904190a0fb33f845
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_457.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/591.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 0xffff, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs457(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_457", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_458.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_458.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e84abd4fa4645d7ab7feaf478784322504b048fa
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_458.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/591.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, -1, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs458(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_458", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_459.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_459.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ce14620a13c4f20f1e2a9d3de72f14cad4b835ad
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_459.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/594.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 10, 0); // ioctl request 10 to the fd
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs459(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_459", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_460.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_460.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..877137903faca56eefbe2fa4fddc90ca9a5e9b71
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_460.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/595.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 0, 1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs460(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_460", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_461.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_461.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5bac61b8f631adb0cd211392f14778fd136bbb21
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_461.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/596.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 0, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs461(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_461", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_462.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_462.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..73b0d76ec33ed69e83ee240d843a4f2306a1750b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_462.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/603.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = isatty(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = isatty(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs462(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_462", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_487.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_487.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8ff00789229a34bdc74d68c3672eea9059620293
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_487.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = fsync(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = fsync(fd);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs487(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_487", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_488.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_488.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9fc22401142a60dc41308747e664b7a1ecffb387
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_488.cpp
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pread(fd, readbuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ len = pread(fd, readbuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pread64(fd, readbuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ len = pread64(fd, readbuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs488(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_488", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_489.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_489.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cb964c35de356b5648a9aae1b13910bca02816b1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_489.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pread(fd, NULL, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pread64(fd, NULL, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs489(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_489", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_490.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_490.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9fc1b4602eee9270dbb84967fc7d3d688b1c0d12
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_490.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 0, 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 0, 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs490(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_490", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_491.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_491.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ce6f64a457c39b9794c6f4f8a4b703350de785e7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_491.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs491(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_491", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_492.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_492.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c41ad8ffd43de283f79215f51a50785737fe216d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_492.cpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len, i;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *writebuf = NULL;
+ CHAR *readbuf = NULL;
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ writebuf = (CHAR *)malloc(0xffff + 2); // malloc 0xffff + 2 bytes buffer
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT2);
+ memset(writebuf, 0, 0xffff + 2); // memset 0xffff + 2 bytes
+
+ for (i = 0; i < 256; i++) { // generate 256 * 260 bytes writebuf
+ strcat(writebuf, filebuf);
+ }
+ writebuf[0xffff] = '\0';
+
+ readbuf = (CHAR *)malloc(0xffff + 1);
+ ICUNIT_GOTO_NOT_EQUAL(readbuf, NULL, readbuf, EXIT3);
+ memset(readbuf, 0, 0xffff + 1);
+
+ len = write(fd, writebuf, 0xffff);
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT4);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 0xffff, 0);
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT4);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 0xffff, off, EXIT4);
+
+ free(readbuf);
+ free(writebuf);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ writebuf = (CHAR *)malloc(0xffff + 2); // malloc 0xffff + 2 bytes buffer
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT2);
+ memset(writebuf, 0, 0xffff + 2); // memset 0xffff + 2 bytes
+
+ for (i = 0; i < 256; i++) { // generate 256 * 260 bytes writebuf
+ strcat(writebuf, filebuf);
+ }
+ writebuf[0xffff] = '\0';
+
+ readbuf = (CHAR *)malloc(0xffff + 1);
+ ICUNIT_GOTO_NOT_EQUAL(readbuf, NULL, readbuf, EXIT3);
+ memset(readbuf, 0, 0xffff + 1);
+
+ len = write(fd, writebuf, 0xffff);
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT4);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 0xffff, 0);
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT4);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 0xffff, off, EXIT4);
+
+ free(readbuf);
+ free(writebuf);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT4:
+ free(readbuf);
+EXIT3:
+ free(writebuf);
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs492(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_492", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_493.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_493.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cf82ff0187dceacb52ece595ba451dedf1f97418
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_493.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[10] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 10); // memset 10 bytes
+ len = pread(fd, readbuf, 9, 1); // read 9 bytes from fd at offset 1
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 10); // memset 10 bytes
+ len = pread64(fd, readbuf, 9, 1); // read 9 bytes from fd at offset 1
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs493(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_493", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_494.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_494.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6b4720ffd99e10b4d41674dcd95137f98d843a2f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_494.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[11] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 10); // memset 10 bytes
+ len = pread(fd, readbuf, 10, 0); // read 10 bytes from fd at offset 0
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 10); // memset 10 bytes
+ len = pread64(fd, readbuf, 10, 0); // read 10 bytes from fd at offset 0
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs494(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_494", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_495.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_495.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9db1dbf3f6be88f1d7721cc55d93ee3a2aed9ce2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_495.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[5] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 5); // memset 5 bytes
+ len = pread(fd, readbuf, 6, 0); // read 6 bytes from fd at offset 0
+ dprintf("len=:%d,readbuf=:%s\n", len, readbuf);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 5); // memset 5 bytes
+ len = pread64(fd, readbuf, 6, 0); // read 6 bytes from fd at offset 0
+ dprintf("len=:%d,readbuf=:%s\n", len, readbuf);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs495(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_495", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_496.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_496.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cc11d7b8d2f68d0fe1e9541eb917a2f7cabc37c3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_496.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, 1); // read 10 bytes from fd at offset 1
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "234567890", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, 1); // read 10 bytes from fd at offset 1
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "234567890", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs496(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_496", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_497.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_497.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b7b32ba643173580595206e419684a0122e81cba
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_497.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, 0xffff); // read 10 bytes from fd at offset 0xffff
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, 0xffff); // read 10 bytes from fd at offset 0xffff
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs497(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_497", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_498.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_498.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..244230899461c7c474355021350039d91f8c5034
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_498.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, 10 + 1); // read 10 bytes from fd at offset 10 + 1 = 11
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, 10 + 1); // read 10 bytes from fd at offset 10 + 1 = 11
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs498(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_498", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_499.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_499.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ab5fc1e7c1f17da0f2499618e9db02d5c55b074c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_499.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, 10); // read 10 bytes from fd at offset 10
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, 10); // read 10 bytes from fd at offset 10
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs499(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_499", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_500.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_500.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..af0f4cbca5c9610a533263013012d73365855acf
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_500.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, strlen(writebuf) - 1); // read 10 bytes from fd at offset strlen(writebuf) - 1
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, strlen(writebuf) - 1); // read 10 bytes from fd at offset strlen(writebuf) - 1
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs500(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_500", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_501.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_501.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5d087171235a470ab084deebe16edf0b94c4a723
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_501.cpp
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, -1); // read 10 bytes from fd at offset -1
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, -1); // read 10 bytes from fd at offset -1
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs501(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_501", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_502.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_502.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8099fc35b2dbfb71bc26d05920dca019df264af6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_502.cpp
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pwrite(fd, writebuf, 10, 0); // write 10 bytes from fd at offset 0
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ len = pwrite(fd, writebuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pwrite64(fd, writebuf, 10, 0); // write 10 bytes from fd at offset 0
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ len = pwrite64(fd, writebuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs502(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_502", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_503.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_503.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..40daec1608a3167f3119ae06eeb29b1524a7c4e6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_503.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pwrite(fd, NULL, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pwrite64(fd, NULL, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs503(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_503", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_504.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_504.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a9c58d57acfd46c88d72169d5df3948147e83620
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_504.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ len = pwrite(fd, writebuf, 0, 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ ret = read(fd, readbuf, 10); // read 10 bytes to buffer
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ len = pwrite64(fd, writebuf, 0, 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ ret = read(fd, readbuf, 10); // read 10 bytes to buffer
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs504(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_504", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_505.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_505.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c1e21748a48a8d77b1b56be96107f4d3de9b8a33
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_505.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ len = pwrite(fd, writebuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ len = pwrite64(fd, writebuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs505(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_505", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_506.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_506.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1a7df68b5db4765861f67a4866648346ac396b59
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_506.cpp
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len, i;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *writebuf = NULL;
+ CHAR *readbuf = NULL;
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ writebuf = (CHAR *)malloc(0xffff + 2); // malloc 0xffff + 2 bytes buffer
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT2);
+ memset(writebuf, 0, 0xffff + 2); // memset 0xffff + 2 bytes
+
+ for (i = 0; i < 256; i++) { // generate 256 * 260 bytes writebuf
+ strcat(writebuf, filebuf);
+ }
+ writebuf[0xffff] = '\0';
+
+ readbuf = (CHAR *)malloc(0xffff + 1);
+ ICUNIT_GOTO_NOT_EQUAL(readbuf, NULL, readbuf, EXIT3);
+ memset(readbuf, 0, 0xffff + 1);
+
+ len = pwrite(fd, writebuf, 0xffff, 0);
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT4);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT4);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 0xffff);
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT4);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT4);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 0xffff, off, EXIT4);
+
+ free(readbuf);
+ free(writebuf);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ writebuf = (CHAR *)malloc(0xffff + 2); // malloc 0xffff + 2 bytes buffer
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT2);
+ memset(writebuf, 0, 0xffff + 2); // memset 0xffff + 2 bytes
+
+ for (i = 0; i < 256; i++) { // generate 256 * 260 bytes writebuf
+ strcat(writebuf, filebuf);
+ }
+ writebuf[0xffff] = '\0';
+
+ readbuf = (CHAR *)malloc(0xffff + 1);
+ ICUNIT_GOTO_NOT_EQUAL(readbuf, NULL, readbuf, EXIT3);
+ memset(readbuf, 0, 0xffff + 1);
+
+ len = pwrite64(fd, writebuf, 0xffff, 0);
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT4);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT4);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 0xffff);
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT4);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT4);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 0xffff, off, EXIT4);
+
+ free(readbuf);
+ free(writebuf);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT4:
+ free(readbuf);
+EXIT3:
+ free(writebuf);
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs506(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_506", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_507.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_507.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6e474d9aebfaa9b8325a9f74d94549665538cf9f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_507.cpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, filebuf, strlen(filebuf) - 1, 0);
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 10); // read buffer len 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "lalalalal0", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, filebuf, strlen(filebuf) - 1, 0);
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 10); // read buffer len 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "lalalalal0", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs507(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_507", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_508.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_508.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c1b26679c1f5fc23c6d4269d2b5c8b3a7c9c064e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_508.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, JFFS_STANDARD_NAME_LENGTH, 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, 20, len, EXIT2); // compare ret len with target len 20
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, JFFS_STANDARD_NAME_LENGTH, 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, 20, len, EXIT2); // compare ret len with target len 20
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs508(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_508", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_509.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_509.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5bbd37d2290239d2059a753b76851204d8b4e40a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_509.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, JFFS_STANDARD_NAME_LENGTH + 1, 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH + 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 25); // read buffer len 25
+ ICUNIT_GOTO_EQUAL(len, 25, len, EXIT2); // compare ret len with target len 25
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, JFFS_STANDARD_NAME_LENGTH + 1, 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH + 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 25); // read buffer len 25
+ ICUNIT_GOTO_EQUAL(len, 25, len, EXIT2); // compare ret len with target len 25
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs509(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_509", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_510.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_510.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f75c0b756bcefaaade5fe6458dce9b1d4a04b0a9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_510.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 1, off, EXIT2);
+
+ len = pwrite(fd, writebuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 1, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 10); // read buffer len 10
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 1, off, EXIT2);
+
+ len = pwrite64(fd, writebuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 1, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 10); // read buffer len 10
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs510(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_510", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_511.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_511.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cf9485f75df9aec2010c3e1f5742e7232eec4f5a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_511.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, strlen(writebuf), 0xffff);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0xffff - 1, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0xffff - 1, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + 1, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, strlen(writebuf), 0xffff);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0xffff - 1, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0xffff - 1, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + 1, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs511(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_511", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_512.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_512.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..57d618fd347ef58d7541bf5f29e1a4995c73b9ef
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_512.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, 10, off + 1); // write 10 bytes from fd at offset off + 1
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf) + 1, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, 10, off + 1); // write 10 bytes from fd at offset off + 1
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf) + 1, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs512(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_512", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_513.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_513.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7d2a5425ee00056dc68f62f04eca5c34910d042a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_513.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, 10, off); // write 10 bytes from fd at offset off
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf), len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "12345678901234567890", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, 10, off); // write 10 bytes from fd at offset off
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf), len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "12345678901234567890", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs513(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_513", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_514.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_514.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c07141707e62389a557152d268d4c04c92ab9d04
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_514.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, 10, off - 1); // write 10 bytes from fd at offset off - 1
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf) - 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567891234567890", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, 10, off - 1); // write 10 bytes from fd at offset off - 1
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf) - 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567891234567890", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs514(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_514", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_515.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_515.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..30e5d3f9655c1d3f0522c119163111e87774ce5f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_515.cpp
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, 10, -1); // write 10 bytes from fd at offset -1
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, 10, -1); // write 10 bytes from fd at offset -1
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs515(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_515", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_516.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_516.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a931be66d14f138eccd0b2373b687c107a9d0f8e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_516.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs516(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_516", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_517.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_517.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..03c0ec4e8fd173c87642a72fe6c63063f2f40d22
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_517.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs517(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_517", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_518.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_518.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..59f48e02be726d253f2e337121b4ba8b6cee9d9c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_518.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove("//");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs518(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_518", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_519.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_519.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c9c25439a2e7c2c12bd0f333431f254e77068a6a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_519.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove("/");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs519(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_519", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_520.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_520.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b4dd25767a36b542a044574a785ec0e48e250cfc
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_520.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *realName = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ realName = realpath(pathname2, NULL);
+ ICUNIT_GOTO_NOT_EQUAL(realName, JFFS_TO_NULL, realName, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(realName, pathname2, realName, EXIT1);
+ free(realName);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ free(realName);
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+* -@test IT_FS_JFFS_520
+* -@tspec The API test for realpath
+* -@ttitle The API test for realpath with NULL for the second parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. mkdir a directory in the mount dir;
+2. use the function realpath to get the full-path;
+3. rmdir the directory;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ */
+
+VOID ItFsJffs520(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_520", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_521.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_521.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..61593a7d3fb1b5227417a360f5dd698c41ca3909
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_521.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *realName = NULL;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ realName = realpath(pathname1, bufname);
+ ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ realName = realpath(pathname1, bufname);
+ ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ close(fd);
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+* -@test IT_FS_JFFS_521
+* -@tspec The Function test for realpath
+* -@ttitle Get the realpath about the file;
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a file;
+2. use the function realpath to get the full-path;
+3. rmdir the directory;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ */
+
+VOID ItFsJffs521(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_521", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_522.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_522.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..67f34191a786f5fc80a6778b1c143fd2f5bf9d65
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_522.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *realName = NULL;
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ realName = realpath(pathname1, bufname);
+ ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ realName = realpath(pathname1, bufname);
+ ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+* -@test IT_FS_JFFS_522
+* -@tspec The Function test for realpath
+* -@ttitle Get the realpath about the directory;
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a directory;
+2. use the function realpath to get the full-path;
+3. rmdir the directory;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ */
+
+VOID ItFsJffs522(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_522", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_523.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_523.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bcce4f6ad021934e3ecfd35a023c533029d056fa
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_523.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *realName = NULL;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ realName = realpath(pathname1, bufname);
+ ICUNIT_GOTO_EQUAL(realName, NULL, realName, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ close(fd);
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+* -@test IT_FS_JFFS_523
+* -@tspec The Function test for realpath
+* -@ttitle Get the realpath about the file which has removed;
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a directory;
+2. use the function realpath to get the full-path;
+3. rmdir the directory;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ */
+
+VOID ItFsJffs523(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_523", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_524.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_524.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..43b53ce6c5d695378179385d5153b5ed707dad8f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_524.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *realName = NULL;
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ realName = realpath(pathname1, bufname);
+ ICUNIT_GOTO_EQUAL(realName, NULL, realName, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+* -@test IT_FS_JFFS_524
+* -@tspec The Function test for realpath
+* -@ttitle Get the realpath about the directory which has removed;
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a directory;
+2. use the function realpath to get the full-path;
+3. rmdir the directory;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ */
+
+VOID ItFsJffs524(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_524", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_526.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_526.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c0b048554a2bb1fb5eaa184c99c74476c59b96cd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_526.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *realName = NULL;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ realName = realpath(pathname1, bufname);
+ ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT);
+ printf("%s-%d \n", __FUNCTION__, __LINE__);
+
+ strcat(pathname2, "/////");
+ strcat(pathname2, "test");
+
+ realName = realpath(pathname2, bufname);
+ ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+* -@test IT_FS_JFFS_526
+* -@tspec The Function test for realpath
+* -@ttitle Get the realpath about the directory which contains many connection symbols;
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a directory;
+2. use the function realpath to get the full-path;
+3. rmdir the directory;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ */
+
+VOID ItFsJffs526(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_526", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_528.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_528.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d6f6b3f025ae27495a4d5fa75d93f3a2ff639ab5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_528.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(VOID *argument)
+{
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *realName = NULL;
+
+ g_TestCnt++;
+
+ realName = realpath(pathname1, bufname);
+ ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT);
+
+ g_TestCnt++;
+
+ return NULL;
+
+EXIT:
+ g_TestCnt++;
+ return NULL;
+}
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_t newTh1;
+ pthread_attr_t attr;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+
+ PosixPthreadInit(&attr, 4); // init pthread with attr 4
+
+ ret = pthread_create(&newTh1, &attr, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ while (g_TestCnt < 2) { // wait for test count 2 complete
+ sleep(1);
+ }
+
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 2, g_TestCnt, EXIT2); // compare g_TestCnt to 2
+
+ ret = PosixPthreadDestroy(&attr, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = remove(pathname1);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ PosixPthreadDestroy(&attr, newTh1);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+/*
+* -@test IT_FS_JFFS_528
+* -@tspec The Function test for realpath
+* -@ttitle Get the realpath about the directory in another task;
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a directory;
+2. use the function realpath to get the full-path in another task;
+3. N/A;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Sucessful operation
+3. N/A
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ */
+
+VOID ItFsJffs528(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_528", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_529.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_529.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a9c3fff85fe48a9b711630767389720abda14a09
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_529.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret, fd;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR *realName = NULL;
+ BOOL bool1 = 0;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ realName = realpath(".", bufname);
+ ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+* -@test IT_FS_JFFS_616
+* -@tspec The Function test for realpath
+* -@ttitle Get the realpath about the directory which was deleted;
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a directory;
+2. delete the directory;
+3. use the function realpath to get the full-pathN/A;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ */
+
+VOID ItFsJffs529(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_529", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_530.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_530.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c06a3db9b6c87e611700b5ea693ffc65131b6dad
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_530.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 i = 0;
+ INT32 ret;
+ INT32 fd;
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_MAIN_DIR0 };
+ CHAR bufname[JFFS_NAME_LIMITTED_SIZE] = "";
+ CHAR *realName = NULL;
+ BOOL bool1 = 0;
+
+ strcat(pathname1, "/");
+
+ // PATH_MAX test. The dirname has occupied 9 bytes.
+ while (i < 246) { // generate 246 length name
+ i++;
+ strcat(pathname1, "t");
+ }
+ ICUNIT_GOTO_EQUAL(strlen(pathname1), 255, strlen(pathname1), EXIT); // compare pathname lenth with 255
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ realName = realpath(pathname1, bufname);
+ ICUNIT_GOTO_NOT_EQUAL(realName, NULL, realName, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(realName, pathname1, realName, EXIT);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ close(fd);
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+* -@test IT_FS_JFFS_616
+* -@tspec The Function test for realpath
+* -@ttitle Get the realpath about the directory which is multi-level directory;
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a directory;
+2. use the function realpath to get the full-path in another task;
+3. N/A;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Sucessful operation
+3. N/A
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ */
+
+VOID ItFsJffs530(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_530", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_531.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_531.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..49a80b0e27721896062193c1264291a14bf3be00
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_531.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 flags;
+
+ fd = open(pathname, O_CREAT | O_RDONLY | O_EXCL | O_APPEND, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ flags = fcntl(fd, F_GETFL, 0);
+ ICUNIT_GOTO_EQUAL(flags & O_ACCMODE, O_RDONLY, flags & O_ACCMODE, EXIT1);
+ ICUNIT_GOTO_EQUAL(flags & O_APPEND, O_APPEND, flags & O_APPEND, EXIT1);
+ ICUNIT_GOTO_NOT_EQUAL(flags & O_NONBLOCK, O_NONBLOCK, flags & O_NONBLOCK, EXIT1);
+
+ flags |= O_NONBLOCK | O_RDWR;
+ flags = fcntl(fd, F_SETFL, flags);
+ ICUNIT_GOTO_EQUAL(flags, 0, flags, EXIT1);
+
+ len = read(fd, readbuf, 50); // read buffer len 50
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ flags = fcntl(fd, F_GETFL, 0);
+ ICUNIT_GOTO_EQUAL(flags & O_APPEND, O_APPEND, flags & O_APPEND, EXIT1);
+ ICUNIT_GOTO_EQUAL(flags & O_NONBLOCK, O_NONBLOCK, flags & O_NONBLOCK, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs531(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_531", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_532.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_532.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1d344dd6cdfcac8142a60a0abf03c052625774d3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_532.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 flags;
+
+ fd = open(pathname, O_CREAT | O_RDONLY | O_EXCL | O_APPEND, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ flags = fcntl(fd, F_GETFL, 0);
+ ICUNIT_GOTO_EQUAL(flags & O_ACCMODE, O_RDONLY, flags & O_ACCMODE, EXIT1);
+ ICUNIT_GOTO_EQUAL(flags & O_APPEND, O_APPEND, flags & O_APPEND, EXIT1);
+ ICUNIT_GOTO_NOT_EQUAL(flags & O_NONBLOCK, O_NONBLOCK, flags & O_NONBLOCK, EXIT1);
+
+ flags |= O_NONBLOCK | O_RDWR;
+ flags = fcntl(fd, F_SETFL, flags);
+ ICUNIT_GOTO_EQUAL(flags, 0, flags, EXIT1);
+
+ len = read(fd, readbuf, 50); // read buffer len 50
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ flags = fcntl(fd, F_GETFL, 0);
+ ICUNIT_GOTO_EQUAL(flags & O_APPEND, O_APPEND, flags & O_APPEND, EXIT1);
+ ICUNIT_GOTO_EQUAL(flags & O_NONBLOCK, O_NONBLOCK, flags & O_NONBLOCK, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs532(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_532", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_533.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_533.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4369c7ce472b9e8c67cf0b8c4fa58ced04b3e99e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_533.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ struct flock fl = { 0 };
+ CHAR filebuf[10] = "good";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = fcntl(fd, F_GETLK, &fl);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 4, len, EXIT1); // compare ret len with target len 4
+
+ fl.l_type = F_UNLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 10; // star from 10
+ fl.l_len = 10; // length 10
+ ret = fcntl(fd, F_SETLK, &fl);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = fcntl(fd, F_GETLK, &fl);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 4, len, EXIT1); // compare ret len with target len 4
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs533(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_533", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_534.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_534.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..92fdc335cad77afb358a9a0d0861c404eb65b3b5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_534.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ struct flock fl = { 0 };
+ CHAR filebuf[10] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 4, len, EXIT1); // compare ret len with target len 4
+
+ ret = fcntl(fd, F_GETLK, &fl);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 10; // star from 10
+ fl.l_len = 10; // length 10
+
+ if (fcntl(fd, F_SETLK, &fl) == -1) {
+ if (errno == EACCES || errno == EAGAIN || errno == ENOSYS) {
+ ICUNIT_GOTO_EQUAL(1, 1, errno, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(1, 0, errno, EXIT1);
+ }
+ }
+
+ len = read(fd, readbuf, 50); // read buffer len 50
+
+ fl.l_type = F_UNLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 10; // star from 10
+ fl.l_len = 10; // length 10
+ ret = fcntl(fd, F_SETLK, &fl);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = fcntl(fd, F_GETLK, &fl);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ len = read(fd, readbuf, 50); // read buffer len 50
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs534(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_534", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_541.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_541.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..70e33a05cf4c7273a3bf45426e08e5276527b41c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_541.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1134.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, -1, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_IS_ERROR, off, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ off = lseek64(fd, -10, SEEK_CUR); // seek -10 from current pos
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs541(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_541", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_542.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_542.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9b24a5aae8587dd7be969464b3432ec924c507c5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_542.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1135.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, 0xffff, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0xffff, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs542(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_542", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_543.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_543.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4e290310376523d63fbe440561ee4ae55aeeecd8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_543.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1136.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, len, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, len, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs543(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_543", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_544.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_544.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bd92bd391055db70423a1509e516375475d97c5a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_544.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1137.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, (len + 2), SEEK_SET); // seek to len + 2
+ ICUNIT_GOTO_EQUAL(off, (len + 2), off, EXIT1); // compare ret off to target len + 2 off
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs544(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_544", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_545.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_545.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fbdb2356000dbfdf03b36541d59ffbae59d700d0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_545.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1138.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, -1, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 9, off, EXIT1); // compare ret off with target off 9
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "eiteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs545(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_545", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_546.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_546.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1ddb3d5cb39f1419e6d6762561e47f646fc025a5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_546.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1139.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, JFFS_SHORT_ARRAY_LENGTH, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs546(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_546", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_547.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_547.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7eb746c1434b46b459153ef601f11929701d535a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_547.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1140.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, 0xffff, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 0x10009, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs547(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_547", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_548.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_548.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7d93cd0787e1965ce2934773bf6aa65ecc536f55
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_548.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1141.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, len, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 0x14, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs548(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_548", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_549.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_549.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..660d41d443fab17be6af4678610a72fecf286985
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_549.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "637.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, (len + 2), SEEK_CUR); // seek len + 2 from current pos
+ ICUNIT_GOTO_EQUAL(off, (len + len + 2), off, EXIT1); // compare ret off to target len + len + 2 off
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs549(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_549", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_550.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_550.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..202b33b84ac0aff8f697f1e7fcb7c94007f80d55
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_550.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1143.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, JFFS_SHORT_ARRAY_LENGTH, off, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs550(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_550", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_551.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_551.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bee29690bf79c1c9aed774d38b5ff9deaa58162a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_551.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1144.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, -1, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 9, off, EXIT1); // compare ret off with target off 9
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "9iteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs551(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_551", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_552.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_552.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..194f7f38443316cec28b80dfd3dd6da7dae00909
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_552.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1145.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, 0xffff, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, (0xffff + JFFS_SHORT_ARRAY_LENGTH), off, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs552(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_552", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_553.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_553.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..66868f3f0e1ca8bf988d362c8d43e67d527f97bf
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_553.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1146.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, len, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, (len + len), off, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs553(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_553", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_554.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_554.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..29fe4223a98af67853fb1b037a8a804e8abd4d76
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_554.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1147.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, (len + 2), SEEK_END); // seek to len + 2 from file end
+ ICUNIT_GOTO_EQUAL(off, (len + len + 2), off, EXIT1); // compare ret off to target len + len + 2 off
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs554(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_554", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_555.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_555.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..584eaac38903f89dc225ba6b30896eddc9cca9e2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_555.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1147.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, 0, -1);
+ ICUNIT_GOTO_EQUAL(off, JFFS_IS_ERROR, off, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs555(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_555", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_556.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_556.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7fab5bf0057a00e17cb514572b0d2e6b97e72f7e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_556.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1147.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, 0, 0xffff);
+ ICUNIT_GOTO_EQUAL(off, JFFS_IS_ERROR, off, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs556(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_556", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_557.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_557.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..95067eb45e7ccfe8c591e97af8ac6e773d14a32e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_557.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, fd1, ret, len;
+ CHAR filebuf[12] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off64_t off;
+
+ strcat(pathname1, "1147.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ off = lseek64(fd, 0, JFFS_SHORT_ARRAY_LENGTH);
+ ICUNIT_GOTO_EQUAL(off, JFFS_IS_ERROR, off, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
+
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs557(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_557", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_560.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_560.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e031c54f47e4249366358d85897f7e637a5f3ba0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_560.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/aaaaa");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = stat64("aaaaa", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ close(fd);
+EXIT1:
+ remove("aaaaa");
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs560(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_560", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_562.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_562.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8f4eba97966fd6819eb9a13d21318879aa13aed8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_562.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat64("", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs562(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_562", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_563.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_563.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c822a78dd91c53cf1a18e9a2f1b9852fa32a19b2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_563.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat64("..", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs563(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_563", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_564.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_564.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..301b8e788e31c5856b3d02043f3bf55b16743790
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_564.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat64(".", &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs564(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_564", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_565.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_565.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4fca7116ddb7bd6ac7f5bcea991fa916afb7ba2e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_565.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_CHINESE_NAME1 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/");
+ strcat(pathname2, pathname3);
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = stat64(pathname3, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname3);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs565(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_565", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_566.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_566.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..86e69651fc3b94363f006d079d52b8cb0b084fd9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_566.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat64(""
+ "",
+ &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs566(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_566", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_567.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_567.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..13c82c5dbbb6e0c895a4ecaa193ebc47aa92c75b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_567.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat64(pathname2, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs567(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_567", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_568.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_568.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..755f5f0fa94d6e737b66847ea79fd67356a8a567
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_568.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+
+ ret = stat64(pathname2, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs568(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_568", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_569.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_569.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..25c4fcc631af6e2902849bd2704230ead335838c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_569.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs569(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_569", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_570.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_570.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1d90fb842e62c5d4efb7dc88964d465f597cd575
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_570.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs570(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_570", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_571.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_571.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..04b541d0cda85bf3b34b3e564fde1fd730e2c445
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_571.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/jffs_1350.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = fstat64(fd, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs571(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_571", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_572.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_572.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bdcb506a2abdd8b5156e21f6caaf5ddcb2624317
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_572.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/1351.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs572(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_572", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_573.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_573.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c87f6298c7ba60ac9e89c4a3e125d29badf20afd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_573.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct stat64 buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/1352.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs573(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_573", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_574.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_574.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..853f5e9a13b647cbcb2bd611ab334390cbbaf47a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_574.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd;
+ INT32 ret = 0;
+ INT32 len = 0;
+ INT32 size = 0xffff;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *writebuf = NULL;
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ struct statfs buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct stat buf3 = { 0 };
+ off_t off;
+
+ writebuf = (CHAR *)malloc(size);
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT);
+ memset(writebuf, 0x61, size);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(buf3);
+
+ ret = fallocate(fd, 1, 0, size + JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf3.st_size, size, buf3.st_size, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ free(writebuf);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ free(writebuf);
+ return JFFS_NO_ERROR;
+}
+
+/*
+* -@test IT_FS_JFFS_574
+* -@tspec The function test for fallocate
+* -@ttitle Fallocate allocates space while the offset + length is more than the size of the file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one non-empty file;
+2. use the function fallocate to allocates space while the offset + length is more than the size of the file ;
+3. compare the file size before and after fallocate;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ */
+
+VOID ItFsJffs574(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_574", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_583.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_583.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..03026fea69b8ce5ec664bebdd291bb0893c9b769
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_583.cpp
@@ -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.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ int ret, i;
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ umount(JFFS_MAIN_DIR0);
+ for (i = 0; i < 30; i++) { // test 30 times
+ printf("%s-%d umount/mount: %d\n", __FUNCTION__, __LINE__, i);
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, MS_RDONLY, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ umount(JFFS_MAIN_DIR0);
+EXIT:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs583(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_583", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_584.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_584.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..45fa7f1898a604a7f41c19df9e6147c64aeb5a4b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_584.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ int ret, i;
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ umount(JFFS_MAIN_DIR0);
+ for (i = 0; i < 30; i++) { // test 30 times
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, MS_RDONLY, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ umount(JFFS_MAIN_DIR0);
+EXIT:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs584(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_584", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_586.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_586.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fb2fa4fefacb5b742df106c05064f5a574aa401b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_586.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd;
+ INT32 ret = 0;
+ INT32 i = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ ret = ftruncate(fd, 50); // truncate fd to 50 bytes
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+* -@test IT_FS_JFFS_586
+* -@tspec The function test for truncate
+* -@ttitle Truncate recover space for the same file fd multiple times
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one file;
+2. use the function truncate to recover the space for the same file fd multiple times;
+3. close and remove the file;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ */
+
+VOID ItFsJffs586(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_586", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_589.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_589.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cc882f4092dc4da2c38a595b22206d57b67612ce
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_589.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/589.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = ioctl(fd, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs589(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_589", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_590.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_590.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..78dd163cd978d070066796b3d666e4137d0997f0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_590.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/590.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, -ENOSYS, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs590(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_590", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_591.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_591.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a73e16cd7c29efd909d34c4cf67b80ef08589eda
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_591.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/591.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 1, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs591(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_591", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_592.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_592.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7c144ae2828da0d1255fabae9a375389e9b12f8a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_592.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/591.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 0xffff, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs592(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_592", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_593.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_593.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d7e9096d23235f2b033bb1b1ad8965efa933f261
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_593.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/591.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, -1, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs593(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_593", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_594.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_594.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..719a68013567bf998691228bc017f27d58f23604
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_594.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/594.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 10, 0); // ioctl request 10 to the fd
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs594(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_594", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_595.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_595.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..416e697cf73e76f6eea6ca8b1963df853a3e9fbd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_595.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/595.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 0, 1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs595(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_595", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_596.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_596.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4c5daf011ed20ecad6c548e50f0becb35befe9b4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_596.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/596.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = ioctl(fd, 0, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs596(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_596", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_603.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_603.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4561705c8e4b6878b886486a480589d190ea3678
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_603.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[JFFS_SHORT_ARRAY_LENGTH] = "good";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct flock fl = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/603.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = isatty(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = isatty(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ remove(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs603(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_603", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_636.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_636.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..149f528aee7d12287cb908a99afee5b34f73d02f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_636.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = fsync(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = fsync(fd);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs636(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_636", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_643.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_643.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f9bf593e06f82eaa149795cd8623b0cb53359cf2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_643.cpp
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pread(fd, readbuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ len = pread(fd, readbuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pread64(fd, readbuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ len = pread64(fd, readbuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs643(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_643", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_644.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_644.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fea95c639c53c64ac271f036c05d8097f7bb3a63
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_644.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pread(fd, NULL, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pread64(fd, NULL, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs644(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_644", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_645.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_645.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..be6df92ed2581922ea772a2547816d6b6cd821e7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_645.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 0, 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 0, 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs645(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_645", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_646.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_646.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..57e73f3a5b90e908dd4bdc410509b2f78a3a91f2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_646.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs646(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_646", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_648.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_648.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9e5c9fb718323e42831ae104a34471b7fa6c85a2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_648.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[10] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 10); // memset 10 bytes
+ len = pread(fd, readbuf, 9, 1); // read 9 bytes from fd at offset 1
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 10); // memset 10 bytes
+ len = pread64(fd, readbuf, 9, 1); // read 9 bytes from fd at offset 1
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs648(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_648", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_649.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_649.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..001573ea5de015e12e0640c6c88e94ca3b5f9dc7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_649.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[11] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 10); // memset 10 bytes
+ len = pread(fd, readbuf, 10, 0); // read 10 bytes from fd at offset 0
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 10); // memset 10 bytes
+ len = pread64(fd, readbuf, 10, 0); // read 10 bytes from fd at offset 0
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs649(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_649", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_650.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_650.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..55c48b9c782030454daab9e56034ad45a68264ea
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_650.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[5] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 5); // memset 5 bytes
+ len = pread(fd, readbuf, 6, 0); // read 6 bytes from fd at offset 0
+ dprintf("len=:%d,readbuf=:%s\n", len, readbuf);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, 5); // memset 5 bytes
+ len = pread64(fd, readbuf, 6, 0); // read 6 bytes from fd at offset 0
+ dprintf("len=:%d,readbuf=:%s\n", len, readbuf);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs650(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_650", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_651.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_651.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5b125abbdb927395cf89ee3826d09d96db178c80
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_651.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, 1); // read 10 bytes from fd at offset 1
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "234567890", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, 1); // read 10 bytes from fd at offset 1
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "234567890", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs651(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_651", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_652.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_652.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0fce90117b7c31cb8650184c27d1bc3ce8610349
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_652.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, 0xffff); // read 10 bytes from fd at offset 0xffff
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, 0xffff); // read 10 bytes from fd at offset 0xffff
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs652(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_652", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_653.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_653.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..673b447e6ad67f329c08645b4e922f4ab53af368
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_653.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, 10 + 1); // read 10 bytes from fd at offset 10 + 1 = 11
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, 10 + 1); // read 10 bytes from fd at offset 10 + 1 = 11
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs653(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_653", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_654.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_654.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8b10a16b53d36a48042d2bff2cd22395c40340ce
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_654.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, 10); // read 10 bytes from fd at offset 10
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, 10); // read 10 bytes from fd at offset 10
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs654(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_654", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_655.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_655.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..51ed5996e79ee50cb3073e72186d89973439e740
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_655.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, strlen(writebuf) - 1); // read 10 bytes from fd at offset strlen(writebuf) - 1
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, strlen(writebuf) - 1); // read 10 bytes from fd at offset strlen(writebuf) - 1
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0", readbuf, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs655(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_655", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_656.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_656.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f32eb61b88b09a3c5c585f373db59df6118a91ac
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_656.cpp
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread(fd, readbuf, 10, -1); // read 10 bytes from fd at offset -1
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = pread64(fd, readbuf, 10, -1); // read 10 bytes from fd at offset -1
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "", readbuf, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs656(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_656", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_663.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_663.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..04297cb3eb6027e279cabd3942e2d68918e9606d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_663.cpp
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pwrite(fd, writebuf, 10, 0); // write 10 bytes from fd at offset 0
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ len = pwrite(fd, writebuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pwrite64(fd, writebuf, 10, 0); // write 10 bytes from fd at offset 0
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ len = pwrite64(fd, writebuf, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs663(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_663", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_664.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_664.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..54682c627cac480f1b8253119b107d05371d6903
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_664.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pwrite(fd, NULL, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = pwrite64(fd, NULL, 0, 0);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs664(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_664", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_665.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_665.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..856846496fbbaf0b353912bcfd69d4a7fd29161e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_665.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ len = pwrite(fd, writebuf, 0, 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ ret = read(fd, readbuf, 10); // read 10 bytes to buffer
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ len = pwrite64(fd, writebuf, 0, 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ ret = read(fd, readbuf, 10); // read 10 bytes to buffer
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs665(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_665", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_666.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_666.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..efb82fee813825f9be85b1e3d120d61ec84ad7a1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_666.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ len = pwrite(fd, writebuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ len = pwrite64(fd, writebuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs666(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_666", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_668.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_668.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c963779e5797502b55a6cd2a9e60eecb97c85b5f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_668.cpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "lalalalala";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, filebuf, strlen(filebuf) - 1, 0);
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 10); // read buffer len 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "lalalalal0", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, filebuf, strlen(filebuf) - 1, 0);
+ ICUNIT_GOTO_EQUAL(len, 9, len, EXIT2); // compare ret len with target len 9
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 10); // read buffer len 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "lalalalal0", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs668(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_668", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_669.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_669.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f0a00fe65cfc2a8e501f8cdf70276b53d625b71c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_669.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, JFFS_STANDARD_NAME_LENGTH, 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, 20, len, EXIT2); // compare ret len with target len 20
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, JFFS_STANDARD_NAME_LENGTH, 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 20); // read buffer len 20
+ ICUNIT_GOTO_EQUAL(len, 20, len, EXIT2); // compare ret len with target len 20
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs669(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_669", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_670.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_670.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a710b4210bd81405e6d4e2a69560af44cb52f635
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_670.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, JFFS_STANDARD_NAME_LENGTH + 1, 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH + 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 25); // read buffer len 25
+ ICUNIT_GOTO_EQUAL(len, 25, len, EXIT2); // compare ret len with target len 25
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, JFFS_STANDARD_NAME_LENGTH + 1, 0);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH + 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 25); // read buffer len 25
+ ICUNIT_GOTO_EQUAL(len, 25, len, EXIT2); // compare ret len with target len 25
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs670(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_670", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_671.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_671.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d3819d50c3a3a0834b92d9fcc7bbec0f50abeb40
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_671.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 1, off, EXIT2);
+
+ len = pwrite(fd, writebuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 1, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 10); // read buffer len 10
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 1, off, EXIT2);
+
+ len = pwrite64(fd, writebuf, 1, 1);
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 1, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 10); // read buffer len 10
+ ICUNIT_GOTO_EQUAL(len, 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs671(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_671", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_672.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_672.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eb041fd063b799bb3558dce4e65a824afbd93bd8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_672.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, strlen(writebuf), 0xffff);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0xffff - 1, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0xffff - 1, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + 1, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, strlen(writebuf), 0xffff);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0xffff - 1, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0xffff - 1, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + 1, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs672(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_672", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_673.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_673.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a987a76fc225816b3b5fa5a935d5660cd4050abd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_673.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, 10, off + 1); // write 10 bytes from fd at offset off + 1
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf) + 1, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, 10, off + 1); // write 10 bytes from fd at offset off + 1
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf) + 1, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs673(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_673", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_674.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_674.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..91a6cbc866051bc5d47f57a65e85f6bd671dae81
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_674.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, 10, off); // write 10 bytes from fd at offset off
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf), len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "12345678901234567890", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, 10, off); // write 10 bytes from fd at offset off
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf), len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "12345678901234567890", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs674(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_674", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_675.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_675.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8c10a59b9164693eeeca0e4ec9fc249f162f5d40
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_675.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, 10, off - 1); // write 10 bytes from fd at offset off - 1
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf) - 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567891234567890", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, 10, off - 1); // write 10 bytes from fd at offset off - 1
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf) + strlen(writebuf) - 1, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567891234567890", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs675(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_675", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_676.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_676.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b05e2e0cb42dac7b436988f629d90955b0ef5355
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_676.cpp
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek64(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite(fd, writebuf, 10, -1); // write 10 bytes from fd at offset -1
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ off = lseek64(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcpy(pathname2, JFFS_PATH_NAME0);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+
+ off = lseek64(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT2); // compare ret off with target off 10
+
+ len = pwrite64(fd, writebuf, 10, -1); // write 10 bytes from fd at offset -1
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ off = lseek64(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ memset(readbuf, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2); // compare ret len with target len 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs676(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_676", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_690.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_690.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a6e2361a7f3b989dbb4dba730ee9c6f32721da9e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_690.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs690(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_690", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_694.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_694.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1a9f372a30fc77310ee97f5e04e4a0785d7b59ab
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_694.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs694(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_694", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_696.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_696.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b9c87281776d065a79514b18caf120853448da1f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_696.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove("//");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs696(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_696", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_697.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_697.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..867d6be409b9f8a31952699a0927b2f1ca4d0e63
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_697.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct statfs buf1 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = remove("/");
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs697(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_697", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_700.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_700.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..604013166aca17832fa5101ccf5ff26aea97992c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_700.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ int ret, i;
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ umount(JFFS_MAIN_DIR0);
+ for (i = 0; i < 30; i++) { // test 30 times
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, MS_RDONLY, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ umount(JFFS_MAIN_DIR0);
+EXIT:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs700(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_700", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_701.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_701.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7fc18b946608194f062786985aae64f52ad81f0a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_701.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ int ret, i;
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ umount(JFFS_MAIN_DIR0);
+ for (i = 0; i < 30; i++) { // test 30 times
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, MS_RDONLY, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ umount(JFFS_MAIN_DIR0);
+EXIT:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+testcase brief in English
+ *
+ */
+
+VOID ItFsJffs701(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_701", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_807.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_807.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..39013a9ffd8b9ccf63ddb30227ead3659b671c6f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_807.cpp
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 ret;
+ INT32 i;
+ INT32 index = 0;
+ INT32 fd[JFFS_CREATFILE_NUM] = {};
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ strcat(bufname1, "/test0");
+ strcat(bufname2, "/test1");
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ for (i = 0; i < JFFS_CREATFILE_NUM; i++) {
+ snprintf(pathname1, JFFS_STANDARD_NAME_LENGTH, "/storage/test/test1/file%d.txt", index);
+ fd[index] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+
+ if (fd[index] == -1) {
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ index++;
+ }
+
+ ret = rename(bufname1, bufname2);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+
+ index--;
+ for (i = index; i >= 0; i--) {
+ snprintf(pathname1, JFFS_STANDARD_NAME_LENGTH, "/storage/test/test1/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ snprintf(pathname1, JFFS_STANDARD_NAME_LENGTH, "/storage/test/test1/file%d.txt", i);
+ unlink(pathname1);
+ }
+EXIT:
+ rmdir(bufname1);
+ rmdir(bufname2);
+ rmdir(pathname);
+ return JFFS_NO_ERROR;
+}
+
+/*
+ *
+* -@test IT_FS_JFFS_807
+* -@tspec The function test for filesystem
+* -@ttitle test1 and not null test2 called API rename,rename test1 to test2
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. mkdir test1 and test2;
+2. open creat five files in test1;
+3. rename test1 to test2;
+4. unlink files in test1 and rmdir test1 and test2.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+ *
+ */
+
+VOID ItFsJffs807(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_807", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/full/It_vfs_jffs_808.cpp b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_808.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ad2e85764e70a4ed0567be4937c531807fe0fec7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/full/It_vfs_jffs_808.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 Testcase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_RDWR | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ closedir(dir);
+ goto EXIT1;
+EXIT2:
+ mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ close(fd);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+/*
+ * @ingroup jffs
+ * API test
+ * @brief 测试有文件或目录打开时å¸è½½jffs文件系统
+ * @par description: Test that umount the jffs filesystem when any file or directory is open
+ * @par precon: jffs moudle open
+ * 1ã€open a file and umount jffs.\n
+ * 2ã€close the file and umount jffs.\n
+ * 3ã€open a directory and umount jffs.\n
+ * 4ã€close the directory and umount jffs.\n
+ * 1ã€return failed. \n
+ * 2ã€return success. \n
+ * 3ã€return failed. \n
+ * 4ã€return success. \n
+ */
+
+VOID ItFsJffs808(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_808", Testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_001.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0e596d98ca9b773cd2934b678d55d38d5ffdc628
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_001.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[JFFS_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm *pstTM = NULL;
+
+ g_TestCnt++;
+
+ time(&tTime);
+ pstTM = localtime(&tTime);
+
+ memset_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ strftime(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", pstTM);
+ snprintf_s(fileName, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/%s_#%d", g_jffsPathname1,
+ (INT32)(INTPTR)arg);
+
+ snprintf_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "performance_001_%d",
+ (INT32)(INTPTR)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_jffsPathname1, 0, 0, 0);
+
+ ret = JffsRandWrite(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_WR_TYPE_TEST1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = JffsRandRead(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_WR_TYPE_TEST1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ g_TestCnt = 0;
+ return JFFS_NO_ERROR;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ pthread_t threadId;
+ pthread_attr_t attr;
+ INT32 priority = 14;
+ INT32 testNum = 2;
+
+ g_TestCnt = 0;
+ ret = PosixPthreadInit(&attr, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ while (g_TestCnt < testNum) {
+ sleep(1);
+ }
+
+ ret = pthread_join(threadId, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ pthread_join(threadId, NULL);
+ pthread_attr_destroy(&attr);
+
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPerformance001(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance001", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_002.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4cee2c78208863d60fbd2670458ccddec426fee2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_002.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[JFFS_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm *pstTM = NULL;
+
+ g_TestCnt++;
+
+ time(&tTime);
+ pstTM = localtime(&tTime);
+ memset_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ strftime(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", pstTM);
+ snprintf_s(fileName, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/%s_#%d", g_jffsPathname1,
+ (INT32)(INTPTR)arg);
+
+ snprintf_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "performance_002_%d",
+ (INT32)(INTPTR)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_jffsPathname1, 0, 0, 0);
+
+ ret = JffsFixWrite(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_PRESSURE_W_R_SIZE1, JFFS_WR_TYPE_TEST1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = JffsFixRead(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_PRESSURE_W_R_SIZE1, JFFS_WR_TYPE_TEST1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ return JFFS_NO_ERROR;
+ g_TestCnt = 0;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 i;
+ INT32 ret;
+ struct sched_param param;
+ pthread_t threadId;
+ pthread_attr_t attr;
+ INT32 priority = 14;
+ INT32 testNum = 2;
+
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ while (g_TestCnt < testNum) {
+ sleep(1);
+ }
+
+ ret = pthread_join(threadId, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ pthread_join(threadId, NULL);
+ pthread_attr_destroy(&attr);
+
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPerformance002(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance002", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_003.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3ec4ebdbcfa02316958dd6f0becfe67c1c55e3f7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_003.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[JFFS_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm *pstTM = NULL;
+
+ g_TestCnt++;
+
+ time(&tTime);
+ pstTM = localtime(&tTime);
+ memset_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ strftime(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", pstTM);
+ snprintf_s(fileName, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/%s_#%d", g_jffsPathname1,
+ (INT32)(INTPTR)arg);
+
+ snprintf_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "performance_003_%d",
+ (INT32)(INTPTR)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_jffsPathname1, 0, 0, 0);
+
+ ret = JffsRandWrite(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_WR_TYPE_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = JffsRandRead(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_WR_TYPE_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ return JFFS_NO_ERROR;
+ g_TestCnt = 0;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 i;
+ INT32 ret;
+ struct sched_param param;
+ pthread_t threadId;
+ pthread_attr_t attr;
+ INT32 priority = 14;
+ INT32 testNum = 2;
+
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ while (g_TestCnt < testNum) {
+ sleep(1);
+ }
+
+ ret = pthread_join(threadId, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ pthread_join(threadId, NULL);
+ pthread_attr_destroy(&attr);
+
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPerformance003(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance003", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_004.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..62589886e1756f56cb9057e0064209f1767d6678
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_004.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[JFFS_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm *pstTM = NULL;
+
+ g_TestCnt++;
+
+ time(&tTime);
+ pstTM = localtime(&tTime);
+ memset_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ strftime(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", pstTM);
+ snprintf_s(fileName, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/%s_#%d", g_jffsPathname1,
+ (INT32)(INTPTR)arg);
+
+ snprintf_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "performance_004_%d",
+ (INT32)(INTPTR)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_jffsPathname1, 0, 0, 0);
+
+ ret = JffsFixWrite(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_PRESSURE_W_R_SIZE1, JFFS_WR_TYPE_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = JffsFixRead(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_PRESSURE_W_R_SIZE1, JFFS_WR_TYPE_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ return JFFS_NO_ERROR;
+ g_TestCnt = 0;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ pthread_t threadId;
+ pthread_attr_t attr;
+ INT32 priority = 14;
+ INT32 testNum = 2;
+
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ while (g_TestCnt < testNum) {
+ sleep(1);
+ }
+
+ ret = pthread_join(threadId, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ pthread_join(threadId, NULL);
+ pthread_attr_destroy(&attr);
+
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPerformance004(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance004", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_005.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dfe15dd911e0d4e94db09a474d754dba3af09c45
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_005.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[JFFS_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm *pstTM = NULL;
+
+ g_TestCnt++;
+
+ time(&tTime);
+ pstTM = localtime(&tTime);
+ memset_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ strftime(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", pstTM);
+ snprintf_s(fileName, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/%s_#%d", g_jffsPathname1,
+ (INT32)(INTPTR)arg);
+
+ snprintf_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "performance_005_%d",
+ (INT32)(INTPTR)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_jffsPathname1, 0, 0, 0);
+
+ ret = JffsFixWrite(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_PRESSURE_W_R_SIZE1, JFFS_WR_TYPE_TEST1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = JffsFixRead(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_PRESSURE_W_R_SIZE1, JFFS_WR_TYPE_TEST1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ return JFFS_NO_ERROR;
+ g_TestCnt = 0;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_t threadId[JFFS_MAX_THREADS];
+ pthread_attr_t attr;
+ INT32 priority = 14;
+ INT32 testNum = 4;
+
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_create(&threadId[i], &attr, PthreadF01, (void *)(i + 1));
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ while (g_TestCnt < testNum) {
+ sleep(1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ pthread_attr_destroy(&attr);
+
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPerformance005(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance005", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_006.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b13a64d2cb26923a327d94dc5df5504408328d32
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_006.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[JFFS_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm *pstTM = NULL;
+
+ g_TestCnt++;
+
+ time(&tTime);
+ pstTM = localtime(&tTime);
+ memset_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ strftime(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", pstTM);
+ snprintf_s(fileName, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/%s_#%d", g_jffsPathname1,
+ (INT32)(INTPTR)arg);
+
+ snprintf_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "performance_006_%d",
+ (INT32)(INTPTR)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_jffsPathname1, 0, 0, 0);
+
+ ret = JffsRandWrite(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_WR_TYPE_TEST1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = JffsRandRead(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_WR_TYPE_TEST1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ return JFFS_NO_ERROR;
+ g_TestCnt = 0;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_t threadId[3];
+ pthread_attr_t attr;
+ INT32 priority = 14;
+ INT32 testNum = 6;
+
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_create(&threadId[i], &attr, PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ while (g_TestCnt < testNum) {
+ sleep(1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ pthread_attr_destroy(&attr);
+
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPerformance006(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance006", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_007.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b8ada1b769f821f4b465a593cd3555358dfdc86b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_007.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[JFFS_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm *pstTM = NULL;
+
+ g_TestCnt++;
+
+ time(&tTime);
+ pstTM = localtime(&tTime);
+ memset_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ strftime(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", pstTM);
+ snprintf_s(fileName, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/%s_#%d", g_jffsPathname1,
+ (INT32)(INTPTR)arg);
+
+ snprintf_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "performance_007_%d",
+ (INT32)(INTPTR)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_jffsPathname1, 0, 0, 0);
+
+ ret = JffsRandWrite(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_WR_TYPE_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = JffsRandRead(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_WR_TYPE_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ return JFFS_NO_ERROR;
+ g_TestCnt = 0;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_t threadId[3];
+ pthread_attr_t attr;
+ INT32 priority = 14;
+ INT32 testNum = 6;
+
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_create(&threadId[i], &attr, PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ while (g_TestCnt < testNum) {
+ sleep(1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ pthread_attr_destroy(&attr);
+
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPerformance007(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance007", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_008.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0113be3abe437a0bab50c524d476f62af4dfc4ca
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_008.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[JFFS_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm *pstTM = NULL;
+
+ g_TestCnt++;
+
+ time(&tTime);
+ pstTM = localtime(&tTime);
+ memset_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ strftime(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", pstTM);
+ snprintf_s(fileName, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/%s_#%d", g_jffsPathname1,
+ (INT32)(INTPTR)arg);
+
+ snprintf_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "performance_008_%d",
+ (INT32)(INTPTR)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_jffsPathname1, 0, 0, 0);
+
+ ret = JffsFixWrite(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_PRESSURE_W_R_SIZE1, JFFS_WR_TYPE_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = JffsFixRead(fileName, (INT64)JFFS_PERFORMANCE_W_R_SIZE, JFFS_PRESSURE_W_R_SIZE1, JFFS_WR_TYPE_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ return JFFS_NO_ERROR;
+ g_TestCnt = 0;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_t threadId[3];
+ pthread_attr_t attr;
+ INT32 priority = 14;
+ INT32 testNum = 6;
+
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_create(&threadId[i], &attr, PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ while (g_TestCnt < testNum) {
+ sleep(1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ pthread_attr_destroy(&attr);
+
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPerformance008(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance008", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_009.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_009.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ac22734f3d097bdaeadd925d09ce4767f3e579bb
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_009.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i, j, index, index1, len;
+ INT32 fd[JFFS_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR pathname0[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname0[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dir = NULL;
+ INT32 bufWLen = 500 * BYTES_PER_KBYTE; // 500 KB
+ struct dirent *ptr = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL(bufW, NULL, bufW);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = mkdir(pathname0, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(pathname0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ index = 0;
+ for (i = 0; i < JFFS_FILE_LIMITTED_NUM; i++) {
+ snprintf_s(bufname0, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt",
+ index);
+ fd[index] = open(bufname0, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+
+ ICUNIT_GOTO_NOT_EQUAL(fd[index], JFFS_IS_ERROR, fd, EXIT2);
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ index++;
+ }
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ for (i = index; i >= 0; i--) {
+ snprintf_s(bufname0, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(bufname0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ dprintf("FF--%s:%d, time: %d\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec));
+
+ free(bufW);
+ return JFFS_NO_ERROR;
+EXIT3:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(bufname0, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ unlink(bufname0);
+ }
+EXIT2:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPerformance009(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance009", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_010.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b07de9b0c88c88198e446a4b8ff157f92d90c722
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_010.cpp
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+#define MS_NOSYNC 2
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i, j, index, index1, len;
+ INT32 fd[JFFS_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dir = NULL;
+ INT32 bufWLen = 300 * BYTES_PER_KBYTE; // 300 KB
+ struct dirent *ptr = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL(bufW, NULL, bufW);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ index = 0;
+ for (i = 0; i < JFFS_FILE_LIMITTED_NUM; i++) {
+ errno = 0;
+ snprintf_s(bufname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt",
+ index);
+ fd[index] = open(bufname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ printf("[%d] name:%s, fd:%d, errno:%d\n", __LINE__, bufname1, fd[index], errno);
+ if (errno == ENOSPC) {
+ index;
+ goto EXIT3;
+ }
+ ICUNIT_GOTO_NOT_EQUAL(fd[index], JFFS_IS_ERROR, fd, EXIT3);
+
+ len = write(fd[index], bufW, strlen(bufW));
+ printf("[%d] name:%s,len:%d, errno:%d\n", __LINE__, bufname1, len, errno);
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ index++;
+ }
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ sync();
+ for (i = index; i >= 0; i--) {
+ snprintf_s(bufname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(bufname1);
+ printf("[%d] name:%s,ret:%d, errno:%d\n", __LINE__, bufname1, ret, errno);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ dprintf("FF--%s:%d, time: %d\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec));
+
+ free(bufW);
+ return JFFS_NO_ERROR;
+EXIT4:
+ umount(JFFS_MOUNT_DIR0);
+EXIT3:
+ for (i = index - 1; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT2:
+ for (i = index - 1; i >= 0; i--) {
+ errno = 0;
+ snprintf_s(bufname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(bufname1);
+ printf("[%d] name:%s,ret:%d, errno:%d\n", __LINE__, bufname1, ret, errno);
+ }
+EXIT1:
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPerformance010(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance010", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_011.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_011.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0ddf40a036229d3aacf2237fe64b366a6a69e055
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_011.cpp
@@ -0,0 +1,380 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static constexpr INT32 USLEEP_TIME = 10;
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, ret, len, index;
+ INT32 fd[JFFS_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < JFFS_FILE_LIMITTED_NUM; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/file%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ usleep(SLEEP_TIME);
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ dprintf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec));
+
+ g_TestCnt++;
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (i; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+EXIT:
+ rmdir(bufname);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, ret, len, index;
+ INT32 fd[JFFS_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < JFFS_FILE_LIMITTED_NUM; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ usleep(SLEEP_TIME);
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ dprintf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec));
+
+ g_TestCnt++;
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (i; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+EXIT:
+ rmdir(bufname);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, ret, len, index;
+ INT32 fd[JFFS_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < JFFS_FILE_LIMITTED_NUM; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ usleep(SLEEP_TIME);
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ dprintf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec));
+
+ g_TestCnt++;
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (i; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+EXIT:
+ rmdir(bufname);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+ errno = 0;
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], TASK_PRIO_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], TASK_PRIO_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], TASK_PRIO_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* - @test ItFsJffsPerformance011
+* - @tspec function test
+* - @ttitle Multi-threaded takes time to delete directory files
+* - @tbrief
+1. Create 200 files per directory;
+2. The size of each file is 300K;
+3. Call the gettimeofday() to get the time;
+4. Delete files and directories;
+5. Call the gettimeofday() to get the time and View the time of serial port printing.
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsJffsPerformance011(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance011", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_012.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_012.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..43c08cce49f799745c4a19ff2d0005a1248141d9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_012.cpp
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 fd[JFFS_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ INT32 bufWLen = 300 * BYTES_PER_KBYTE; // 300 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < JFFS_FILE_LIMITTED_NUM; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ len = write(fd[index], bufW, strlen(bufW));
+
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ dprintf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec));
+
+ g_TestCnt++;
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (i; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+EXIT:
+ rmdir(bufname);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, ret, len, index;
+ INT32 fd[JFFS_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ INT32 bufWLen = 300 * BYTES_PER_KBYTE; // 300 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < JFFS_FILE_LIMITTED_NUM; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ len = write(fd[index], bufW, strlen(bufW));
+
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ dprintf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec));
+
+ g_TestCnt++;
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (i; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+EXIT:
+ rmdir(bufname);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 fd[JFFS_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ INT32 bufWLen = 300 * BYTES_PER_KBYTE; // 300 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < JFFS_FILE_LIMITTED_NUM; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ len = write(fd[index], bufW, strlen(bufW));
+
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ dprintf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec));
+
+ g_TestCnt++;
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (i; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+EXIT:
+ rmdir(bufname);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], TASK_PRIO_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], TASK_PRIO_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], TASK_PRIO_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+ return JFFS_NO_ERROR;
+}
+
+/* *
+* - @test ItFsJffsPerformance012
+* - @tspec function test
+* - @ttitle Multi-threaded takes time to delete directory files
+* - @tbrief
+1. Create 200 files per directory;
+2. The size of each file is 300K;
+3. Call the gettimeofday() to get the time;
+4. Delete files and directories;
+5. Call the gettimeofday() to get the time and View the time of serial port printing.
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsJffsPerformance012(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance012", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_013.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_013.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6a0e16f8b41e0e380f20e30bb52c8083bb5e8247
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_performance_013.cpp
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+
+static void *PthreadFunc(void *arg)
+{
+ int fd = -1;
+ int ret;
+ int num = JFFS_MAX_NUM_TEST;
+ char *fileName = { JFFS_PATH_NAME0 };
+ char *filebuf = "helloworld";
+
+ while (num-- > 0) {
+ fd = open(fileName, O_RDWR | O_CREAT, S_IRUSR);
+ if (fd < 0) {
+ printf("open %s failed, error: %s\n", fileName, strerror(errno));
+ }
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ ret = write(fd, filebuf, strlen(filebuf));
+ if (ret != strlen(filebuf)) {
+ printf("write %s failed, ret: %d, error: %s\n", fileName, ret, strerror(errno));
+ }
+ ICUNIT_GOTO_EQUAL(ret, strlen(filebuf), ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(fileName);
+ if (ret != 0) {
+ printf("remove %s failed, ret: %d, error: %s\n", fileName, ret, strerror(errno));
+ }
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+ pthread_exit(0);
+EXIT1:
+ close(fd);
+EXIT2:
+ unlink(fileName);
+EXIT:
+ pthread_exit(0);
+}
+
+static UINT32 TestCase(VOID)
+{
+ pthread_attr_t attr1, attr2;
+ pthread_t newTh1, newTh2;
+ int ret;
+ int num = 100;
+ int priority = 14;
+
+ while (num-- > 0) {
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadFunc, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadFunc, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ ret = pthread_join(newTh1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_attr_destroy(&attr1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_join(newTh2, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_attr_destroy(&attr2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ pthread_join(newTh2, NULL);
+ pthread_attr_destroy(&attr2);
+EXIT1:
+ pthread_join(newTh1, NULL);
+ pthread_attr_destroy(&attr1);
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+
+VOID ItFsJffsPerformance013(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPerformance013", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_001.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ef13823bc83e6e36d416cad9b03f4649a36d4047
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_001.cpp
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ struct flock fl = { 0 };
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/jffs_1600.txt");
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ ret = rename(pathname1, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rename(pathname2, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0000000000111111111122222222223333333333", readbuf, EXIT2);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rename(pathname1, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rename(pathname2, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(buf2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd);
+ goto EXIT1;
+EXIT2:
+ close(fd1);
+EXIT1:
+ remove(pathname1);
+ remove(pathname2);
+EXIT:
+ rmdir(pathname3);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure001(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure001", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_002.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6b4a7e1d8732c9956cbf9d789e42a06d602d1bdd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_002.cpp
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test/test1");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/test/test2", strlen(pathname1));
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/test/test3", strlen(pathname1));
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/test/jffs_1601.txt", strlen(pathname1));
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, "/123");
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ ret = rename(pathname2, pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rename(pathname3, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ dir = opendir(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT);
+
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, 0, offset, EXIT); // dir offset: 0
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT);
+
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, 1, offset, EXIT3); // dir offset: 1
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT);
+
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, 2, offset, EXIT); // dir offset: 2
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT);
+
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, 3, offset, EXIT); // dir offset: 3
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT);
+
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, 4, offset, EXIT); // dir offset: 4
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT);
+
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, 4, offset, EXIT); // dir offset: 4
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/test/jffs_1601.txt", strlen(pathname1));
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/test/test1", strlen(pathname1));
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/test/test2", strlen(pathname1));
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ JffsStrcat2(pathname1, "/test/test3", strlen(pathname1));
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ JffsStrcat2(pathname2, "/test", strlen(pathname2));
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd);
+EXIT2:
+ JffsStrcat2(pathname1, "/test/jffs_1601.txt", strlen(pathname1));
+ remove(pathname1);
+ JffsStrcat2(pathname1, "/test/test3", strlen(pathname1));
+ remove(pathname1);
+ JffsStrcat2(pathname1, "/test/test2", strlen(pathname1));
+ remove(pathname1);
+ JffsStrcat2(pathname1, "/test/test1", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "/123/jffs_1601.txt", strlen(pathname1));
+ remove(pathname1);
+ JffsStrcat2(pathname1, "/123/test3", strlen(pathname1));
+ remove(pathname1);
+ JffsStrcat2(pathname1, "/123/test2", strlen(pathname1));
+ remove(pathname1);
+ JffsStrcat2(pathname1, "/123/test1", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(pathname3);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure002(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure002", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_003.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9f8dc1c6a937f4075bdbdf1f1fa837eb0f33447e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_003.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/1602_%d", i);
+ JffsStrcat2(pathname2, bufname, strlen(bufname));
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ closedir(dir);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname4);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure003(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure003", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_004.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2651a0cb648b97237ac983378b75c6014bdbb57a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_004.cpp
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dirbuf[JFFS_SHORT_ARRAY_LENGTH] = {NULL};
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ memset_s(pathname1, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ strcpy_s(pathname1, JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(pathname[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/1603_%d", i);
+ strcat_s(pathname1, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcpy_s(pathname[i], JFFS_NAME_LIMITTED_SIZE, pathname1);
+
+ ret = mkdir(pathname[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dirbuf[i] = opendir(pathname[i]);
+ ICUNIT_GOTO_NOT_EQUAL(dirbuf[i], NULL, dirbuf[i], EXIT2);
+ }
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ JffsStatPrintf(buf2);
+
+ for (i = JFFS_PRESSURE_CYCLES - 1; i >= 0; i--) {
+ ret = closedir(dirbuf[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ closedir(dirbuf[i]);
+ }
+
+EXIT1:
+ for (i = JFFS_PRESSURE_CYCLES - 1; i >= 0; i--) {
+ rmdir(pathname[i]);
+ }
+EXIT:
+ remove(pathname3);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure004(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure004", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_005.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fed0a86eec14114c0293644b4469283dd41e0905
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_005.cpp
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ static UINT32 flag = 0;
+ signed long long offset;
+
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname4[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname5[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname6[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ DIR *dir1 = NULL;
+ DIR *dir2 = NULL;
+ DIR *dir3 = NULL;
+ DIR *dir4 = NULL;
+ DIR *dir5 = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ strcat_s(pathname1, JFFS_NAME_LIMITTED_SIZE, "/test1");
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, "/test2");
+ strcat_s(pathname3, JFFS_NAME_LIMITTED_SIZE, "/test3");
+ strcat_s(pathname4, JFFS_NAME_LIMITTED_SIZE, "/test4");
+ strcat_s(pathname5, JFFS_NAME_LIMITTED_SIZE, "/test5");
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = mkdir(pathname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+
+ ret = mkdir(pathname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ dir1 = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir1, NULL, dir1, EXIT6);
+
+ dir2 = opendir(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(dir2, NULL, dir2, EXIT7);
+
+ dir3 = opendir(pathname3);
+ ICUNIT_GOTO_NOT_EQUAL(dir3, NULL, dir3, EXIT8);
+
+ dir4 = opendir(pathname4);
+ ICUNIT_GOTO_NOT_EQUAL(dir4, NULL, dir4, EXIT9);
+
+ dir5 = opendir(pathname5);
+ ICUNIT_GOTO_NOT_EQUAL(dir5, NULL, dir5, EXIT10);
+
+ ret = closedir(dir1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = closedir(dir2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = closedir(dir3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = closedir(dir4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = closedir(dir5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = rmdir(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+
+ ret = rmdir(pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+ }
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT10:
+ closedir(dir5);
+EXIT9:
+ closedir(dir4);
+EXIT8:
+ closedir(dir3);
+EXIT7:
+ closedir(dir2);
+EXIT6:
+ closedir(dir1);
+EXIT5:
+ rmdir(pathname5);
+EXIT4:
+ rmdir(pathname4);
+EXIT3:
+ rmdir(pathname3);
+EXIT2:
+ rmdir(pathname2);
+EXIT1:
+ rmdir(pathname1);
+EXIT:
+ rmdir(pathname6);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure005(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure005", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_006.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..41d70b5186d929ece407f36c991e6a5066178006
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_006.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+ JffsStrcat2(pathname2, "/", strlen(pathname2));
+
+ for (j = 0; j < 40; j++) { // loop times: 40
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "test%d", j);
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, bufname);
+ }
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT3);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT3);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0000000000111111111122222222223333333333", readbuf, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ remove(pathname2);
+ goto EXIT;
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure006(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure006", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_007.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..59d7b837977b6c4de08ef4e36a820b12e324058c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_007.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR pathname4[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR pathname5[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, strlen(readbuf));
+ memset_s(pathname2, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, pathname6);
+
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ memset_s(pathname3[j], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", j);
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcpy_s(pathname3[j], JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ ret = mkdir(pathname3[j], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ strcpy_s(pathname4[j], JFFS_NAME_LIMITTED_SIZE, pathname3[j]);
+ strcat_s(pathname4[j], JFFS_NAME_LIMITTED_SIZE, ".txt");
+ }
+
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ fd = open(pathname4[j], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0000000000111111111122222222223333333333", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname4[j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+
+ for (j = JFFS_SHORT_ARRAY_LENGTH - 1; j >= 0; j--) {
+ ret = rmdir(pathname3[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ }
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(buf2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ unlink(pathname4[i]);
+ }
+EXIT1:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ rmdir(pathname3[i]);
+ }
+EXIT:
+ rmdir(pathname5);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure007(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure007", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_008.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b103d3a1d14d222658deb26fe652d9c809286172
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_008.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ memset_s(pathname2, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+ JffsStrcat2(pathname2, "/_", strlen(pathname2));
+
+ for (j = 0; j < 31; j++) { // loop times: 31
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "test%d", j);
+ JffsStrcat2(pathname2, bufname, strlen(bufname));
+ }
+
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ dir = opendir(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ }
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ closedir(dir);
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname3);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure008(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure008", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_009.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_009.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d700b161961a2aaa79d0ebed8d9cef6f7573e6db
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_009.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, "/1608.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ fd = open(pathname2, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0000000000111111111122222222223333333333", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname2);
+EXIT:
+ rmdir(pathname3);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure009(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure009", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_010.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..11ec8ddf580a0b0aecdeb80c92c9497b3c709b22
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_010.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname4[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname5[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname6[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, "/1609.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, strlen(readbuf));
+
+ fd = open(pathname2, O_NONBLOCK | O_TRUNC | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0000000000111111111122222222223333333333", readbuf, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname2);
+EXIT:
+ rmdir(pathname3);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure010(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure010", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_011.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_011.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..61ce1b5b58acc15547a0a65cd9a63a7cbf8dff07
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_011.cpp
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR pathname3[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+ INT32 even = 2;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ JffsStrcat2(pathname2, bufname, strlen(pathname2));
+ strcpy_s(pathname[i], JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ ret = mkdir(pathname[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/1016_%d", i);
+ JffsStrcat2(pathname2, bufname, strlen(pathname2));
+ strcpy_s(pathname3[i], JFFS_NAME_LIMITTED_SIZE, pathname2);
+ }
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ if ((j % even) == 0) {
+ ret = rename(pathname[i], pathname3[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ } else {
+ ret = rename(pathname3[i], pathname[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+ }
+ if ((j % even) == 0) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = rmdir(pathname[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ } else {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = rmdir(pathname3[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = rmdir(pathname3[i]);
+ }
+
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = rmdir(pathname[i]);
+ }
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure011(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure011", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_012.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_012.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d521a5e194e69de8b3eba221f6be90b2fae2ecec
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_012.cpp
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH], fd1, ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR pathname3[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR pathname5[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR pathname6[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+ INT32 even = 2;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ JffsStrcat2(pathname2, bufname, strlen(pathname2));
+ strcpy_s(pathname[i], JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, "/test.txt");
+ strcpy_s(pathname5[i], JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/1011_%d", i);
+ JffsStrcat2(pathname2, bufname, strlen(pathname2));
+ strcpy_s(pathname3[i], JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, "/test.txt");
+ strcpy_s(pathname6[i], JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ ret = mkdir(pathname[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd[i] = open(pathname5[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT3);
+
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ }
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ if ((j % even) == 0) {
+ ret = rename(pathname[i], pathname3[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ } else {
+ ret = rename(pathname3[i], pathname[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+ }
+
+ if ((j % even) == 1) {
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ ret = unlink(pathname6[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname3[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ } else {
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ ret = unlink(pathname5[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(fd[i]);
+ }
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ unlink(pathname5[i]);
+ unlink(pathname6[i]);
+ }
+
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ rmdir(pathname[i]);
+ rmdir(pathname3[i]);
+ }
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure012(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure012", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_014.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_014.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3d89a80616d6a78696aaa0e3a278e5545fb3dc35
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_014.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+ DIR *dir = NULL;
+ DIR *dirbuf[BYTES_PER_KBYTE] = {NULL};
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ JffsStrcat2(pathname3, "/1613.txt", strlen(pathname3));
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT3);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT3);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0000000000111111111122222222223333333333", readbuf, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT4);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+ }
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ JffsStatPrintf(buf2);
+
+ ret = unlink(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT4:
+ closedir(dir);
+ goto EXIT2;
+EXIT3:
+ close(fd);
+EXIT2:
+ unlink(pathname3);
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure014(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure014", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_015.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_015.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e17ac7233b5f6433049aaa20799e24485dd4a7e1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_015.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname4[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dirbuf[JFFS_SHORT_ARRAY_LENGTH] = {NULL};
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/1614_%d", i);
+ strcat_s(pathname1, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcpy_s(pathname[i], JFFS_NAME_LIMITTED_SIZE, pathname1);
+
+ ret = mkdir(pathname[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ dirbuf[i] = opendir(pathname[i]);
+ ICUNIT_GOTO_NOT_EQUAL(dirbuf[i], NULL, dirbuf[i], EXIT2);
+ }
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = closedir(dirbuf[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ ret = rmdir(pathname[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ closedir(dirbuf[i]);
+ }
+EXIT1:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ rmdir(pathname[i]);
+ }
+
+EXIT:
+ rmdir(pathname3);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure015(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure015", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_016.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_016.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a2091611188a38f696d0a5488720f11602f87c1a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_016.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ signed long long offset;
+
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname[JFFS_SHORT_ARRAY_LENGTH][JFFS_STANDARD_NAME_LENGTH] = {0};
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(pathname[i], JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/1615_%d", i);
+ JffsStrcat2(pathname2, bufname, strlen(pathname2));
+ strcat_s(pathname[i], JFFS_STANDARD_NAME_LENGTH, pathname2);
+ }
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ fd[i] = open(pathname[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT2);
+
+ len = write(fd[i], filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ len = read(fd[i], readbuf, 45); // read length: 45
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(fd[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(fd[i]);
+ }
+
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ unlink(pathname[i]);
+ }
+
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure016(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure016", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_017.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_017.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cf43972dcee9db0a42c3bcf59f1c0cccebd2e72a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_017.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname4[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/1616_%d", i);
+ JffsStrcat2(pathname2, bufname, strlen(pathname2));
+ strcat_s(pathname[i], JFFS_STANDARD_NAME_LENGTH, pathname2);
+
+ fd[i] = open(pathname[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT2);
+ }
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ off = lseek(fd[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = write(fd[i], filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+ }
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ off = lseek(fd[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(fd[i]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ unlink(pathname[i]);
+ }
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure017(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure017", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_018.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_018.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b69073cbf789f6f6d8e122656e62769e136d3a5d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_018.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ signed long long offset;
+
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname4[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/1617_%d", i);
+ JffsStrcat2(pathname2, bufname, strlen(pathname2));
+ strcat_s(pathname[i], JFFS_STANDARD_NAME_LENGTH, pathname2);
+
+ fd[i] = open(pathname[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT);
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ off = lseek(fd[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT);
+
+ len = write(fd[i], filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT);
+ }
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ off = lseek(fd[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT);
+
+ len = read(fd[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT);
+ }
+ }
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ off = lseek(fd[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT);
+
+ len = read(fd[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT);
+
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = unlink(pathname[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(fd[i]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ unlink(pathname[i]);
+ }
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure018(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure018", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_019.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_019.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..96f5f4c300a47feeb0ff1ee56cf38d767189665e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_019.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname1[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR bufname2[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname4[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR pathname5[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(pathname3, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ snprintf_s(bufname1, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, bufname1);
+ strcat_s(pathname3, JFFS_NAME_LIMITTED_SIZE, pathname2);
+ strcpy_s(pathname4[i], JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ ret = mkdir(pathname4[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname3, JFFS_NAME_LIMITTED_SIZE, ".txt");
+ strcpy_s(pathname5[i], JFFS_NAME_LIMITTED_SIZE, pathname3);
+
+ fd[i] = open(pathname5[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT2);
+ }
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ off = lseek(fd[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = write(fd[i], filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+ }
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ off = lseek(fd[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+ }
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ off = lseek(fd[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(fd[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+ }
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ off = lseek(fd[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = write(fd[i], filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+ }
+ }
+
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ off = lseek(fd[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+ len = read(fd[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT2);
+
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname5[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname4[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(fd[i]);
+ }
+EXIT1:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ unlink(pathname5[i]);
+ rmdir(pathname4[i]);
+ }
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure019(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure019", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_020.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_020.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cf057b217a2bfbbca9e5097e03064c55cb7c8edb
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_020.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(pathname[i], JFFS_NAME_LIMITTED_SIZE, 0, strlen(pathname[i]));
+ }
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/1616_%d", i);
+ JffsStrcat2(pathname2, bufname, strlen(pathname2));
+ strcat_s(pathname[i], JFFS_STANDARD_NAME_LENGTH, pathname2);
+
+ fd[i] = open(pathname[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT2);
+ }
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(fd[i]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ unlink(pathname[i]);
+ }
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure020(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure020", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_021.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_021.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5f96fee6c0634e45fe2d02e0ca06177a836dc807
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_021.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ signed long long offset;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname1[JFFS_SHORT_ARRAY_LENGTH] = "";
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname4[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR pathname5[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(pathname4[i], JFFS_NAME_LIMITTED_SIZE, 0, strlen(pathname4[i]));
+ memset_s(pathname5[i], JFFS_NAME_LIMITTED_SIZE, 0, strlen(pathname5[i]));
+ }
+ memset_s(pathname2, JFFS_NAME_LIMITTED_SIZE, 0, strlen(pathname2));
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, pathname1);
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(pathname3, JFFS_NAME_LIMITTED_SIZE, 0, strlen(pathname3));
+
+ snprintf_s(bufname1, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, bufname1);
+ strcat_s(pathname3, JFFS_NAME_LIMITTED_SIZE, pathname2);
+ strcpy_s(pathname4[i], JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ ret = mkdir(pathname4[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname3, JFFS_NAME_LIMITTED_SIZE, ".txt");
+ strcpy_s(pathname5[i], JFFS_NAME_LIMITTED_SIZE, pathname3);
+
+ fd[i] = open(pathname5[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT2);
+ }
+
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname5[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname4[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+ LosTaskDelay(10); // delay time: 10
+ }
+ LosTaskDelay(100); // delay time: 100
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT1:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ unlink(pathname5[i]);
+ rmdir(pathname4[i]);
+ }
+
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure021(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure021", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_022.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_022.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1c413860a9c16f84b1f848ac3ab49ecd6b62803d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_022.cpp
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ signed long long offset;
+ CHAR filebuf[70] = "1111111111222222222233333333334444444444555555555566666666667777";
+ CHAR readbuf[70] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+ struct stat statfile;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1621.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ for (i = 0; i < 16 * 1024; i++) { // loop times: 16 * 1024
+ errno = 0;
+ ret = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(ret, strlen(filebuf), ret, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, (strlen(filebuf) * (i + 1)), off, EXIT2);
+ }
+
+ off = lseek(fd, 64, SEEK_SET); // seek offset: 64
+ ICUNIT_GOTO_EQUAL(off, 64, off, EXIT2);
+
+ len = read(fd, readbuf, 64); // read length: 64
+ ICUNIT_GOTO_EQUAL(len, 64, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1111111111222222222233333333334444444444555555555566666666667777", readbuf,
+ EXIT2);
+
+ ret = stat(pathname1, &statfile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ // file size: 1024 * 1024
+ ICUNIT_GOTO_EQUAL(statfile.st_size, 1024 * 1024, statfile.st_size, EXIT2);
+
+ printf("[%d] cycle:%d errno:%d\n", __LINE__, j, errno);
+ }
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure022(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure022", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_023.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_023.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2c827eeb1a97e28e121985e63f8feb00d9d911be
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_023.cpp
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ signed long long offset;
+
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[70] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+ struct stat statfile;
+
+ INT32 bufWLen = BYTES_PER_MBYTE;
+ INT32 bufW1Len = 512 * BYTES_PER_KBYTE; // 512 KB
+ INT32 bufW2Len = 16 * BYTES_PER_KBYTE; // 16 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL(bufW, NULL, 0);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW1 = (CHAR *)malloc(bufW1Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW1, NULL, 0, EXIT2);
+ memset_s(bufW1, bufW1Len + 1, 0, bufW1Len + 1);
+
+ bufW2 = (CHAR *)malloc(bufW2Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW2, NULL, 0, EXIT3);
+ memset_s(bufW2, bufW2Len + 1, 0, bufW2Len + 1);
+
+ for (j = 0; j < bufW2Len / strlen(filebuf); j++) {
+ strcat_s(bufW2, bufW2Len + 1, filebuf);
+ }
+
+ for (j = 0; j < bufW1Len / bufW2Len; j++) {
+ strcat_s(bufW1, bufW1Len + 1, bufW2);
+ }
+
+ for (i = 0; i < bufWLen / bufW1Len; i++) {
+ strcat_s(bufW, bufWLen + 1, bufW1);
+ }
+
+ free(bufW1);
+ free(bufW2);
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ JffsStatPrintf(buf1);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1622.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ ret = write(fd, bufW, strlen(bufW));
+ printf("cnt=%d %d\n", i, j);
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTE, ret, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, (BYTES_PER_MBYTE * (i + 1)), off, EXIT2);
+ }
+ ret = stat(pathname1, &statfile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ // file size: 10 * 1024 * 1024
+ ICUNIT_GOTO_EQUAL(statfile.st_size, 10 * 1024 * 1024, statfile.st_size, EXIT2);
+ }
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ free(bufW);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ free(bufW1);
+EXIT2:
+ free(bufW);
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure023(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure023", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_024.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_024.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bb949540ade6d3b9c576f59aa24d9732bc5408f5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_024.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ signed long long offset;
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[70] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+ struct stat statfile;
+
+ INT32 bufWLen = BYTES_PER_MBYTE;
+ INT32 bufW1Len = 512 * BYTES_PER_KBYTE; // 512 KB
+ INT32 bufW2Len = 16 * BYTES_PER_KBYTE; // 16 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL(bufW, NULL, 0);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW1 = (CHAR *)malloc(bufW1Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW1, NULL, 0, EXIT2);
+ memset_s(bufW1, bufW1Len + 1, 0, bufW1Len + 1);
+
+ bufW2 = (CHAR *)malloc(bufW2Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW2, NULL, 0, EXIT3);
+ memset_s(bufW2, bufW2Len + 1, 0, bufW2Len + 1);
+
+ for (j = 0; j < bufW2Len / strlen(filebuf); j++) {
+ strcat_s(bufW2, bufW2Len + 1, filebuf);
+ }
+
+ for (j = 0; j < bufW1Len / bufW2Len; j++) {
+ strcat_s(bufW1, bufW1Len + 1, bufW2);
+ }
+
+ for (i = 0; i < bufWLen / bufW1Len; i++) {
+ strcat_s(bufW, bufWLen + 1, bufW1);
+ }
+ free(bufW1);
+ free(bufW2);
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ JffsStatPrintf(buf1);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/1623.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ for (j = 0; j < 1; j++) {
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ for (i = 0; i < 100; i++) { // loop times: 100
+ ret = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTE, ret, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, (BYTES_PER_MBYTE * (i + 1)), off, EXIT2);
+ }
+
+ off = lseek(fd, 64, SEEK_SET); // seek offset: 64
+ ICUNIT_GOTO_EQUAL(off, 64, off, EXIT2); // file position: 64
+
+ len = read(fd, readbuf, 64); // read length: 64
+ ICUNIT_GOTO_EQUAL(len, 64, len, EXIT2);
+
+ ret = stat(pathname1, &statfile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ // 100 * 1024 * 1024: filesize
+ ICUNIT_GOTO_EQUAL(statfile.st_size, 100 * 1024 * 1024, statfile.st_size, EXIT2);
+ }
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ free(bufW);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ free(bufW1);
+EXIT2:
+ free(bufW);
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure024(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure024", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_025.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_025.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ab8015a6d3d387aacf9bf5cbf96dbaa704a3413f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_025.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ static INT32 count = 0;
+ signed long long offset;
+
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333 333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "123";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_SHORT_ARRAY_LENGTH][JFFS_STANDARD_NAME_LENGTH] = {0};
+ CHAR pathname4[JFFS_SHORT_ARRAY_LENGTH][JFFS_STANDARD_NAME_LENGTH] = {0};
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 even = 2;
+
+ struct stat statfile;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(pathname2, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(bufname, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(pathname3[i], JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(pathname4[i], JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+
+ strcpy_s(pathname2, JFFS_STANDARD_NAME_LENGTH, pathname1);
+ snprintf_s(bufname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/1623_%d.txt", i);
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, bufname);
+ strcat_s(pathname3[i], JFFS_STANDARD_NAME_LENGTH, pathname2);
+
+ memset_s(pathname2, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(bufname, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ strcpy_s(pathname2, JFFS_STANDARD_NAME_LENGTH, pathname1);
+ snprintf_s(bufname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/test_%d.c", i);
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, bufname);
+ strcat_s(pathname4[i], JFFS_STANDARD_NAME_LENGTH, pathname2);
+
+ fd[i] = open(pathname3[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT2);
+
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ if ((j % even) == 0) {
+ ret = rename(pathname3[i], pathname4[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ } else {
+ ret = rename(pathname4[i], pathname3[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ }
+ }
+
+ if ((j % even) == 0) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = unlink(pathname3[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ } else {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = unlink(pathname4[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(fd[i]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ remove(pathname3[i]);
+ remove(pathname4[i]);
+ }
+EXIT:
+ chdir(JFFS_MAIN_DIR0);
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure025(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure025", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_026.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_026.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8b4fb5498e14d25c7847442b271d44b127030607
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_026.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ signed long long offset;
+
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333 333";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "123";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR pathname4[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR pathname5[JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ off_t off;
+ struct stat statfile;
+ INT32 even = 2;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ snprintf_s(bufname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/test%d", i);
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, bufname);
+ strcpy_s(pathname3[i], JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ ret = mkdir(pathname3[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcpy_s(pathname4[i], JFFS_NAME_LIMITTED_SIZE, pathname3[i]);
+ strcat_s(pathname4[i], JFFS_NAME_LIMITTED_SIZE, ".txt");
+
+ strcpy_s(pathname5[i], JFFS_NAME_LIMITTED_SIZE, pathname3[i]);
+ strcat_s(pathname5[i], JFFS_NAME_LIMITTED_SIZE, ".c");
+
+ fd[i] = open(pathname4[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT3);
+
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ for (j = 0; j < JFFS_PRESSURE_CYCLES; j++) {
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ if ((j % even) == 0) {
+ ret = rename(pathname4[i], pathname5[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ } else {
+ ret = rename(pathname5[i], pathname4[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+ }
+
+ if ((j % even) == 0) {
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ ret = unlink(pathname4[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname3[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ } else {
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ ret = unlink(pathname5[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname3[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(fd[i]);
+ }
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ remove(pathname4[i]);
+ remove(pathname5[i]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ remove(pathname3[i]);
+ }
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure026(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure026", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_027.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_027.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a6960abd9061cfa0fb61e404d0aa74229fb9e494
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_027.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, scandirCount1, scandirCount2;
+ INT64 i;
+ INT64 perTime;
+ INT64 totalSize = 0;
+ INT64 totalTime = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ struct timeval testTime1;
+ struct timeval testTime2;
+ struct dirent **namelist = NULL;
+ DOUBLE mountSpeed;
+
+ totalTime = 0;
+ totalSize = 0;
+
+ scandirCount1 = scandir(pathname2, &namelist, 0, alphasort);
+ if (scandirCount1 >= 0) {
+ JffsScandirFree(namelist, scandirCount1);
+ }
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ gettimeofday(&testTime1, 0);
+
+ ret = umount(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ dprintf("the size:%lld th,umount/mount cost %lld us \n", i, perTime);
+ }
+
+ totalSize = i;
+
+ mountSpeed = totalSize * 1.0;
+ mountSpeed = totalTime / mountSpeed;
+
+ dprintf("total_size %lld,cost %lld us, speed: %0.3lf us/Size\n", totalSize, totalTime, mountSpeed);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ scandirCount2 = scandir(pathname2, &namelist, 0, alphasort);
+ if (scandirCount2 >= 0) {
+ JffsScandirFree(namelist, scandirCount2);
+ }
+
+ ICUNIT_GOTO_EQUAL(scandirCount1, scandirCount2, scandirCount2, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure027(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure027", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_028.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_028.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..12c9460c75598f630a40cd2008206e86cc175f44
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_028.cpp
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, scandirCount1, scandirCount2;
+ INT64 i, j;
+ INT64 writeCount = 0;
+ INT64 readCount = 0;
+ INT64 perTime;
+ INT64 totalSize = 0;
+ INT64 totalTime = 0;
+ INT32 fileLen = 2 * BYTES_PER_KBYTE; // 2 KB
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ struct dirent **namelist = NULL;
+ DOUBLE mountSpeed;
+ struct statfs buf1 = { 0 };
+ struct statfs buf2 = { 0 };
+ struct statfs buf3 = { 0 };
+
+ INT32 bufWLen = BYTES_PER_MBYTE;
+ INT32 bufW1Len = 512 * BYTES_PER_KBYTE; // 512 KB
+ INT32 bufW2Len = 16 * BYTES_PER_KBYTE; // 16 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL(bufW, NULL, 0);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW1 = (CHAR *)malloc(bufW1Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW1, NULL, 0, EXIT2);
+ memset_s(bufW1, bufW1Len + 1, 0, bufW1Len + 1);
+
+ bufW2 = (CHAR *)malloc(bufW2Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW2, NULL, 0, EXIT3);
+ memset_s(bufW2, bufW2Len + 1, 0, bufW2Len + 1);
+
+ for (j = 0; j < bufW2Len / strlen(filebuf); j++) {
+ strcat_s(bufW2, bufW2Len + 1, filebuf);
+ }
+
+ for (j = 0; j < bufW1Len / bufW2Len; j++) {
+ strcat_s(bufW1, bufW1Len + 1, bufW2);
+ }
+
+ for (i = 0; i < bufWLen / bufW1Len; i++) {
+ strcat_s(bufW, bufWLen + 1, bufW1);
+ }
+ free(bufW1);
+ free(bufW2);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ for (i = 0; i < fileLen / (INT32)bufW; i++) {
+ ret = write(fd, bufW, strlen(filebuf));
+ writeCount++;
+ }
+
+ free(bufW);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(JFFS_MAIN_DIR0, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatfsPrintf(buf3);
+
+ totalTime = 0;
+ totalSize = 0;
+
+ scandirCount1 = scandir(pathname2, &namelist, 0, alphasort);
+ if (scandirCount1 >= 0) {
+ JffsScandirFree(namelist, scandirCount1);
+ }
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ gettimeofday(&testTime1, 0);
+
+ ret = umount(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ dprintf("the size:%lld th,umount/mount cost %lld us \n", i, perTime);
+ }
+
+ totalSize = i;
+
+ mountSpeed = totalSize * 1.0;
+ mountSpeed = totalTime / mountSpeed;
+
+ dprintf("total_size %lld,cost %lld us, speed: %0.3lf us/Size\n", totalSize, totalTime, mountSpeed);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ scandirCount2 = scandir(pathname2, &namelist, 0, alphasort);
+ if (scandirCount2 >= 0) {
+ JffsScandirFree(namelist, scandirCount2);
+ }
+
+ ICUNIT_GOTO_EQUAL(scandirCount1, scandirCount2, scandirCount2, EXIT);
+
+ fd = open(pathname1, O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ do {
+ ret = read(fd, filebuf, 1); // read length: 1
+ readCount++;
+ } while (ret == 1);
+
+ readCount--;
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(JFFS_MAIN_DIR0, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatfsPrintf(buf2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = statfs(JFFS_MAIN_DIR0, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatfsPrintf(buf3);
+
+ return JFFS_NO_ERROR;
+EXIT4:
+ free(bufW1);
+EXIT3:
+ free(bufW);
+ goto EXIT1;
+EXIT2:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ goto EXIT;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure028(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure028", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_029.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_029.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..96ecfff72fb38a54f332db4f4cf7944f7c64476b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_029.cpp
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, scandirCount1, scandirCount2;
+ INT64 i, j;
+ INT64 writeCount = 0;
+ INT64 readCount = 0;
+ INT64 perTime;
+ INT64 totalSize = 0;
+ INT64 totalTime = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ struct timeval testTime1;
+ struct timeval testTime2;
+ struct dirent **namelist = NULL;
+ DOUBLE mountSpeed;
+ struct statfs buf1 = { 0 };
+ struct statfs buf2 = { 0 };
+ struct statfs buf3 = { 0 };
+ off_t off;
+
+ INT32 bufWLen = BYTES_PER_MBYTE;
+ INT32 bufW1Len = 512 * BYTES_PER_KBYTE; // 512 KB
+ INT32 bufW2Len = 16 * BYTES_PER_KBYTE; // 16 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL(bufW, NULL, 0);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW1 = (CHAR *)malloc(bufW1Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW1, NULL, 0, EXIT2);
+ memset_s(bufW1, bufW1Len + 1, 0, bufW1Len + 1);
+
+ bufW2 = (CHAR *)malloc(bufW2Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW2, NULL, 0, EXIT3);
+ memset_s(bufW2, bufW2Len + 1, 0, bufW2Len + 1);
+
+ for (j = 0; j < bufW2Len / strlen(filebuf); j++) {
+ strcat_s(bufW2, bufW2Len + 1, filebuf);
+ }
+
+ for (j = 0; j < bufW1Len / bufW2Len; j++) {
+ strcat_s(bufW1, bufW1Len + 1, bufW2);
+ }
+
+ for (i = 0; i < bufWLen / bufW1Len; i++) {
+ strcat_s(bufW, bufWLen + 1, bufW1);
+ }
+ free(bufW1);
+ free(bufW2);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ while (writeCount < 100) { // loop times: 100
+ ret = write(fd, bufW, strlen(bufW));
+ dprintf("write_count=:%lld\n", writeCount);
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTE, ret, EXIT3);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, (BYTES_PER_MBYTE * (writeCount + 1)), off, EXIT1);
+
+ writeCount++;
+ }
+
+ free(bufW);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = statfs(JFFS_MAIN_DIR0, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatfsPrintf(buf3);
+
+ totalTime = 0;
+ totalSize = 0;
+
+ scandirCount1 = scandir(pathname2, &namelist, 0, alphasort);
+ if (scandirCount1 >= 0) {
+ JffsScandirFree(namelist, scandirCount1);
+ }
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ gettimeofday(&testTime1, 0);
+
+ ret = umount(pathname2);
+ if (ret != 0) {
+ dprintf("umount jffs is error\n");
+ goto EXIT2;
+ }
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ if (ret != 0) {
+ dprintf("mount jffs is error\n");
+ goto EXIT2;
+ }
+
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ dprintf("the size:%lld th,umount/mount cost %lld us \n", i, perTime);
+ }
+
+ totalSize = i;
+
+ mountSpeed = totalSize * 1.0;
+ mountSpeed = totalTime / mountSpeed;
+
+ dprintf("total_size %lld,cost %lld us, speed: %0.3lf us/Size\n", totalSize, totalTime, mountSpeed);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ scandirCount2 = scandir(pathname2, &namelist, 0, alphasort);
+ if (scandirCount2 >= 0) {
+ JffsScandirFree(namelist, scandirCount2);
+ }
+
+ ICUNIT_GOTO_EQUAL(scandirCount1, scandirCount2, scandirCount2, EXIT);
+
+ fd = open(pathname1, O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 100 * 1024 * 1024, off, EXIT1); // 100 * 1024 * 1024: filesize
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = statfs(JFFS_MAIN_DIR0, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatfsPrintf(buf2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = statfs(JFFS_MAIN_DIR0, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ JffsStatfsPrintf(buf3);
+
+ return JFFS_NO_ERROR;
+EXIT4:
+ free(bufW1);
+EXIT3:
+ free(bufW);
+ goto EXIT1;
+EXIT2:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ goto EXIT;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure029(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure029", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_030.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_030.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..af7a8247eefec59b06236ee56316e2b84d09da3d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_030.cpp
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ INT32 i = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ memset_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, pathname);
+ strcat_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, pathname);
+ strcat_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, "/");
+ strcat_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, "/");
+
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "AAAA%d", i);
+ strcat_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, bufname);
+
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "BBBB%d", i);
+ strcat_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, bufname);
+
+ ret = mkdir(g_jffsPathname11[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ ICUNIT_GOTO_NOT_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT); // even number: 2
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ ret = rmdir(g_jffsPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ return NULL;
+
+EXIT:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ rmdir(g_jffsPathname11[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 even = 2;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ for (i = 0; i < JFFS_MAXIMUM_OPERATIONS; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ if (i % even == 0) {
+ ret = rename(g_jffsPathname11[j], g_jffsPathname12[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ } else {
+ ret = rename(g_jffsPathname12[j], g_jffsPathname11[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ }
+ }
+
+ ICUNIT_GOTO_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT); // even number: 2
+
+ g_jffsFlagF02++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(2); // delay time: 2
+
+ return NULL;
+EXIT1:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ rmdir(g_jffsPathname12[i]);
+ }
+EXIT:
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ rmdir(g_jffsPathname11[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(10); // delay time: 10
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dprintf("\tjffs_flag:=%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure030(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure030", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_031.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_031.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0f576e65f82462ad6b946c813812c19dccf7f05b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_031.cpp
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 dirCount1 = 0;
+ INT32 dirCount2 = 0;
+ off_t off;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ memset_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, pathname1);
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ memset_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+
+ strcat_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcpy_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname6);
+
+ ret = mkdir(g_jffsPathname11[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dirCount1++;
+ }
+ ICUNIT_GOTO_EQUAL(dirCount1, JFFS_SHORT_ARRAY_LENGTH, dirCount1, EXIT);
+ ICUNIT_GOTO_NOT_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT); // even number: 2
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ len = read(g_jffsFd11[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+
+ len = write(g_jffsFd11[i], filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT);
+
+ len = read(g_jffsFd11[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+
+ off = lseek(g_jffsFd11[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT);
+
+ len = read(g_jffsFd11[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(3); // delay time: 3
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ ret = close(g_jffsFd11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(g_jffsPathname12[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(g_jffsPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ close(g_jffsFd11[i]);
+ unlink(g_jffsPathname12[i]);
+ }
+EXIT:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ rmdir(g_jffsPathname11[i]);
+ }
+ g_TestCnt++;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF02++;
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, g_jffsPathname11[i]);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, ".txt");
+ strcpy_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname7);
+
+ g_jffsFd11[i] = open(g_jffsPathname12[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT);
+ }
+
+ ICUNIT_GOTO_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT); // even number: 2
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(2); // delay time: 2
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ len = read(g_jffsFd11[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT);
+
+ off = lseek(g_jffsFd11[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT);
+
+ len = read(g_jffsFd11[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcdeabcde", readbuf, EXIT);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ LosTaskDelay(2); // delay time: 2
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ close(g_jffsFd11[i]);
+ unlink(g_jffsPathname12[i]);
+ }
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ g_TestCnt++;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ UINT64 start, end;
+ INT32 priority = 20;
+ INT32 testNum = 4;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ while (g_TestCnt != testNum) {
+ LosTaskDelay(1); // delay time: 1
+ }
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure031(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure031", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_032.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_032.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d10d8b3d704232f10321e23c5b348c24ee2767c9
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_032.cpp
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ INT32 fileCount1 = 0;
+ off_t off;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ memset_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, pathname1);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, bufname);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, ".txt");
+ strcpy_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname2);
+ g_jffsFd11[i] = open(g_jffsPathname12[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT1);
+
+ if (i % JFFS_SHORT_ARRAY_LENGTH == JFFS_SHORT_ARRAY_LENGTH - 1) {
+ for (k = (i / JFFS_SHORT_ARRAY_LENGTH) * JFFS_SHORT_ARRAY_LENGTH; k <= i; k++) {
+ ret = close(g_jffsFd11[k]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+ }
+ }
+
+ ICUNIT_GOTO_NOT_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT1); // even number: 2
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ g_jffsFd11[i] = open(g_jffsPathname12[i], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT1);
+
+ off = lseek(g_jffsFd11[i], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 1 * 1024, off, EXIT1); // file size: 1 * 1024
+
+ if (i % JFFS_SHORT_ARRAY_LENGTH == JFFS_SHORT_ARRAY_LENGTH - 1) {
+ for (k = (i / JFFS_SHORT_ARRAY_LENGTH) * JFFS_SHORT_ARRAY_LENGTH; k <= i; k++) {
+ ret = close(g_jffsFd11[k]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ }
+ }
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ ret = unlink(g_jffsPathname12[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ return NULL;
+EXIT1:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ close(g_jffsFd11[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ unlink(g_jffsPathname12[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd1, ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ INT32 fileCount2 = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR *bufW = NULL;
+ off_t off;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW, NULL, 0, EXIT1);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (j = 0; j < bufWLen / strlen(filebuf); j++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ g_jffsFd11[i] = open(g_jffsPathname12[i], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT2);
+
+ len = read(g_jffsFd11[i], readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(g_jffsFd11[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = write(g_jffsFd11[i], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT2);
+
+ if (i % JFFS_SHORT_ARRAY_LENGTH == JFFS_SHORT_ARRAY_LENGTH - 1) {
+ for (k = (i / JFFS_SHORT_ARRAY_LENGTH) * JFFS_SHORT_ARRAY_LENGTH; k <= i; k++) {
+ ret = close(g_jffsFd11[k]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+ }
+
+ ICUNIT_GOTO_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT2); // even number: 2
+
+ free(bufW);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(2); // delay time: 2
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ close(g_jffsFd11[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ unlink(g_jffsPathname12[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ UINT64 start, end;
+ INT32 priority = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure032(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure032", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_033.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_033.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e6e486aabe51220af9f02683a0802d5e9ce356be
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_033.cpp
@@ -0,0 +1,350 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+static INT32 g_testNum = 100;
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ off_t off;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[101] = "liteos";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 Start first get lock\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW, NULL, 0, EXIT2);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ memset_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, pathname1);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, bufname);
+ strcpy_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname2);
+ strcat_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, ".cpp");
+
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, ".txt");
+ strcpy_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname2);
+
+ g_jffsFd11[i] = open(g_jffsPathname12[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT3);
+ }
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ len = write(g_jffsFd11[i], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT3);
+ }
+
+ free(bufW);
+
+ ICUNIT_GOTO_NOT_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT2); // even number: 2
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(3); // delay time: 3
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 Start second get lock\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ ret = close(g_jffsFd11[i]);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ g_jffsFd11[i] = open(g_jffsPathname11[i], O_NONBLOCK | O_APPEND | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT2);
+ }
+ memset_s(writebuf, sizeof(writebuf), 0, strlen(writebuf));
+
+ for (i = 0; i < g_testNum; i++) {
+ strcat_s(writebuf, sizeof(writebuf), "a");
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ len = write(g_jffsFd11[j], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+ }
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(10); // delay time: 10
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 Start third get lock\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ errno = 0;
+ ret = unlink(g_jffsPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ return NULL;
+EXIT3:
+ free(bufW);
+EXIT2:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ close(g_jffsFd11[i]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ unlink(g_jffsPathname11[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ unlink(g_jffsPathname12[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd1, ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ UINT32 len;
+ INT32 fileCount2 = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR *bufR = NULL;
+ CHAR *bufW = NULL;
+ off_t off;
+ INT32 bufRSize = 6075; // 6075: read length
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 Start frist get lock\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ bufR = (CHAR *)malloc(BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufR, NULL, 0, EXIT3);
+ memset_s(bufR, BYTES_PER_KBYTE + 1, 0, BYTES_PER_KBYTE + 1);
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ len = read(g_jffsFd11[i], readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT3);
+
+ off = lseek(g_jffsFd11[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT3);
+
+ len = read(g_jffsFd11[i], bufR, BYTES_PER_KBYTE);
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT3);
+
+ ret = close(g_jffsFd11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ ret = rename(g_jffsPathname12[i], g_jffsPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ ICUNIT_GOTO_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT3); // even number: 2
+
+ free(bufR);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(5); // delay time: 5
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 Start second get lock\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ bufR = (CHAR *)malloc(bufRSize);
+ ICUNIT_TRACK_NOT_EQUAL(bufR, NULL, 0);
+ memset_s(bufR, bufRSize, 0, bufRSize);
+
+ for (i = 0; i < g_testNum; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ off = lseek(g_jffsFd11[j], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT3);
+
+ len = read(g_jffsFd11[j], bufR, bufRSize + 1);
+ ICUNIT_GOTO_EQUAL(len, bufRSize, len, EXIT3);
+ }
+ }
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ ret = close(g_jffsFd11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+ g_jffsFlagF02++;
+
+ ICUNIT_GOTO_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT3); // even number: 2
+
+ free(bufR);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(2); // delay time: 2
+
+ return NULL;
+EXIT3:
+ free(bufR);
+EXIT2:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ close(g_jffsFd11[i]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ unlink(g_jffsPathname11[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ unlink(g_jffsPathname12[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(100); // delay time: 100
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dprintf("\tjffs_flag:=%d\t", g_jffsFlag);
+ }
+
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure033(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure033", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_034.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_034.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e53c40e0655f0417c3cefd01e0e0dc07bad18765
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_034.cpp
@@ -0,0 +1,320 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+static INT32 g_testNum = 100;
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ off_t off;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[101] = "liteos";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW, NULL, 0, EXIT1);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ memset_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, pathname1);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, bufname);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, ".txt");
+ strcpy_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname2);
+
+ g_jffsFd11[i] = open(g_jffsPathname12[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT2);
+ }
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ len = write(g_jffsFd11[i], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT2);
+ }
+
+ ICUNIT_GOTO_NOT_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT2); // even number: 2
+
+ free(bufW);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ memset_s(writebuf, sizeof(writebuf), 0, strlen(writebuf));
+
+ for (i = 0; i < g_testNum; i++) {
+ strcat_s(writebuf, sizeof(writebuf), "a");
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ g_jffsFd11[j] = open(g_jffsPathname12[j], O_NONBLOCK | O_TRUNC | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[j], -1, g_jffsFd11[j], EXIT1);
+
+ len = write(g_jffsFd11[j], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = close(g_jffsFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ }
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(5); // delay time: 5
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ ret = unlink(g_jffsPathname12[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ close(g_jffsFd11[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ unlink(g_jffsPathname12[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd1, ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ UINT32 len;
+ INT32 fileCount2 = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[101] = "liteos";
+ CHAR *bufR = NULL;
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ bufR = (CHAR *)malloc(BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufR, NULL, 0, EXIT2);
+ memset_s(bufR, BYTES_PER_KBYTE + 1, 0, BYTES_PER_KBYTE + 1);
+
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ len = read(g_jffsFd11[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(g_jffsFd11[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(g_jffsFd11[i], bufR, BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT2);
+
+ ret = close(g_jffsFd11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_GOTO_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT2); // even number: 2
+
+ free(bufR);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < g_testNum; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ g_jffsFd11[j] = open(g_jffsPathname12[j], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[j], -1, g_jffsFd11[j], EXIT1);
+
+ off = lseek(g_jffsFd11[j], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(g_jffsFd11[j], readbuf, 101); // read length: 101
+ ICUNIT_GOTO_EQUAL(len, 100, len, EXIT1); // read length: 100
+ }
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ ret = close(g_jffsFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ }
+
+ g_jffsFlagF02++;
+
+ ICUNIT_GOTO_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT1); // even number: 2
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(2); // delay time: 2
+
+ return NULL;
+EXIT2:
+ free(bufR);
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(g_jffsFd11[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ unlink(g_jffsPathname12[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority1 = 18;
+ INT32 priority2 = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr1, priority1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(10); // delay time: 10
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dprintf("\tjffs_flag:=%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure034(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure034", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_035.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_035.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..118c2fb6b5dc0ea31331fe4b60d73c90d189dfe1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_035.cpp
@@ -0,0 +1,357 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+static INT32 g_testNum = 100;
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ off_t off;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[101] = "liteos";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "/storage/jffs_035";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufR = NULL;
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 Start get lock 1\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW, NULL, 0, EXIT2);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ strcat_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, pathname1);
+ strcat_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, bufname);
+ strcat_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, ".txt");
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, pathname2);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, bufname);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, ".txt");
+ strcpy_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname1);
+ strcpy_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname2);
+
+ g_jffsFd11[i] = open(g_jffsPathname12[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT3);
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ len = write(g_jffsFd11[i], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT3);
+ }
+
+ ICUNIT_GOTO_NOT_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT3); // even number: 2
+ free(bufW);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(3); // delay time: 3
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 Start get lock 2\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ memset_s(writebuf, sizeof(writebuf), 0, strlen(writebuf));
+
+ for (i = 0; i < g_testNum; i++) {
+ errno = 0;
+ strcat_s(writebuf, sizeof(writebuf), "a");
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ g_jffsFd11[j] = open(g_jffsPathname11[j], O_NONBLOCK | O_TRUNC | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[j], -1, g_jffsFd11[j], EXIT2);
+
+ len = write(g_jffsFd11[j], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ ret = close(g_jffsFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ }
+ }
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(15); // delay time: 15
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 Start get lock 3\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = unlink(g_jffsPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ g_jffsFlag++;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+ return NULL;
+EXIT3:
+ free(bufW);
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(g_jffsFd11[i]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ unlink(g_jffsPathname11[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ unlink(g_jffsPathname12[i]);
+ }
+ g_TestCnt = 0;
+ mkdir(pathname2, HIGHEST_AUTHORITY);
+ remove(pathname1);
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd1, ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ UINT32 len;
+ INT32 fileCount2 = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[101] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "/storage/jffs_035";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufR = NULL;
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 Start get lock 1\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF02++;
+
+ bufR = (CHAR *)malloc(BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufR, NULL, 0, EXIT3);
+ memset_s(bufR, BYTES_PER_KBYTE + 1, 0, BYTES_PER_KBYTE + 1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ len = read(g_jffsFd11[i], readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT3);
+
+ off = lseek(g_jffsFd11[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT3);
+
+ len = read(g_jffsFd11[i], bufR, BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT3);
+
+ ret = close(g_jffsFd11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = rename(pathname2, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ICUNIT_GOTO_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT3); // even number: 2
+ free(bufR);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(10); // delay time: 10
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 Start get lock 2\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < g_testNum; i++) {
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ errno = 0;
+ g_jffsFd11[j] = open(g_jffsPathname11[j], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[j], -1, g_jffsFd11[j], EXIT2);
+
+ off = lseek(g_jffsFd11[j], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = read(g_jffsFd11[j], readbuf, 101); // read length: 101
+ ICUNIT_GOTO_EQUAL(len, 100, len, EXIT2); // read length: 100
+
+ ret = close(g_jffsFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+ ICUNIT_GOTO_EQUAL((g_TestCnt % 2), 0, g_TestCnt, EXIT2); // even number: 2
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ return NULL;
+EXIT3:
+ free(bufR);
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(g_jffsFd11[i]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ unlink(g_jffsPathname11[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ unlink(g_jffsPathname12[i]);
+ }
+ g_TestCnt = 0;
+ remove(pathname1);
+ mkdir(pathname2, HIGHEST_AUTHORITY);
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+ void *tret = NULL;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(100); // delay time: 100
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dprintf("\tjffs_flag:=%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure035(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure035", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_036.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_036.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e06a69122e123a8d4a13b2a46c1e750ccb30a83c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_036.cpp
@@ -0,0 +1,369 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static CHAR g_jffs1647Pathname4[JFFS_SHORT_ARRAY_LENGTH][JFFS_MAXIMUM_SIZES][JFFS_STANDARD_NAME_LENGTH] = {0};
+static CHAR g_jffs1647Pathname5[JFFS_SHORT_ARRAY_LENGTH][JFFS_MAXIMUM_SIZES][JFFS_STANDARD_NAME_LENGTH] = {0};
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ off_t off;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876547210abcdeabcde0123456789abcedfghij9876547210abcdeabcde0123"
+ "456789abcedfghij9876547210abcdeabcde0123456789abcedfghij9876547210abcdeabcde0123456789abcedfgh"
+ "ij9876547210abcdeabcde0123456789abcedfghij9876547210lalalalalalalala";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufR = NULL;
+ CHAR *bufW = NULL;
+ INT32 bufLen = BYTES_PER_KBYTE;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ memset_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ strcat_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, pathname1);
+ strcat_s(g_jffsPathname1, JFFS_STANDARD_NAME_LENGTH, bufname);
+ strcpy_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname1);
+
+ ret = mkdir(g_jffsPathname11[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ bufW = (CHAR *)malloc(bufLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW, NULL, 0, EXIT3);
+ memset_s(bufW, bufLen + 1, 0, bufLen + 1);
+
+ for (i = 0; i < bufLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufLen + 1, filebuf);
+ }
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ g_jffsFd12[i][j] = open(g_jffs1647Pathname4[i][j], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd12[i][j], -1, g_jffsFd12[i][j], EXIT4);
+
+ len = write(g_jffsFd12[i][j], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT4);
+
+ ret = close(g_jffsFd12[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+ }
+ }
+
+ free(bufW);
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(5); // delay time: 5
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ bufR = (CHAR *)malloc(bufLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufR, NULL, 0, EXIT3);
+ memset_s(bufR, bufLen + 1, 0, bufLen + 1);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ g_jffsFd12[i][j] = open(g_jffs1647Pathname5[i][j], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd12[i][j], -1, g_jffsFd12[i][j], EXIT5);
+
+ off = lseek(g_jffsFd12[i][j], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT5);
+
+ len = read(g_jffsFd12[i][j], bufR, bufLen + 1);
+ ICUNIT_GOTO_EQUAL(len, bufLen, len, EXIT5);
+
+ ret = close(g_jffsFd12[i][k]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+ }
+ }
+
+ free(bufR);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ ret = remove(g_jffsPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+ g_jffsFlag++;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ return NULL;
+EXIT5:
+ free(bufR);
+ goto EXIT3;
+EXIT4:
+ free(bufW);
+EXIT3:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ close(g_jffsFd12[i][j]);
+ }
+ }
+EXIT2:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ unlink(g_jffs1647Pathname5[i][j]);
+ }
+ }
+EXIT1:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ unlink(g_jffs1647Pathname4[i][j]);
+ }
+ }
+EXIT:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ remove(g_jffsPathname11[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd1, ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ UINT32 len;
+ INT32 fileCount2 = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ memset_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(g_jffs1647Pathname4[i][j], JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(g_jffs1647Pathname5[i][j], JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", j);
+ strcat_s(g_jffsPathname2, JFFS_NAME_LIMITTED_SIZE, g_jffsPathname11[i]);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, bufname);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, ".txt");
+ strcpy_s(g_jffs1647Pathname4[i][j], JFFS_STANDARD_NAME_LENGTH, g_jffsPathname2);
+
+ memset_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ strcat_s(g_jffsPathname2, JFFS_NAME_LIMITTED_SIZE, g_jffsPathname11[i]);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, bufname);
+ strcat_s(g_jffsPathname2, JFFS_STANDARD_NAME_LENGTH, ".cpp");
+ strcpy_s(g_jffs1647Pathname5[i][j], JFFS_STANDARD_NAME_LENGTH, g_jffsPathname2);
+
+ g_jffsFd12[i][j] = open(g_jffs1647Pathname4[i][j], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL,
+ HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd12[i][j], -1, g_jffsFd12[i][j], EXIT1);
+
+ ret = close(g_jffsFd12[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ }
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ ret = rename(g_jffs1647Pathname4[i][j], g_jffs1647Pathname5[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ ret = unlink(g_jffs1647Pathname5[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+ g_jffsFlagF02++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ return NULL;
+EXIT3:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ close(g_jffsFd12[i][j]);
+ }
+ }
+EXIT2:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ unlink(g_jffs1647Pathname5[i][j]);
+ }
+ }
+EXIT1:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ unlink(g_jffs1647Pathname4[i][j]);
+ }
+ }
+EXIT:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ remove(g_jffsPathname11[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure036(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure036", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_037.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_037.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ebd5783107c83e7841134ed0b88ac6ff38996986
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_037.cpp
@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static CHAR g_jffs1648Pathname4[5][JFFS_MAXIMUM_SIZES][JFFS_NAME_LIMITTED_SIZE] = {0};
+static CHAR g_jffs1648Pathname5[5][JFFS_MAXIMUM_SIZES][JFFS_NAME_LIMITTED_SIZE] = {0};
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ off_t off;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876548210abcdeabcde0123456789abcedfghij9876548210abcdeabcde0123"
+ "456789abcedfghij9876548210abcdeabcde0123456789abcedfghij9876548210abcdeabcde0123456789abcedfgh"
+ "ij9876548210abcdeabcde0123456789abcedfghij9876548210lalalalalalalala";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufR = NULL;
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ memset_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, pathname1);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+ memset_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ strcat_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcpy_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname6);
+
+ ret = mkdir(g_jffsPathname11[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW, NULL, 0, EXIT2);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ g_jffsFd12[i][j] = open(g_jffs1648Pathname4[i][j], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd12[i][j], -1, g_jffsFd12[i][j], EXIT3);
+
+ len = write(g_jffsFd12[i][j], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT3);
+
+ ret = close(g_jffsFd12[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ }
+ }
+ free(bufW);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(5); // delay time: 5
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ bufR = (CHAR *)malloc(BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufR, NULL, 0, EXIT2);
+ memset_s(bufR, BYTES_PER_KBYTE + 1, 0, BYTES_PER_KBYTE + 1);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ g_jffsFd12[i][j] = open(g_jffs1648Pathname5[i][j], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd12[i][j], -1, g_jffsFd12[i][j], EXIT4);
+
+ off = lseek(g_jffsFd12[i][j], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT4);
+
+ len = read(g_jffsFd12[i][j], bufR, BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT4);
+
+ ret = close(g_jffsFd12[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+ }
+ }
+
+ free(bufR);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = JFFS_MAX_CYCLES - 1; i >= 0; i--) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ ret = unlink(g_jffs1648Pathname5[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+ ret = remove(g_jffsPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ return NULL;
+EXIT4:
+ free(bufR);
+ goto EXIT2;
+EXIT3:
+ free(bufW);
+EXIT2:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ close(g_jffsFd12[i][j]);
+ }
+ }
+EXIT1:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ unlink(g_jffs1648Pathname4[i][j]);
+ }
+ }
+EXIT:
+ for (i = JFFS_MAX_CYCLES - 1; i >= 0; i--) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ unlink(g_jffs1648Pathname5[i][j]);
+ }
+ remove(g_jffsPathname11[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd1, ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ UINT32 len;
+ INT32 fileCount2 = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876548210abcdeabcde0123456789abcedfghij9876548210abcdeabcde0123"
+ "456789abcedfghij9876548210abcdeabcde0123456789abcedfghij9876548210abcdeabcde0123456789abcedfgh"
+ "ij9876548210abcdeabcde0123456789abcedfghij9876548210lalalalalalalala";
+ CHAR readbuf[101] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF02++;
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ memset_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname8, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffs1648Pathname4[i][j], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffs1648Pathname5[i][j], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", j);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, g_jffsPathname11[i]);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, ".txt");
+ strcpy_s(g_jffs1648Pathname4[i][j], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname7);
+
+ strcat_s(g_jffsPathname8, JFFS_NAME_LIMITTED_SIZE, g_jffsPathname11[i]);
+ strcat_s(g_jffsPathname8, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcat_s(g_jffsPathname8, JFFS_NAME_LIMITTED_SIZE, ".cpp");
+ strcpy_s(g_jffs1648Pathname5[i][j], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname8);
+ g_jffsFd12[i][j] = open(g_jffs1648Pathname4[i][j], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL,
+ HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd12[i][j], -1, g_jffsFd12[i][j], EXIT2);
+
+ ret = close(g_jffsFd12[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+ }
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ ret = rename(g_jffs1648Pathname4[i][j], g_jffs1648Pathname5[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ }
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(2); // delay time: 2
+
+ return NULL;
+EXIT2:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ close(g_jffsFd12[i][j]);
+ }
+ }
+EXIT1:
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ unlink(g_jffs1648Pathname4[i][j]);
+ }
+ }
+EXIT:
+ for (i = JFFS_MAX_CYCLES - 1; i >= 0; i--) {
+ for (j = 0; j < JFFS_MAXIMUM_SIZES; j++) {
+ unlink(g_jffs1648Pathname5[i][j]);
+ }
+ remove(g_jffsPathname11[i]);
+ }
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority1 = 18;
+ INT32 priority2 = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr1, priority1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(10); // delay time: 10
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure037(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure037", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_038.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_038.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..df343bf1f0a3c66e38d67701ee711d24d9f6b062
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_038.cpp
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ off_t off;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876549210abcdeabcde0123456789abcedfghij9876549210abcdeabcde0123"
+ "456789abcedfghij9876549210abcdeabcde0123456789abcedfghij9876549210abcdeabcde0123456789abcedfgh"
+ "ij9876549210abcdeabcde0123456789abcedfghij9876549210lalalalalalalala";
+ CHAR writebuf[200] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ memset_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, pathname1);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, pathname1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+ memset_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname13[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ strcat_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcpy_s(g_jffsPathname13[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname6);
+
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, "A");
+ strcpy_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname7);
+
+ if (i == 0) {
+ strcpy_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname12[i]);
+ } else {
+ strcpy_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname13[i]);
+ strcat_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, "A");
+ }
+
+ ret = mkdir(g_jffsPathname13[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = rmdir(g_jffsPathname13[i]);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH - 1; i++) {
+ ret = rmdir(g_jffsPathname12[i]);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ ret = rmdir(g_jffsPathname12[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ return NULL;
+EXIT1:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ remove(g_jffsPathname12[i]);
+ remove(g_jffsPathname13[i]);
+ }
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd1, ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ UINT32 len;
+ INT32 dirCount2 = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876549210abcdeabcde0123456789abcedfghij9876549210abcdeabcde0123"
+ "456789abcedfghij9876549210abcdeabcde0123456789abcedfghij9876549210abcdeabcde0123456789abcedfgh"
+ "ij9876549210abcdeabcde0123456789abcedfghij9876549210lalalalalalalala";
+ CHAR readbuf[101] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF02++;
+
+ for (j = JFFS_SHORT_ARRAY_LENGTH - 1; j >= 0; j--) {
+ ret = rename(g_jffsPathname13[j], g_jffsPathname11[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ return NULL;
+
+EXIT:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ remove(g_jffsPathname12[i]);
+ remove(g_jffsPathname13[i]);
+ }
+ remove(JFFS_PATH_NAME0);
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(1); // delay time: 1
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure038(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure038", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_039.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_039.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4d00a1f0124d243177673c2aeeeca033c577ae37
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_039.cpp
@@ -0,0 +1,360 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static CHAR g_jffs1650Pathname4[JFFS_SHORT_ARRAY_LENGTH][JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+static CHAR g_jffs1650Pathname5[JFFS_SHORT_ARRAY_LENGTH][JFFS_SHORT_ARRAY_LENGTH][JFFS_NAME_LIMITTED_SIZE] = {0};
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ off_t off;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR writebuf[200] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufR = NULL;
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 Start get lock 1\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ memset_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, pathname1);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ memset_s(g_jffs1650Pathname4[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffs1650Pathname5[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ strcat_s(g_jffsPathname6, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcpy_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname6);
+
+ ret = mkdir(g_jffsPathname11[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ memset_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", j);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, g_jffsPathname6);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, ".txt");
+ strcpy_s(g_jffs1650Pathname4[i][j], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname7);
+
+ memset_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, g_jffsPathname6);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcat_s(g_jffsPathname7, JFFS_NAME_LIMITTED_SIZE, ".cpp");
+ strcpy_s(g_jffs1650Pathname5[i][j], JFFS_NAME_LIMITTED_SIZE, g_jffsPathname7);
+
+ g_jffsFd12[i][j] = open(g_jffs1650Pathname4[i][j], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL,
+ HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd12[i][j], -1, g_jffsFd12[i][j], EXIT1);
+
+ ret = close(g_jffsFd12[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 Start get lock 2\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ bufR = (CHAR *)malloc(BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufR, NULL, 0, EXIT1);
+ memset_s(bufR, BYTES_PER_KBYTE + 1, 0, BYTES_PER_KBYTE + 1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ g_jffsFd12[i][j] = open(g_jffs1650Pathname4[i][j], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd12[i][j], -1, g_jffsFd12[i][j], EXIT2);
+
+ len = read(g_jffsFd12[i][j], bufR, BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT2);
+
+ ret = close(g_jffsFd12[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+
+ free(bufR);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 Start get lock 3\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ return NULL;
+EXIT2:
+ free(bufR);
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ close(g_jffsFd12[i][j]);
+ }
+ }
+EXIT:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ for (j = JFFS_SHORT_ARRAY_LENGTH - 1; j >= 0; j--) {
+ remove(g_jffs1650Pathname4[i][j]);
+ remove(g_jffs1650Pathname5[i][j]);
+ }
+
+ remove(g_jffsPathname11[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd1, ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ UINT32 len;
+ INT32 fileCount2 = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR readbuf[101] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 Start get lock 1\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW, NULL, 0, EXIT1);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (j = 0; j < bufWLen / strlen(filebuf); j++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ g_jffsFd12[i][j] = open(g_jffs1650Pathname4[i][j], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd12[i][j], -1, g_jffsFd12[i][j], EXIT2);
+
+ len = write(g_jffsFd12[i][j], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT2);
+
+ ret = close(g_jffsFd12[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ }
+ free(bufW);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 Start get lock 2\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ ret = rename(g_jffs1650Pathname4[i][j], g_jffs1650Pathname5[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ }
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 Start get lock 3\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ for (j = JFFS_SHORT_ARRAY_LENGTH - 1; j >= 0; j--) {
+ ret = remove(g_jffs1650Pathname5[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ ret = remove(g_jffsPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+ g_jffsFlagF02++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(2); // delay time: 2
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ close(g_jffsFd12[i][j]);
+ }
+ }
+EXIT:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ for (j = JFFS_SHORT_ARRAY_LENGTH - 1; j >= 0; j--) {
+ remove(g_jffs1650Pathname4[i][j]);
+ remove(g_jffs1650Pathname5[i][j]);
+ }
+ remove(g_jffsPathname11[i]);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 fd[JFFS_SHORT_ARRAY_LENGTH];
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(10); // delay time: 10
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure039(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure039", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_040.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_040.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..27585e105ef42f51b2d2351df4784229198abf6d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_040.cpp
@@ -0,0 +1,341 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ INT32 dirCount = 0;
+ INT32 dirCount1 = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufR = NULL;
+ CHAR *bufW = NULL;
+ INT32 bufLen = 2 * BYTES_PER_KBYTE; // 2 KB
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, pathname);
+ strcat_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, pathname);
+ strcat_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, "/");
+ strcat_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, "/");
+
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "AAAA%d", i);
+ strcat_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, bufname);
+
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "BBBB%d", i);
+ strcat_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, bufname);
+
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "%d", i);
+ strcat_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcat_s(g_jffsPathname12[i], JFFS_NAME_LIMITTED_SIZE, bufname);
+
+ g_jffsFd11[i] = open(g_jffsPathname11[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT);
+
+ ret = close(g_jffsFd11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ bufR = (CHAR *)malloc(bufLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufR, NULL, 0, EXIT2);
+ memset_s(bufR, bufLen + 1, 0, bufLen + 1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ g_jffsFd11[i] = open(g_jffsPathname11[i], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT3);
+
+ ret = read(g_jffsFd11[i], bufR, bufLen + 1);
+ ICUNIT_GOTO_EQUAL(ret, bufLen, ret, EXIT3);
+
+ ret = close(g_jffsFd11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+ free(bufR);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ bufR = (CHAR *)malloc(bufLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufR, NULL, 0, EXIT2);
+ memset_s(bufR, bufLen + 1, 0, bufLen + 1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ g_jffsFd11[i] = open(g_jffsPathname11[i], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT3);
+
+ ret = read(g_jffsFd11[i], bufR, bufLen);
+ ICUNIT_GOTO_EQUAL(ret, bufLen, ret, EXIT3);
+
+ ret = close(g_jffsFd11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ free(bufR);
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ return NULL;
+EXIT3:
+ free(bufR);
+EXIT2:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ close(g_jffsFd11[i]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ remove(g_jffsPathname12[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ remove(g_jffsPathname11[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 dirCount = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = 2 * BYTES_PER_KBYTE; // 2 KB
+
+ g_TestCnt++;
+ g_jffsFlagF02++;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW, NULL, 0, EXIT2);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ g_jffsFd11[i] = open(g_jffsPathname11[i], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[i], -1, g_jffsFd11[i], EXIT3);
+
+ len = write(g_jffsFd11[i], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT3);
+
+ ret = close(g_jffsFd11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+ free(bufW);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ for (j = 0; j < JFFS_SHORT_ARRAY_LENGTH; j++) {
+ if (j % 2 == 0) { // even number: 2
+ ret = rename(g_jffsPathname11[i], g_jffsPathname12[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ } else {
+ ret = rename(g_jffsPathname12[i], g_jffsPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ }
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(2); // delay time: 2
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = remove(g_jffsPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ return NULL;
+EXIT3:
+ free(bufW);
+EXIT2:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ close(g_jffsFd11[i]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ remove(g_jffsPathname12[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_MAXIMUM_SIZES; i++) {
+ remove(g_jffsPathname11[i]);
+ }
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(1); // delay time: 1
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dprintf("\tjffs_flag:=%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure040(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure040", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_041.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_041.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f1feef741a785029600c2eeb2072e1fa238ba9ec
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_041.cpp
@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ INT32 dirCount1 = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ off_t off;
+ INT32 fileNum = 4;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 first get lock\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ for (j = 0; j < fileNum; j++) {
+ memset_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname13[j], JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", j);
+ strcat_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, pathname);
+ strcat_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, pathname);
+ strcat_s(g_jffsPathname13[j], JFFS_NAME_LIMITTED_SIZE, pathname);
+
+ strcat_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcat_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcat_s(g_jffsPathname13[j], JFFS_NAME_LIMITTED_SIZE, bufname);
+
+ strcat_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, ".txt");
+ strcat_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, ".cpp");
+ strcat_s(g_jffsPathname13[j], JFFS_NAME_LIMITTED_SIZE, ".jpg");
+
+ g_jffsFd11[j] = open(g_jffsPathname11[j], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[j], -1, g_jffsFd11[j], EXIT2);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(3); // delay time: 3
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 second get lock\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ for (j = 0; j < fileNum; j++) {
+ errno = 0;
+ off = lseek(g_jffsFd11[j], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 1 * 1024, off, EXIT2); // file size: 1 * 1024
+ }
+
+ for (j = 0; j < fileNum; j++) {
+ ret = close(g_jffsFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ }
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < JFFS_MAXIMUM_OPERATIONS; j++) {
+ ret = umount(JFFS_MAIN_DIR0);
+ printf("[%d] umount:%s,\n", __LINE__, JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ printf("[%d] mount:%s,\n", __LINE__, JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+ }
+ ret = chdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(3); // delay time: 3
+ printf("[%d] Thread1 Start third get lock\n", __LINE__);
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 third get lock\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < JFFS_MAXIMUM_OPERATIONS; j++) {
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+ }
+
+ ret = chdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < fileNum; j++) {
+ ret = access(g_jffsPathname13[j], F_OK);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+ }
+
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ return NULL;
+EXIT3:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT2:
+ for (j = 0; j < fileNum; j++) {
+ close(g_jffsFd11[j]);
+ }
+EXIT1:
+ for (j = 0; j < fileNum; j++) {
+ remove(g_jffsPathname11[j]);
+ remove(g_jffsPathname12[j]);
+ remove(g_jffsPathname13[j]);
+ }
+EXIT:
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 fileCount = 0;
+ UINT64 len;
+ CHAR bufname[15] = "01234567890";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufR[JFFS_SHORT_ARRAY_LENGTH] = "abcde";
+ CHAR writebuf[JFFS_SHORT_ARRAY_LENGTH] = "a";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufW = NULL;
+ off_t off;
+ INT32 fileNum = 4;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 first get lock\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW, NULL, 0, EXIT2);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (j = 0; j < fileNum; j++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ g_TestCnt++;
+
+ for (j = 0; j < fileNum; j++) {
+ len = write(g_jffsFd11[j], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT3);
+ }
+
+ free(bufW);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 second get lock\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ for (j = 0; j < fileNum; j++) {
+ errno = 0;
+ ret = rename(g_jffsPathname11[j], g_jffsPathname12[j]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ }
+
+ for (j = 0; j < fileNum; j++) {
+ ret = rename(g_jffsPathname12[j], g_jffsPathname13[j]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 third get lock\n", __LINE__);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ for (j = 0; j < fileNum; j++) {
+ g_jffsFd11[j] = open(g_jffsPathname13[j], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[j], -1, g_jffsFd11[j], EXIT2);
+ }
+
+ for (j = 0; j < fileNum; j++) {
+ off = lseek(g_jffsFd11[j], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 1 * 1024, off, EXIT2); // file size: 1 * 1024
+ }
+
+ for (j = 0; j < fileNum; j++) {
+ ret = close(g_jffsFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = unlink(g_jffsPathname13[j]);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+ }
+
+ g_jffsFlagF02++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ return NULL;
+EXIT3:
+ free(bufW);
+EXIT2:
+ for (j = 0; j < fileNum; j++) {
+ close(g_jffsFd11[j]);
+ }
+EXIT1:
+ for (j = 0; j < fileNum; j++) {
+ remove(g_jffsPathname11[j]);
+ remove(g_jffsPathname12[j]);
+ remove(g_jffsPathname13[j]);
+ }
+EXIT:
+ g_TestCnt = 0;
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufW1 = NULL;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(50); // delay time: 50
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
+
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
+
+ return LOS_OK;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return LOS_OK;
+}
+
+VOID ItFsJffsPressure041(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure041", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_042.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_042.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e21cc5f1b48f829ffed714d0dcaab96c9eb0c397
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_042.cpp
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "/storage/jffs_042";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ off_t off;
+ INT32 fileNum = 4;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ for (j = 0; j < fileNum; j++) {
+ memset_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", j);
+ strcat_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, pathname);
+ strcat_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ strcat_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcat_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, bufname);
+
+ strcat_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, ".txt");
+ strcat_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, ".txt");
+
+ g_jffsFd11[j] = open(g_jffsPathname11[j], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[j], -1, g_jffsFd11[j], EXIT2);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(3); // delay time: 3
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ printf("[%d] Thread1 second Get lock \n", __LINE__);
+
+ for (j = 0; j < fileNum; j++) {
+ off = lseek(g_jffsFd11[j], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 1 * 1024, off, EXIT2); // file size: 1 * 1024
+ }
+
+ for (j = 0; j < fileNum; j++) {
+ ret = close(g_jffsFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < JFFS_MAXIMUM_OPERATIONS; j++) {
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(3); // delay time: 3
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ printf("[%d] Thread1 third Get lock \n", __LINE__);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < JFFS_MAXIMUM_OPERATIONS; j++) {
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ for (j = 0; j < fileNum; j++) {
+ ret = access(g_jffsPathname12[j], F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ return NULL;
+EXIT3:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT2:
+ for (j = 0; j < fileNum; j++) {
+ close(g_jffsFd11[j]);
+ }
+EXIT1:
+ for (j = 0; j < fileNum; j++) {
+ remove(g_jffsPathname11[j]);
+ remove(g_jffsPathname12[j]);
+ }
+EXIT:
+ g_TestCnt = 0;
+ remove(pathname2);
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR bufname[15] = "01234567890";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "/storage/jffs_042";
+ CHAR bufR[JFFS_SHORT_ARRAY_LENGTH] = "abcde";
+ CHAR writebuf[JFFS_SHORT_ARRAY_LENGTH] = "a";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufW = NULL;
+ off_t off;
+ INT32 fileNum = 4;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW, NULL, 0, EXIT2);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (j = 0; j < bufWLen / strlen(filebuf); j++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ g_TestCnt++;
+
+ for (j = 0; j < fileNum; j++) {
+ len = write(g_jffsFd11[j], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT3);
+ }
+
+ free(bufW);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ printf("[%d] Thread2 second Get lock \n", __LINE__);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ printf("[%d] Thread2 third Get lock \n", __LINE__);
+ for (j = 0; j < fileNum; j++) {
+ g_jffsFd11[j] = open(g_jffsPathname12[j], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[j], -1, g_jffsFd11[j], EXIT2);
+ }
+
+ for (j = 0; j < fileNum; j++) {
+ off = lseek(g_jffsFd11[j], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, BYTES_PER_KBYTE, off, EXIT2);
+ }
+
+ for (j = 0; j < fileNum; j++) {
+ ret = close(g_jffsFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(g_jffsPathname12[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ g_jffsFlagF02++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ return NULL;
+EXIT3:
+ free(bufW);
+EXIT2:
+ for (j = 0; j < fileNum; j++) {
+ close(g_jffsFd11[j]);
+ }
+EXIT1:
+ for (j = 0; j < fileNum; j++) {
+ remove(g_jffsPathname11[j]);
+ remove(g_jffsPathname12[j]);
+ }
+EXIT:
+ g_TestCnt = 0;
+ remove(pathname2);
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufW1 = NULL;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(10); // delay time: 10
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure042(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure042", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_043.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_043.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b8793e248894467eb879f62564b9b5b15f7f2ed7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_043.cpp
@@ -0,0 +1,408 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf1[JFFS_STANDARD_NAME_LENGTH] = "0123456789LLLLLL";
+ CHAR filebuf2[JFFS_STANDARD_NAME_LENGTH] = "aaaaaaaaaaaaaaaa";
+ CHAR filebuf3[JFFS_STANDARD_NAME_LENGTH] = "BBBBBBBBBBBBBBBB";
+ CHAR *bufR1 = NULL;
+ CHAR *bufR2 = NULL;
+ CHAR *bufR3 = NULL;
+ off_t off;
+ INT32 fileNum = 3;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ g_jffsFlagF01++;
+
+ for (j = 0; j < fileNum; j++) {
+ memset_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", j);
+ strcat_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, pathname);
+ strcat_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, pathname2);
+
+ strcat_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, bufname);
+ strcat_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, bufname);
+
+ strcat_s(g_jffsPathname11[j], JFFS_NAME_LIMITTED_SIZE, ".txt");
+ strcat_s(g_jffsPathname12[j], JFFS_NAME_LIMITTED_SIZE, ".cpp");
+
+ g_jffsFd11[j] = open(g_jffsPathname11[j], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[j], -1, g_jffsFd11[j], EXIT2);
+ }
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread1 Second Get lock,ret:%d \n", __LINE__, ret);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ bufR1 = (CHAR *)malloc(BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufR1, NULL, 0, EXIT2);
+ memset_s(bufR1, BYTES_PER_KBYTE + 1, 0, BYTES_PER_KBYTE + 1);
+
+ bufR2 = (CHAR *)malloc(BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufR2, NULL, 0, EXIT3);
+ memset_s(bufR2, BYTES_PER_KBYTE + 1, 0, BYTES_PER_KBYTE + 1);
+
+ bufR3 = (CHAR *)malloc(BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufR3, NULL, 0, EXIT4);
+ memset_s(bufR3, BYTES_PER_KBYTE + 1, 0, BYTES_PER_KBYTE + 1);
+
+ for (j = 0; j < fileNum; j++) {
+ off = lseek(g_jffsFd11[j], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, BYTES_PER_KBYTE, off, EXIT5);
+ }
+
+ for (j = 0; j < fileNum; j++) {
+ off = lseek(g_jffsFd11[j], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT5);
+ }
+
+ j = 0;
+ len = read(g_jffsFd11[j], bufR1, BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT5);
+
+ j++;
+ len = read(g_jffsFd11[j], bufR2, BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT5);
+
+ j++;
+ len = read(g_jffsFd11[j], bufR3, BYTES_PER_KBYTE + 1);
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT5);
+
+ for (j = 0; j < fileNum; j++) {
+ ret = close(g_jffsFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+ }
+
+ for (j = 0; j < fileNum; j++) {
+ g_jffsFd11[j] = open(g_jffsPathname11[j], O_NONBLOCK | O_TRUNC | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[j], -1, g_jffsFd11[j], EXIT5);
+ }
+
+ j = 0;
+ len = write(g_jffsFd11[j], bufR2, strlen(bufR2));
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT5);
+
+ j++;
+ len = write(g_jffsFd11[j], bufR3, strlen(bufR3));
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT5);
+
+ j++;
+ len = write(g_jffsFd11[j], bufR1, strlen(bufR1));
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTE, len, EXIT5);
+
+ for (j = 0; j < fileNum; j++) {
+ ret = close(g_jffsFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT5);
+ }
+
+ free(bufR1);
+ free(bufR2);
+ free(bufR3);
+
+ g_jffsFlag++;
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(4); // delay time: 4
+
+ return NULL;
+EXIT5:
+ free(bufR3);
+EXIT4:
+ free(bufR2);
+EXIT3:
+ free(bufR1);
+EXIT2:
+ for (j = 0; j < fileNum; j++) {
+ close(g_jffsFd11[j]);
+ }
+EXIT1:
+ for (j = 0; j < fileNum; j++) {
+ remove(g_jffsPathname11[j]);
+ remove(g_jffsPathname12[j]);
+ }
+EXIT:
+ g_TestCnt = 0;
+ remove(pathname2);
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR bufname[15] = "01234567890";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf1[JFFS_STANDARD_NAME_LENGTH] = "0123456789LLLLLL";
+ CHAR filebuf2[JFFS_STANDARD_NAME_LENGTH] = "aaaaaaaaaaaaaaaa";
+ CHAR filebuf3[JFFS_STANDARD_NAME_LENGTH] = "BBBBBBBBBBBBBBBB";
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ CHAR *bufW3 = NULL;
+ off_t off;
+ INT32 bufWLen = BYTES_PER_KBYTE;
+ INT32 fileNum = 3;
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 First Get lock,ret:%d \n", __LINE__, ret);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ g_TestCnt++;
+
+ bufW1 = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW1, NULL, 0, EXIT2);
+ memset_s(bufW1, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW2 = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW2, NULL, 0, EXIT3);
+ memset_s(bufW2, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW3 = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW3, NULL, 0, EXIT4);
+ memset_s(bufW3, bufWLen + 1, 0, bufWLen + 1);
+
+ for (j = 0; j < bufWLen / strlen(filebuf1); j++) {
+ strcat_s(bufW1, bufWLen + 1, filebuf1);
+ strcat_s(bufW2, bufWLen + 1, filebuf2);
+ strcat_s(bufW3, bufWLen + 1, filebuf3);
+ }
+
+ j = 0;
+ ret = write(g_jffsFd11[j], bufW1, strlen(bufW1));
+ ICUNIT_GOTO_EQUAL(ret, strlen(bufW1), ret, EXIT5);
+
+ j++;
+ ret = write(g_jffsFd11[j], bufW2, strlen(bufW2));
+ ICUNIT_GOTO_EQUAL(ret, strlen(bufW2), ret, EXIT5);
+
+ j++;
+ ret = write(g_jffsFd11[j], bufW3, strlen(bufW3));
+ ICUNIT_GOTO_EQUAL(ret, strlen(bufW3), ret, EXIT5);
+
+ free(bufW1);
+ free(bufW2);
+ free(bufW3);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(10); // delay time: 10
+
+ ret = pthread_mutex_lock(&g_jffs2GlobalLock1);
+ printf("[%d] Thread2 Second Get lock,ret:%d \n", __LINE__, ret);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < fileNum; j++) {
+ ret = rename(g_jffsPathname11[j], g_jffsPathname12[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT7);
+
+ for (j = 0; j < JFFS_MAXIMUM_OPERATIONS; j++) {
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT7);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT7);
+ }
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < fileNum; j++) {
+ g_jffsFd11[j] = open(g_jffsPathname12[j], O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd11[j], -1, g_jffsFd11[j], EXIT2);
+ }
+
+ for (j = 0; j < fileNum; j++) {
+ off = lseek(g_jffsFd11[j], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 1 * 1024, off, EXIT2); // file size: 1 * 1024
+ }
+
+ for (j = 0; j < fileNum; j++) {
+ ret = close(g_jffsFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(g_jffsPathname12[j]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ g_jffsFlagF02++;
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+
+ LosTaskDelay(2); // delay time: 2
+
+ return NULL;
+EXIT7:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, "vfat", 0, NULL);
+ goto EXIT2;
+EXIT5:
+ free(bufW3);
+EXIT4:
+ free(bufW2);
+EXIT3:
+ free(bufW1);
+EXIT2:
+ for (j = 0; j < fileNum; j++) {
+ close(g_jffsFd11[j]);
+ }
+EXIT1:
+ for (j = 0; j < fileNum; j++) {
+ remove(g_jffsPathname11[j]);
+ remove(g_jffsPathname12[j]);
+ }
+EXIT:
+ g_TestCnt = 0;
+ remove(pathname2);
+ (void)pthread_mutex_unlock(&g_jffs2GlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufW1 = NULL;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+
+ g_jffsFlag = 0;
+ g_jffsFlagF01 = 0;
+ g_jffsFlagF02 = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ while ((g_jffsFlag < JFFS_PRESSURE_CYCLES) && (g_jffsFlag == g_jffsFlagF01)) {
+ g_TestCnt = 0;
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(10); // delay time: 10
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure043(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure043", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_044.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_044.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..66974199ccd340c55c11a0a4131747d893297c29
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_044.cpp
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "a";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "LLLLLLLLLL";
+ off_t off;
+
+ g_TestCnt++;
+
+ fd = open(pathname, O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT);
+
+ off = lseek(fd, -10, SEEK_END); // seek offset: -10
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT);
+
+EXIT:
+ close(fd);
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "a";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+
+ g_TestCnt++;
+
+ fd = open(pathname, O_RDONLY, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT);
+
+EXIT:
+ g_TestCnt++;
+ close(fd);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "a";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+ INT32 testNum = 4;
+
+ g_jffsFlag = 0;
+
+ ret = access(pathname, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ while (g_jffsFlag < JFFS_PRESSURE_CYCLES) {
+ g_TestCnt = 0;
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT3);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT3);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT3);
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ while (g_TestCnt != testNum) {
+ LosTaskDelay(1); // delay time: 1
+ }
+
+ g_jffsFlag++;
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(fd);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure044(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure044", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_045.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_045.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6ce4488b66850b4c814f95df3c1d705e1ac4aa32
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_045.cpp
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ g_TestCnt++;
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT);
+
+ sleep(2); // sleep time: 2
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ return NULL;
+
+EXIT:
+ closedir(dir);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ g_TestCnt++;
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT);
+
+ sleep(3); // sleep time: 3
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+ return NULL;
+
+EXIT:
+ closedir(dir);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+ INT32 testNum = 4;
+
+ g_jffsFlag = 0;
+
+ ret = access(pathname, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ while (g_jffsFlag < JFFS_PRESSURE_CYCLES) {
+ g_TestCnt = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ while (g_TestCnt != testNum) {
+ LosTaskDelay(1); // delay time: 1
+ }
+
+ g_jffsFlag++;
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure045(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure045", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_046.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_046.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f2434ba222b99358f2382955e78d5d85c1a44c05
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_046.cpp
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "a";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "LLLLLLLLLL";
+ off_t off = 0;
+
+ g_TestCnt++;
+
+ len = write(g_jffsFd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT);
+
+ off = lseek(g_jffsFd, -10, SEEK_END); // seek offset: -10
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT); // file position: 10
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(g_jffsFd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT);
+
+ g_TestCnt++;
+
+ return NULL;
+
+EXIT:
+ close(g_jffsFd);
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret, len;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "a";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "AAAAAAAAAA";
+ off_t off = 0;
+
+ g_TestCnt++;
+
+ off = lseek(g_jffsFd, -10, SEEK_END); // seek offset: -10
+ ICUNIT_GOTO_EQUAL(off, 10, off, EXIT); // file position: 10
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(g_jffsFd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT); // file size: 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "LLLLLLLLLL", readbuf, EXIT);
+
+ len = write(g_jffsFd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT);
+
+ off = lseek(g_jffsFd, -10, SEEK_END); // seek offset: -10
+ ICUNIT_GOTO_EQUAL(off, 20, off, EXIT); // file position: 20
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(g_jffsFd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT); // file size: 10
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT);
+
+ g_TestCnt++;
+
+ return NULL;
+
+EXIT:
+ close(g_jffsFd);
+ g_TestCnt++;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "a";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ pthread_t newTh1, newTh2;
+ pthread_attr_t attr1, attr2;
+ INT32 priority = 20;
+ INT32 testNum = 4;
+
+ g_jffsFlag = 0;
+
+ ret = access(pathname, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ while (g_jffsFlag < JFFS_PRESSURE_CYCLES) {
+ g_TestCnt = 0;
+
+ g_jffsFd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd, JFFS_IS_ERROR, g_jffsFd, EXIT3);
+
+ len = write(g_jffsFd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT3);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(g_jffsFd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT3);
+
+ ret = PosixPthreadInit(&attr1, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ while (g_TestCnt != testNum) {
+ LosTaskDelay(1); // delay time: 1
+ }
+
+ g_jffsFlag++;
+
+ ret = close(g_jffsFd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadDestroy(&attr2, newTh2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newTh1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("\tjffs_flag=:%d\t", g_jffsFlag);
+ }
+ dprintf("\n");
+
+ ICUNIT_GOTO_EQUAL(g_jffsFlag, JFFS_PRESSURE_CYCLES, g_jffsFlag, EXIT2);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ close(g_jffsFd);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newTh2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure046(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure046", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_047.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_047.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..10c0ebb0c5a18e3eaa47fbad3b76521ba0f92e16
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_047.cpp
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ UINT32 writeSize = JFFS_PRESSURE_W_R_SIZE2;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR *writeBuf = NULL;
+ struct stat64 statbuf1;
+ off64_t off64;
+
+ writeBuf = (CHAR *)malloc(writeSize);
+ ICUNIT_GOTO_NOT_EQUAL(writeBuf, NULL, writeBuf, EXIT);
+ memset_s(writeBuf, writeSize, 0x61, writeSize);
+
+ g_jffsFd = open64(pathname1, O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd, JFFS_IS_ERROR, g_jffsFd, EXIT1);
+
+ while (1) {
+ ret = write(g_jffsFd, writeBuf, writeSize);
+ printf("[%d]write_size: %d write ret:%d Fd:%d \n", __LINE__, writeSize, ret, g_jffsFd);
+ if (ret <= 0) {
+ break;
+ }
+ g_TestCnt++;
+ dprintf("write 5M date %d times\n", g_TestCnt);
+ }
+
+ ret = stat64(pathname1, &statbuf1);
+ printf("[%d]stat64 ret:%d Fd:%d \n", __LINE__, ret, g_jffsFd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ off64 = lseek64(g_jffsFd, 0, SEEK_END);
+ printf("[%d]lseek64 off64:%lld Fd:%d \n", __LINE__, off64, g_jffsFd);
+ ICUNIT_GOTO_EQUAL(statbuf1.st_size, off64, statbuf1.st_size, EXIT1);
+
+ len = write(g_jffsFd, writebuf, strlen(writebuf));
+ printf("[%d]lseek64 len:%d Fd:%d, errno:%d\n", __LINE__, len, g_jffsFd, errno);
+ ICUNIT_GOTO_EQUAL(len, JFFS_IS_ERROR, len, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOSPC, errno, EXIT1);
+
+ off64 = lseek64(g_jffsFd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(statbuf1.st_size, off64, statbuf1.st_size, EXIT1);
+
+ off64 = lseek64(g_jffsFd, -10, SEEK_END); // seek offset: -10
+ ICUNIT_GOTO_EQUAL(off64, statbuf1.st_size - 10, off64, EXIT1);
+
+ ret = close(g_jffsFd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ free(writeBuf);
+
+ return NULL;
+EXIT1:
+ close(g_jffsFd);
+EXIT:
+ free(writeBuf);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len, i;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off64_t off64;
+ pthread_t newTh1;
+ pthread_attr_t attr1;
+ struct stat64 statbuf1;
+ struct stat64 statbuf2;
+
+ g_TestCnt = 0;
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ g_jffsFd = open64(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd, JFFS_IS_ERROR, g_jffsFd, EXIT2);
+
+ len = read(g_jffsFd, readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ ret = close(g_jffsFd);
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT2);
+
+ ret = PosixPthreadInit(&attr1, TASK_PRIO_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_join(newTh1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = close(g_jffsFd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+
+ ret = pthread_attr_destroy(&attr1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat64(pathname1, &statbuf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_PRESSURE_CYCLES; i++) {
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ errno = 0;
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat64(pathname1, &statbuf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(statbuf2.st_size, statbuf1.st_size, statbuf2.st_size, EXIT);
+ dprintf("\tcycle=:%d\t", i);
+ }
+
+ g_jffsFd = open64(pathname1, O_RDONLY | O_APPEND, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd, JFFS_IS_ERROR, g_jffsFd, EXIT2);
+
+ off64 = lseek64(g_jffsFd, -10, SEEK_END); // seek offset: -10
+ ICUNIT_GOTO_EQUAL(off64, statbuf1.st_size - 10, off64, EXIT);
+
+ len = read(g_jffsFd, readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2);
+
+ ret = close(g_jffsFd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ goto EXIT;
+EXIT2:
+ close(g_jffsFd);
+ goto EXIT;
+EXIT1:
+ pthread_join(newTh1, NULL);
+ pthread_attr_destroy(&attr1);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure047(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure047", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_048.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_048.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4aa29943923a975e1d358b106695c7fe481c0c94
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_048.cpp
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "";
+ struct stat statbuf1;
+ struct stat statbuf2;
+
+ g_TestCnt = 0;
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(pathname1, &statbuf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(statbuf1.st_size, 0, statbuf1.st_size, EXIT);
+ JffsStatPrintf(statbuf1);
+
+ while (i < 1024) { // loop times: 1024
+ errno = 0;
+ memset_s(bufname, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(pathname3, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ snprintf_s(bufname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/_%d", i);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, pathname2);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, bufname);
+
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ printf("[%d]open cycle:%d name :%s, fd:%d, errno:%d\n", __LINE__, i, pathname3, fd, errno);
+ if (fd == JFFS_IS_ERROR) {
+ dprintf("Open the files is the moust:=%d\n", i);
+ break;
+ }
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ }
+
+ for (k = 0; k < JFFS_MAXIMUM_OPERATIONS; k++) {
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = stat(pathname1, &statbuf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(statbuf2.st_size, statbuf1.st_size, statbuf2.st_size, EXIT1);
+
+ for (j = 0; j < i; j++) {
+ memset_s(bufname, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(pathname3, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ snprintf_s(bufname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/_%d", j);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, pathname2);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, bufname);
+
+ ret = remove(pathname3);
+ printf("[%d] cycle:%d remove name :%s, errno:%d\n", __LINE__, j, pathname3, errno);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(pathname2, &statbuf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT1:
+ close(fd);
+ for (j = 0; j < i; j++) {
+ memset_s(bufname, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(pathname3, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ snprintf_s(bufname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/_%d", j);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, pathname2);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, bufname);
+
+ remove(pathname3);
+ }
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure048(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure048", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_049.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_049.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cafd78dcc7aaf90b8217ecfef609c49b61f414b1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_049.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = "";
+ struct stat statbuf1;
+ struct stat statbuf2;
+
+ g_TestCnt = 0;
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = stat(pathname1, &statbuf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(statbuf1.st_size, 0, statbuf1.st_size, EXIT);
+
+ while (i < 100) { // loop times: 100
+ memset_s(bufname, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(pathname3, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ snprintf_s(bufname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/_%d", i);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, pathname2);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, bufname);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ printf("[%d]mkdir cycle:%d name: %s, errno:%d\n", __LINE__, i, pathname3, errno);
+ if (ret == -1) {
+ break;
+ }
+
+ i++;
+ }
+
+ for (k = 0; k < JFFS_MAXIMUM_OPERATIONS; k++) {
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = stat(pathname1, &statbuf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(statbuf2.st_size, statbuf1.st_size, statbuf2.st_size, EXIT1);
+
+ for (j = 0; j < i; j++) {
+ errno = 0;
+ memset_s(bufname, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(pathname3, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ snprintf_s(bufname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/_%d", j);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, pathname2);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, bufname);
+
+ ret = remove(pathname3);
+ printf("[%d]remove cycle:%d name: %s, errno:%d\n", __LINE__, j, pathname3, errno);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = stat(pathname1, &statbuf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(statbuf2.st_size, statbuf1.st_size, statbuf2.st_size, EXIT);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT1:
+ for (j = 0; j < i; j++) {
+ memset_s(bufname, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ memset_s(pathname3, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ snprintf_s(bufname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/_%d", j);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, pathname2);
+ strcat_s(pathname3, JFFS_STANDARD_NAME_LENGTH, bufname);
+
+ remove(pathname3);
+ }
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure049(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure049", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_050.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_050.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..33ef4046b0ab0568f12a412fea7606f11e501065
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_050.cpp
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR *writeBuf = NULL;
+ UINT32 writeSize = JFFS_PRESSURE_W_R_SIZE1;
+
+ writeBuf = (CHAR *)malloc(writeSize);
+ ICUNIT_GOTO_NOT_EQUAL(writeBuf, NULL, writeBuf, EXIT);
+ memset_s(writeBuf, writeSize, (0x61 + (INT32)(INTPTR)arg), writeSize);
+
+ fd = open64(g_jffsPathname11[(INT32)(INTPTR)arg], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ dprintf("(INT32)(INTPTR)arg=:%d,jffs_pathname11=:%s\n", (INT32)(INTPTR)arg, g_jffsPathname11[(INT32)(INTPTR)arg]);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+
+ while (1) {
+ ret = write(fd, writeBuf, writeSize);
+ if (ret <= 0) {
+ break;
+ }
+ }
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_IS_ERROR, len, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOSPC, errno, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ free(writeBuf);
+
+ return NULL;
+EXIT1:
+ close(fd);
+EXIT:
+ free(writeBuf);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len, i;
+ INT32 fd = -1;
+ UINT64 toatlSize1, toatlSize2;
+ UINT64 freeSize1, freeSize2;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off64_t off64;
+ pthread_attr_t attr;
+ pthread_t threadId[JFFS_THREAD_NUM_TEST];
+ struct statfs statfsbuf1;
+ struct statfs statfsbuf2;
+ struct stat64 statbuf;
+
+ for (i = 0; i < JFFS_THREAD_NUM_TEST; i++) {
+ memset_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(bufname, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ snprintf_s(bufname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "_%d", i);
+ strcat_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, pathname2);
+ strcat_s(g_jffsPathname11[i], JFFS_NAME_LIMITTED_SIZE, bufname);
+ }
+
+ g_TestCnt = 0;
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = statfs(pathname1, &statfsbuf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ toatlSize1 = (UINT64)statfsbuf1.f_bsize * statfsbuf1.f_blocks;
+ freeSize1 = (UINT64)statfsbuf1.f_bsize * statfsbuf1.f_bfree;
+
+ ret = PosixPthreadInit(&attr, TASK_PRIO_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_THREAD_NUM_TEST; i++) {
+ ret = pthread_create(&threadId[i], &attr, PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_THREAD_NUM_TEST; i++) {
+ pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAXIMUM_OPERATIONS; i++) {
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ for (i = 0; i < JFFS_THREAD_NUM_TEST; i++) {
+ fd = open64(g_jffsPathname11[i], O_RDONLY | O_APPEND, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ ret = stat64(g_jffsPathname11[i], &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ off64 = lseek64(fd, -10, SEEK_END); // seek offset: -10
+ ICUNIT_GOTO_EQUAL(off64, statbuf.st_size - 10, off64, EXIT);
+
+ memset_s(readbuf, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = remove(g_jffsPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ ret = statfs(pathname1, &statfsbuf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ toatlSize2 = (UINT64)statfsbuf2.f_bsize * statfsbuf2.f_blocks;
+ freeSize2 = (UINT64)statfsbuf2.f_bsize * statfsbuf2.f_bfree;
+ ICUNIT_GOTO_EQUAL(toatlSize1, toatlSize2, toatlSize1, EXIT);
+ ICUNIT_GOTO_NOT_EQUAL(freeSize1, freeSize2, freeSize1, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ mount(JFFS_DEV_PATH0, JFFS_MOUNT_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ goto EXIT;
+EXIT2:
+ close(fd);
+ goto EXIT;
+EXIT1:
+ for (i = 0; i < JFFS_THREAD_NUM_TEST; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ pthread_attr_destroy(&attr);
+EXIT:
+ for (i = 0; i < JFFS_THREAD_NUM_TEST; i++) {
+ remove(g_jffsPathname11[i]);
+ }
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure050(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure050", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_051.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_051.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..114919434f35ad563e624c629a3b12274cfcdd4c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_051.cpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len, i;
+ INT32 fd = -1;
+ INT64 total = 0;
+ INT64 perTime;
+ INT64 totalSize = 0;
+ INT64 totalTime = 0;
+ INT32 cycleCount = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR *writeBuf = NULL;
+ UINT32 writeSize = JFFS_PRESSURE_W_R_SIZE1;
+ DOUBLE testSpeed;
+ CHAR *pid = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ writeBuf = (CHAR *)malloc(writeSize);
+ ICUNIT_GOTO_NOT_EQUAL(writeBuf, NULL, writeBuf, EXIT);
+
+ gettimeofday(&testTime1, 0);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+ dprintf("\n open %s,task %lld ms,\n", pathname1, perTime / MSECS_PER_SEC);
+
+ gettimeofday(&testTime1, 0);
+
+ while (1) {
+ len = write(fd, writeBuf, writeSize);
+ if (len <= 0) {
+ break;
+ }
+ g_TestCnt++;
+
+ total += len;
+ totalSize += len;
+ if (total >= JFFS_WR_CAP_SIZE_TEST) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+
+ dprintf("%d time write, write %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n", cycleCount++, total,
+ perTime, testSpeed);
+
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+ dprintf("\n total write=%lld, time=%lld,arv speed =%0.3lfMB/s,\n", totalSize, totalTime, testSpeed);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_IS_ERROR, len, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOSPC, errno, EXIT1);
+
+ gettimeofday(&testTime1, 0);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ dprintf("\n sucess to fclose the %s,task:%lld ms,\n", pathname1, perTime / MSECS_PER_SEC);
+
+ free(writeBuf);
+
+ return NULL;
+EXIT1:
+ close(fd);
+EXIT:
+ free(writeBuf);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_t newTh1;
+ pthread_attr_t attr1;
+
+ g_TestCnt = 0;
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = PosixPthreadInit(&attr1, TASK_PRIO_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_join(newTh1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_attr_destroy(&attr1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ PosixPthreadDestroy(&attr1, newTh1);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure051(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure051", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_052.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_052.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..06ea0f943eea204db1571276e3b52844a9e5e1f2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_052.cpp
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static CHAR *g_writeBuf = NULL;
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 len, taskId;
+ INT64 total = 0;
+ INT64 perTime;
+ INT64 totalSize = 0;
+ INT64 totalTime = 0;
+ INT32 cycleCount = 0;
+ UINT32 writeSize = JFFS_PRESSURE_W_R_SIZE1;
+ DOUBLE testSpeed;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ INT32 testNum = 4 * 1024 / 5; // 4 * 1024 / 5: test number
+
+ taskId = (UINT32)(UINTPTR)arg;
+
+ gettimeofday(&testTime1, 0);
+
+ while (1) {
+ len = write(g_jffsFd, g_writeBuf, writeSize);
+ if (len <= 0) {
+ if (g_TestCnt < testNum) {
+ dprintf("\n TaskID:%3d, The biggest file size is smaller than the 4GB", taskId);
+ goto EXIT;
+ }
+ dprintf("\n TaskID:%3d, The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB", taskId, g_TestCnt,
+ g_TestCnt * 5, (g_TestCnt * 5) * 1.0 / BYTES_PER_KBYTE); // file size per test: 5 MB
+
+ break;
+ }
+ g_TestCnt++;
+
+ total += len;
+ totalSize += len;
+ if (total >= JFFS_WR_CAP_SIZE_TEST) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+
+ dprintf("TaskID:%3d, %d time write, write %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n", taskId,
+ cycleCount++, total, perTime, testSpeed);
+
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+ dprintf("\n TaskID:%3d,total write=%lld, time=%lld,arv speed =%0.3lfMB/s,\n", taskId, totalSize, totalTime,
+ testSpeed);
+
+ return NULL;
+EXIT:
+ close(g_jffsFd);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len, i, j;
+ UINT64 toatlSize1, toatlSize2;
+ UINT64 freeSize1, freeSize2;
+ UINT32 writeSize = JFFS_PRESSURE_W_R_SIZE1;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ off64_t off64;
+ pthread_t threadId[JFFS_THREAD_NUM_TEST];
+ pthread_attr_t attr;
+ struct statfs statfsbuf1;
+ struct statfs statfsbuf2;
+ struct stat64 statbuf;
+
+ g_TestCnt = 0;
+
+ g_writeBuf = (CHAR *)malloc(writeSize);
+ ICUNIT_GOTO_NOT_EQUAL(g_writeBuf, NULL, g_writeBuf, EXIT);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ g_jffsFd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd, JFFS_IS_ERROR, g_jffsFd, EXIT1);
+
+ ret = statfs(pathname1, &statfsbuf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ toatlSize1 = (UINT64)statfsbuf1.f_bsize * statfsbuf1.f_blocks;
+ freeSize1 = (UINT64)statfsbuf1.f_bsize * statfsbuf1.f_bfree;
+
+ ret = PosixPthreadInit(&attr, TASK_PRIO_TEST2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (i = 0; i < JFFS_THREAD_NUM_TEST; i++) {
+ ret = pthread_create(&threadId[i], &attr, PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (j = 0; j < JFFS_THREAD_NUM_TEST; j++) {
+ pthread_join(threadId[j], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat64(pathname1, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ off64 = lseek64(g_jffsFd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off64, statbuf.st_size, off64, EXIT1);
+
+ ret = close(g_jffsFd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &statfsbuf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ toatlSize2 = (UINT64)statfsbuf2.f_bsize * statfsbuf2.f_blocks;
+ freeSize2 = (UINT64)statfsbuf2.f_bsize * statfsbuf2.f_bfree;
+
+ ICUNIT_GOTO_EQUAL(toatlSize1, toatlSize2, toatlSize1, EXIT);
+ ICUNIT_GOTO_EQUAL(((statfsbuf1.f_bfree - statfsbuf2.f_bfree) >= 0), TRUE, (statfsbuf1.f_bfree - statfsbuf2.f_bfree),
+ EXIT);
+
+ free(g_writeBuf);
+ g_writeBuf = NULL;
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (j = 0; j < JFFS_THREAD_NUM_TEST; j++) {
+ pthread_join(threadId[i], NULL);
+ }
+ pthread_attr_destroy(&attr);
+EXIT1:
+ close(g_jffsFd);
+ remove(pathname1);
+EXIT:
+ free(g_writeBuf);
+ g_writeBuf = NULL;
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure052(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure052", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_053.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_053.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..42adb7ae62a7ef7272bd89a2bccf7358457c9dba
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_053.cpp
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static CHAR *g_writeBuf = NULL;
+static CHAR* g_readBuf[3] = {};
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret, len, taskId;
+ INT32 fd = -1;
+ INT64 total = 0;
+ INT64 perTime;
+ INT64 totalSize = 0;
+ INT64 totalTime = 0;
+ INT32 cycleCount = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ UINT32 writeSize = JFFS_PRESSURE_W_R_SIZE1;
+ UINT32 readSize = JFFS_PRESSURE_W_R_SIZE1;
+ DOUBLE testSpeed;
+ CHAR *pid = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ time_t tTime;
+ struct tm *pstTM = NULL;
+ INT32 testNum = 4 * 1024; // 4 * 1024: test number
+
+ g_TestCnt++;
+
+ time(&tTime);
+ pstTM = localtime(&tTime);
+ memset_s(g_jffsPathname4, JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ strftime(g_jffsPathname4, JFFS_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", pstTM);
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/%s_#%d", g_jffsPathname4,
+ (INT32)(INTPTR)arg);
+
+ snprintf_s(g_jffsPathname4, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "testfile#%d",
+ (INT32)(INTPTR)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_jffsPathname4, 0, 0, 0);
+
+ taskId = strlen(pathname1);
+ pid = pathname1 + taskId - 1;
+ taskId = atoi(pid);
+
+ gettimeofday(&testTime1, 0);
+
+ fd = open(pathname1, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ dprintf("\n Task_%d fail to open %s,\n", taskId, pathname1);
+ goto EXIT1;
+ }
+
+ LosTaskDelay(5); // delay time: 5
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+ dprintf("\n TaskID:%3d,open %s,task %lld ms,\n", taskId, pathname1, perTime / MSECS_PER_SEC);
+
+ gettimeofday(&testTime1, 0);
+
+ while (1) {
+ len = write(fd, g_writeBuf, writeSize);
+ if (len <= 0) {
+ if (g_TestCnt < testNum) {
+ dprintf("\n TaskID:%3d, The biggest file size is smaller than the 4GB", taskId);
+ goto EXIT1;
+ }
+ dprintf("\n TaskID:%3d, The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB", taskId, g_TestCnt,
+ g_TestCnt, g_TestCnt / BYTES_PER_MBYTE);
+
+ break;
+ }
+
+ g_TestCnt++;
+
+ total += len;
+ totalSize += len;
+ if (total >= JFFS_WR_CAP_SIZE_TEST) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+
+ dprintf("TaskID:%3d, %d time write, write %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n", taskId,
+ cycleCount++, total, perTime, testSpeed);
+
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+ dprintf("\n TaskID:%3d,total write=%lld, time=%lld,arv speed =%0.3lfMB/s,\n", taskId, totalSize, totalTime,
+ testSpeed);
+
+ gettimeofday(&testTime1, 0);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ dprintf("\n TaskID:%3d,sucess to fclose the %s,task:%lld ms,\n", taskId, pathname1, perTime / MSECS_PER_SEC);
+
+ gettimeofday(&testTime1, 0);
+
+ fd = open(pathname1, O_RDWR, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ dprintf("Task_%d fail to open %s,\n", taskId, pathname1);
+ goto EXIT1;
+ }
+
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ dprintf(" fix_Read TaskID:%3d,open %s, task:%lld ms,\n", taskId, pathname1, perTime / MSECS_PER_SEC);
+
+ gettimeofday(&testTime1, 0);
+
+ while (1) {
+ ret = read(fd, g_readBuf[(INT32)(INTPTR)arg], readSize);
+ if (ret < 0) {
+ dprintf("ret = %d,%s read fail!-->(X),\n", ret, pathname1);
+ goto EXIT1;
+ }
+ if (!ret) {
+ dprintf("warning: read ret = %d, errno=:%d\n", ret, errno);
+ goto EXIT1;
+ }
+ total += ret;
+ totalSize += ret;
+
+ if (total >= JFFS_WR_CAP_SIZE_TEST) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+
+ dprintf("fix_Read TaskID:%3d,times %d, read %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n", taskId,
+ cycleCount++, total, perTime, testSpeed);
+
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+ dprintf("\n fix_Read TaskID:%3d,total read=%lld, time=%lld,arv speed =%0.3lfMB/s,\n", taskId, totalSize, totalTime,
+ testSpeed);
+
+ gettimeofday(&testTime1, 0);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ dprintf("fix_Read TaskID:%3d, fclose %s!,task:%lld ms,\n", taskId, pathname1, perTime / MSECS_PER_SEC);
+
+ return NULL;
+
+EXIT1:
+ close(fd);
+ remove(pathname1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i, j;
+ pthread_t threadId[JFFS_THREAD_NUM_TEST];
+ pthread_attr_t attr;
+ UINT32 writeSize = JFFS_PRESSURE_W_R_SIZE1;
+ UINT32 readSize = JFFS_PRESSURE_W_R_SIZE1;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 priority = 4;
+
+ g_TestCnt = 0;
+
+ g_writeBuf = (CHAR *)malloc(writeSize + 1);
+ ICUNIT_GOTO_NOT_EQUAL(g_writeBuf, NULL, g_writeBuf, EXIT0);
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ g_readBuf[i] = (CHAR *)malloc(readSize + 1);
+ ICUNIT_GOTO_NOT_EQUAL(g_readBuf[i], NULL, g_readBuf[i], EXIT0);
+ }
+ ret = PosixPthreadInit(&attr, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_THREAD_NUM_TEST; i++) {
+ ret = pthread_create(&threadId[i], &attr, PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ while (g_TestCnt < JFFS_THREAD_NUM_TEST * 2) { // thread cnts: JFFS_THREAD_NUM_TEST * 2
+ sleep(1);
+ }
+
+ for (i = 0; i < JFFS_THREAD_NUM_TEST; i++) {
+ pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ for (i = 0; i < JFFS_THREAD_NUM_TEST; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+EXIT:
+ pthread_attr_destroy(&attr);
+EXIT0:
+ free(g_writeBuf);
+ g_writeBuf = NULL;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ free(g_readBuf[i]);
+ g_readBuf[i] = NULL;
+ }
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure053(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure053", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_301.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_301.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..18802a109ef8235ccc269736ea22a0ebe8bafbba
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_301.cpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct stat buf3 = { 0 };
+ INT32 n = 103;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(buffile, sizeof(buffile), "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ while (n--) {
+ len = write(fd, "0123456789012345678901234567890123456789", 40); // write length: 40
+ ICUNIT_GOTO_EQUAL(len, 40, len, EXIT3);
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_blocks, buf2.st_blocks, buf1.st_blocks, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_size, buf2.st_size, buf1.st_size, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_blksize, buf2.st_blksize, buf1.st_blksize, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_ino, buf2.st_ino, buf1.st_ino, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_mode, buf2.st_mode, buf1.st_mode, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_mtim.tv_nsec, buf2.st_mtim.tv_nsec, buf1.st_mtim.tv_nsec, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(buffile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/files", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure301(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure301", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_302.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_302.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a2ae5e2a3dda9bb7576cf33c502747f5f088aaaf
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_302.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd = -1;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct stat buf3 = { 0 };
+ INT32 n = 256;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, sizeof(pathname1), "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat_s(buffile, sizeof(buffile), "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ while (n--) {
+ len = write(fd, "01234567890123456789012345", 16); // write length: 16
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT3);
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_size, buf2.st_size, buf1.st_size, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_blksize, buf2.st_blksize, buf1.st_blksize, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(buffile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/files", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure302(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure302", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_303.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_303.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..017804e99300af08be8dea8fbe6e9a37e8618316
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_303.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ INT32 i = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_MIDDLE_ARRAY_LENGTH][JFFS_STANDARD_NAME_LENGTH] = {JFFS_PATH_NAME0};
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ DIR *dir = NULL;
+ DIR *dir1[JFFS_MIDDLE_ARRAY_LENGTH] = {NULL};
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ for (i = 0; i < JFFS_MIDDLE_ARRAY_LENGTH; i++) {
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ memset_s(pathname2[i], JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ JffsStrcat2(pathname2[i], bufname, strlen(bufname));
+
+ ret = mkdir(pathname2[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < JFFS_MIDDLE_ARRAY_LENGTH; i++) {
+ dir1[i] = opendir(pathname2[i]);
+ ICUNIT_GOTO_NOT_EQUAL(dir1[i], NULL, dir1[i], EXIT3);
+ }
+
+ for (i = 0; i < JFFS_MIDDLE_ARRAY_LENGTH; i++) {
+ ret = closedir(dir1[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ for (i = 0; i < JFFS_MIDDLE_ARRAY_LENGTH; i++) {
+ ret = remove(pathname2[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ for (i = 0; i < JFFS_MIDDLE_ARRAY_LENGTH; i++) {
+ closedir(dir1[i]);
+ }
+EXIT2:
+ for (i = 0; i < JFFS_MIDDLE_ARRAY_LENGTH; i++) {
+ remove(pathname2[i]);
+ }
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure303(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure303", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_304.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_304.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3c8a4e03beca902394c1217b8f8cd99fa529bbe1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_304.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *argument)
+{
+ INT32 len;
+ INT32 n = 1000;
+
+ g_TestCnt++;
+ while (n--) {
+ len = write(g_jffsFd,
+ "1234567890123456789012345678901234567890abcdefghjk12345678901234567890123456789012345678901234567890123456"
+ "7890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ 200); // write length: 200
+ ICUNIT_GOTO_EQUAL(len, 200, len, EXIT);
+ if (g_TestCnt == 2) { // test number: 2
+ break;
+ }
+ }
+ g_TestCnt++;
+
+ return (void *)0;
+
+EXIT:
+ g_TestCnt = 0;
+ return (void *)0;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ pthread_t newTh;
+ pthread_attr_t attr;
+ CHAR readbuf[201] = {0};
+ off_t off;
+ INT32 priority = 4;
+ INT32 testNum = 2;
+
+ g_TestCnt = 0;
+ g_jffsFd = open(pathname, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(g_jffsFd, -1, g_jffsFd, EXIT1);
+
+ ret = PosixPthreadInit(&attr, priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newTh, &attr, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ while (g_TestCnt < testNum) {
+ LosTaskDelay(1); // delay time: 1
+ }
+ g_TestCnt++;
+
+ off = lseek(g_jffsFd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT2);
+
+ len = read(g_jffsFd, readbuf, 200); // read length: 200
+ ICUNIT_GOTO_EQUAL(len, 200, len, EXIT2);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf,
+ "1234567890123456789012345678901234567890abcdefghjk123456789012345678901234567890123456789012345678901234567890"
+ "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ readbuf, EXIT2);
+
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 3, g_TestCnt, EXIT2); // 3: test num
+
+ ret = PosixPthreadDestroy(&attr, newTh);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = close(g_jffsFd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ PosixPthreadDestroy(&attr, newTh);
+EXIT1:
+ close(g_jffsFd);
+EXIT:
+ remove(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure304(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure304", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_305.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_305.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a6370e2c8ba47f5053b72263de9e1b48089fc9bb
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_305.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ INT32 i = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ DIR *dir1[JFFS_MIDDLE_ARRAY_LENGTH] = {NULL};
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ while (i < JFFS_MIDDLE_ARRAY_LENGTH) {
+ dir1[i] = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir1[i], NULL, dir1[i], EXIT1);
+
+ i++;
+ }
+ for (i = 0; i < JFFS_MIDDLE_ARRAY_LENGTH; i++) {
+ ret = closedir(dir1[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ return JFFS_NO_ERROR;
+EXIT1:
+ closedir(dir);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure305(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure305", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_306.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_306.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..92e60605d7e09b540e9ca9ebea45daa78c2ab539
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_306.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i, j;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[300] = { JFFS_PATH_NAME0 };
+ CHAR bufname[10] = "";
+ CHAR pathname2[10][300] = {0};
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(bufname, sizeof(bufname), 0, strlen(bufname));
+ snprintf_s(bufname, sizeof(bufname), sizeof(bufname) - 1, "/test_%d", i);
+ strcat_s(pathname1, sizeof(pathname1), bufname);
+ strcpy_s(pathname2[i], sizeof(pathname2[i]), pathname1);
+
+ ret = mkdir(pathname2[i], HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH - 1; i++) {
+ ret = rmdir(pathname2[i]);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ }
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ ret = rmdir(pathname2[i]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ }
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ for (i = JFFS_SHORT_ARRAY_LENGTH - 1; i >= 0; i--) {
+ rmdir(pathname2[i]);
+ }
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure306(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure306", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_307.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_307.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ea7e3718f1643d3f2edf1adf77c1cf4c304bbabe
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_307.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 fd[JFFS_NAME_LIMITTED_SIZE] = { 0 };
+ INT32 i = 0;
+ INT32 fileCount = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE][JFFS_STANDARD_NAME_LENGTH] = {JFFS_PATH_NAME0};
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ DIR *dir = NULL;
+ struct inode *node = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_NAME_LIMITTED_SIZE; i++) {
+ errno = 0;
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ memset_s(pathname2[i], JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/test%d", i);
+ JffsStrcat2(pathname2[i], bufname, strlen(bufname));
+
+ // system has 512 fd,when start testsuits_app,has open 11 file,
+ // so current usersapce only has 500 file counts,and its value is dynamic
+ // when it failed,please adapt it.
+ if (fileCount == 500) { // max file counts: 500
+ fd[i] = open(pathname2[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd[i], -1, fd[i], EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EMFILE, errno, EXIT3);
+ break;
+ }
+ fd[i] = open(pathname2[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT3);
+ fileCount = i;
+ }
+
+ for (i = 0; i < JFFS_NAME_LIMITTED_SIZE; i++) {
+ if (i > fileCount) {
+ ret = close(fd[i]);
+ printf("[%d] close: fd:%d, errno:%d,ret:%d,i:%d,\n", __LINE__, fd[i], errno, ret, i);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT3);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT3);
+ break;
+ }
+ ret = close(fd[i]);
+ printf("[%d] close: fd:%d, errno:%d,ret:%d,i:%d\n", __LINE__, fd[i], errno, ret, i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ }
+
+ for (i = 0; i < JFFS_NAME_LIMITTED_SIZE; i++) {
+ if (i > fileCount) {
+ errno = 0;
+ ret = remove(pathname2[i]);
+ printf("[%d] remove: %s, errno:%d,i:%d\n", __LINE__, pathname2[i], errno, i);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT2);
+ break;
+ }
+
+ ret = remove(pathname2[i]);
+ printf("[%d] remove: %s, errno:%d,i:%d\n", __LINE__, pathname2[i], errno, i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT3:
+ for (i = 0; i < JFFS_NAME_LIMITTED_SIZE; i++) {
+ close(fd[i]);
+ }
+EXIT2:
+ for (i = 0; i < JFFS_NAME_LIMITTED_SIZE; i++) {
+ remove(pathname2[i]);
+ }
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure307(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure307", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_308.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_308.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e0a1e2d3756a56bee3634db9451b50891a30293c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_308.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len;
+ INT32 fd1 = -1;
+ INT32 i = 0;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test");
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT1);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_NUM_TEST; i++) {
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT1);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_SHORT_ARRAY_LENGTH, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = remove(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT1:
+ close(fd1);
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure308(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure308", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_309.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_309.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0aded4fd4c02695f11af268624905df9f02cbaa4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_309.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, fd[10];
+ INT32 i = 0;
+ INT32 len = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[10][JFFS_STANDARD_NAME_LENGTH] = {JFFS_PATH_NAME0};
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR bufname[JFFS_SHORT_ARRAY_LENGTH] = "";
+ INT32 randTest1[10] = {2, 6, 3, 1, 0, 8, 7, 9, 4, 5};
+ INT32 randTest2[10] = {5, 3, 1, 6, 7, 2, 4, 9, 0, 8};
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ memset_s(bufname, JFFS_SHORT_ARRAY_LENGTH, 0, JFFS_SHORT_ARRAY_LENGTH);
+ memset_s(pathname2[i], JFFS_STANDARD_NAME_LENGTH, 0, JFFS_STANDARD_NAME_LENGTH);
+ snprintf_s(bufname, JFFS_SHORT_ARRAY_LENGTH, JFFS_SHORT_ARRAY_LENGTH - 1, "/1071_%d", i);
+ strcat_s(pathname2[i], JFFS_STANDARD_NAME_LENGTH, pathname1);
+ strcat_s(pathname2[i], JFFS_STANDARD_NAME_LENGTH, bufname);
+ fd[i] = open(pathname2[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT2);
+ }
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ len = write(fd[randTest1[i]], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ ret = close(fd[randTest1[i]]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ fd[randTest2[i]] = open(pathname2[randTest2[i]], O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], -1, fd[i], EXIT2);
+
+ len = read(fd[randTest2[i]], readbuf, JFFS_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ ret = close(fd[randTest2[i]]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ ret = remove(pathname2[randTest2[i]]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ close(fd[randTest1[i]]);
+ }
+EXIT1:
+ for (i = 0; i < JFFS_SHORT_ARRAY_LENGTH; i++) {
+ remove(pathname2[randTest2[i]]);
+ }
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure309(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure309", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_310.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_310.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3549107e247b42e8de55f0cbf947c4d84348ce2d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_310.cpp
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ INT32 scandirCount = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_NAME_LIMITTED_SIZE] = "";
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "/jf";
+ CHAR pathname5[JFFS_STANDARD_NAME_LENGTH] = "/jf/test";
+ CHAR pathname6[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct dirent **namelist = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ memset_s(pathname2, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(pathname3, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(pathname6, JFFS_NAME_LIMITTED_SIZE, "/");
+
+ // PATH_MAX test. The dirname has occupied 14 bytes.
+ while (i < 241) { // loop times: 241
+ i++;
+ strcat_s(pathname2, JFFS_NAME_LIMITTED_SIZE, "t");
+ strcat_s(pathname3, JFFS_NAME_LIMITTED_SIZE, "t");
+ strcat_s(pathname6, JFFS_NAME_LIMITTED_SIZE, "t");
+ }
+ ICUNIT_GOTO_EQUAL(strlen(pathname6), 255, strlen(pathname6), EXIT); // pathname length: 255
+ ICUNIT_GOTO_EQUAL(strlen(pathname2), 241, strlen(pathname2), EXIT); // pathname length: 241
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = mkdir(pathname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EEXIST, errno, EXIT1);
+
+ strcat_s(pathname3, JFFS_NAME_LIMITTED_SIZE, "t");
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT2);
+
+ strcat_s(pathname6, JFFS_NAME_LIMITTED_SIZE, "t");
+ ICUNIT_GOTO_EQUAL(strlen(pathname6), 256, strlen(pathname6), EXIT); // pathname length: 256
+ ret = mkdir(pathname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT2);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ errno = 0;
+ ret = mkdir(pathname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, pathname4, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+ ret = mkdir(pathname5, HIGHEST_AUTHORITY);
+ printf("[%d] errno:%d\n", __LINE__, errno);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT4);
+
+ ret = chdir(pathname5);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = access(pathname2, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+
+ scandirCount = scandir(pathname5, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 2, scandirCount, EXIT5); // dir number: 2
+
+ JffsScandirFree(namelist, scandirCount);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ scandirCount = scandir(pathname1, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 2, scandirCount, EXIT5); // dir number: 2
+
+ JffsScandirFree(namelist, scandirCount);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT4);
+
+ ret = rmdir(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT4);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT4);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mkdir(pathname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, pathname4, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mkdir(pathname5, HIGHEST_AUTHORITY);
+ printf("[%d] errno:%d\n", __LINE__, errno);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT4);
+
+ ret = chdir(pathname5);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT5:
+ JffsScandirFree(namelist, scandirCount);
+EXIT4:
+ umount(pathname4);
+ remove(pathname4);
+EXIT3:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT2:
+ remove(pathname3);
+ remove(pathname6);
+EXIT1:
+ rmdir(pathname2);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure310(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure310", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_311.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_311.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5b36e4b7c8f0684913fa554bbca72da8f801ab84
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_311.cpp
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ INT32 fd = -1;
+ INT32 scandirCount = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+ CHAR pathname3[JFFS_NAME_LIMITTED_SIZE] = { JFFS_MAIN_DIR0 };
+ CHAR pathname4[JFFS_NAME_LIMITTED_SIZE] = "";
+ CHAR pathname5[JFFS_NAME_LIMITTED_SIZE] = "";
+ CHAR pathname6[JFFS_STANDARD_NAME_LENGTH] = "/jf";
+ CHAR pathname7[JFFS_STANDARD_NAME_LENGTH] = "/jf";
+
+ struct dirent **namelist = NULL;
+
+ ret = chdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ memset_s(pathname4, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ memset_s(pathname5, JFFS_NAME_LIMITTED_SIZE, 0, JFFS_NAME_LIMITTED_SIZE);
+ strcat_s(pathname3, JFFS_NAME_LIMITTED_SIZE, "/");
+
+ // PATH_MAX test. The dirname has occupied 9 bytes.
+ while (i < 246) { // loop times: 246
+ i++;
+ strcat_s(pathname4, JFFS_NAME_LIMITTED_SIZE, "t");
+ strcat_s(pathname5, JFFS_NAME_LIMITTED_SIZE, "t");
+ strcat_s(pathname3, JFFS_NAME_LIMITTED_SIZE, "t");
+ }
+ ICUNIT_GOTO_EQUAL(strlen(pathname3), 255, strlen(pathname3), EXIT); // pathname length: 255
+ ICUNIT_GOTO_EQUAL(strlen(pathname4), 246, strlen(pathname4), EXIT); // pathname length: 246
+
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ fd = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EEXIST, errno, EXIT2);
+
+ strcat_s(pathname5, JFFS_NAME_LIMITTED_SIZE, "t");
+ fd = open(pathname5, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT2);
+
+ strcat_s(pathname3, JFFS_NAME_LIMITTED_SIZE, "t");
+ ICUNIT_GOTO_EQUAL(strlen(pathname3), 256, strlen(pathname3), EXIT); // pathname length: 256
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, -1, fd, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT2);
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = mkdir(pathname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, pathname6, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = chdir(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = access(pathname4, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ fd = open(pathname5, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT4);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+
+ scandirCount = scandir(pathname7, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 2, scandirCount, EXIT5); // dir number: 2
+
+ JffsScandirFree(namelist, scandirCount);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ scandirCount = scandir(pathname1, &namelist, 0, alphasort);
+ ICUNIT_GOTO_EQUAL(scandirCount, 2, scandirCount, EXIT5); // dir number: 2
+
+ JffsScandirFree(namelist, scandirCount);
+
+ ret = remove(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT4);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(JFFS_MOUNT_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mkdir(pathname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, pathname6, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = chdir(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname5);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = umount(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = remove(pathname6);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ return JFFS_NO_ERROR;
+EXIT5:
+ JffsScandirFree(namelist, scandirCount);
+EXIT4:
+ umount(pathname6);
+ remove(pathname6);
+EXIT3:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+EXIT2:
+ close(fd);
+ remove(pathname5);
+ remove(pathname3);
+EXIT1:
+ close(fd);
+ remove(pathname4);
+EXIT:
+ close(fd);
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure311(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure311", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_312.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_312.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1f5c2eefd7675d672c2359bd72beb5b20e17dffc
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_312.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, JFFS_NAME_LIMITTED_SIZE, "/");
+
+ while (i < 280) { // loop times: 280
+ strcat_s(pathname1, JFFS_NAME_LIMITTED_SIZE, "t");
+ i++;
+ }
+ ICUNIT_GOTO_EQUAL(strlen(pathname1), 294, strlen(pathname1), EXIT); // pathname length: 294
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ remove(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure312(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure312", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_313.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_313.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..aca3e63f1b0ca603ee8070a66885d4a2ccb24b3d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_313.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ CHAR pathname1[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat_s(pathname1, JFFS_NAME_LIMITTED_SIZE, "/test");
+ while (i < 280) { // loop times: 280
+ i++;
+ strcat_s(pathname1, JFFS_NAME_LIMITTED_SIZE, "t");
+ }
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT2);
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ closedir(dir);
+EXIT1:
+ rmdir(pathname1);
+EXIT:
+ rmdir(pathname2);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure313(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure313", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_314.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_314.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5c27da3e05a2fcf0e2408702942e080fdb44a123
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_314.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len, i;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *writebuf = NULL;
+ CHAR *readbuf = NULL;
+ off_t off;
+ INT32 bufLen = 65536;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ writebuf = (CHAR *)malloc(bufLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT2);
+ memset_s(writebuf, bufLen + 1, 0, bufLen + 1);
+
+ for (i = 0; i < bufLen / strlen(filebuf); i++) {
+ strcat_s(writebuf, bufLen + 1, filebuf);
+ }
+ writebuf[bufLen - 1] = '\0';
+
+ readbuf = (CHAR *)malloc(bufLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(readbuf, NULL, readbuf, EXIT3);
+ memset_s(readbuf, bufLen + 1, 0, bufLen + 1);
+
+ len = write(fd, writebuf, bufLen - 1);
+ ICUNIT_GOTO_EQUAL(len, bufLen - 1, len, EXIT4);
+
+ memset_s(readbuf, bufLen + 1, 0, bufLen + 1);
+ len = pread(fd, readbuf, bufLen - 1, 0);
+ ICUNIT_GOTO_EQUAL(len, bufLen - 1, len, EXIT4);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, bufLen - 1, off, EXIT4);
+
+ free(readbuf);
+ free(writebuf);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT4:
+ free(readbuf);
+EXIT3:
+ free(writebuf);
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure314(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure314", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_315.cpp b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_315.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7d92ecb66f125a5b63a5f544b5156af3c0c19338
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_fs_jffs_pressure_315.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len, i;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *writebuf = NULL;
+ CHAR *readbuf = NULL;
+ off_t off;
+ INT32 testLen = 0xffff;
+ INT32 bufLen = testLen + 1;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ writebuf = (CHAR *)malloc(bufLen + 1);
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT2);
+ memset_s(writebuf, bufLen + 1, 0, bufLen + 1);
+
+ for (i = 0; i < bufLen / strlen(filebuf); i++) {
+ strcat_s(writebuf, bufLen + 1, filebuf);
+ }
+ writebuf[bufLen - 1] = '\0';
+
+ readbuf = (CHAR *)malloc(bufLen);
+ ICUNIT_GOTO_NOT_EQUAL(readbuf, NULL, readbuf, EXIT3);
+ memset_s(readbuf, bufLen, 0, bufLen);
+
+ len = pwrite(fd, writebuf, testLen, 0);
+ ICUNIT_GOTO_EQUAL(len, testLen, len, EXIT4);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT4);
+
+ memset_s(readbuf, bufLen, 0, bufLen);
+ len = read(fd, readbuf, testLen);
+ ICUNIT_GOTO_EQUAL(len, testLen, len, EXIT4);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT4);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, testLen, off, EXIT4);
+
+ free(readbuf);
+ free(writebuf);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT4:
+ free(readbuf);
+EXIT3:
+ free(writebuf);
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsPressure315(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsPressure315", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_001.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ffb85e5707fc82fe7f20fdb6ca308561c5e3116b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_001.cpp
@@ -0,0 +1,400 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[70] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ off_t off;
+ struct stat statfile;
+
+ INT32 bufWLen = BYTES_PER_MBYTE;
+ INT32 bufW1Len = 512 * BYTES_PER_KBYTE; // 512 KB
+ INT32 bufW2Len = 16 * BYTES_PER_KBYTE; // 16 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, 0);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW1 = (CHAR *)malloc(bufW1Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW1, NULL, 0, EXIT2);
+ memset_s(bufW1, bufW1Len + 1, 0, bufW1Len + 1);
+
+ bufW2 = (CHAR *)malloc(bufW2Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW2, NULL, 0, EXIT3);
+ memset_s(bufW2, bufW2Len + 1, 0, bufW2Len + 1);
+
+ for (j = 0; j < bufW2Len / strlen(filebuf); j++) {
+ strcat_s(bufW2, bufW2Len + 1, filebuf);
+ }
+
+ for (j = 0; j < bufW1Len / bufW2Len; j++) {
+ strcat_s(bufW1, bufW1Len + 1, bufW2);
+ }
+
+ for (i = 0; i < bufWLen / bufW1Len; i++) {
+ strcat_s(bufW, bufWLen + 1, bufW1);
+ }
+ free(bufW1);
+ free(bufW2);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/001.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_NO_ERROR, off, EXIT2);
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ ret = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTE, ret, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, (BYTES_PER_MBYTE * (i + 1)), off, EXIT2);
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF01 is excecuting\n");
+ }
+
+ off = lseek(fd, 64, SEEK_SET); // file position: 64
+ ICUNIT_GOTO_EQUAL(off, 64, off, EXIT2);
+
+ len = read(fd, readbuf, 64); // read length: 64
+ ICUNIT_GOTO_EQUAL(len, 64, len, EXIT2);
+
+ ret = stat(pathname1, &statfile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ // 3 * 1024 * 1024: filesize
+ ICUNIT_GOTO_EQUAL(statfile.st_size, 3 * 1024 * 1024, statfile.st_size, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ free(bufW);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ g_TestCnt++;
+ return NULL;
+EXIT3:
+ free(bufW1);
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[70] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ off_t off;
+ struct stat statfile;
+
+ INT32 bufWLen = BYTES_PER_MBYTE;
+ INT32 bufW1Len = 512 * BYTES_PER_KBYTE; // 512 KB
+ INT32 bufW2Len = 16 * BYTES_PER_KBYTE; // 16 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, 0);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW1 = (CHAR *)malloc(bufW1Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW1, NULL, 0, EXIT2);
+ memset_s(bufW1, bufW1Len + 1, 0, bufW1Len + 1);
+
+ bufW2 = (CHAR *)malloc(bufW2Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW2, NULL, 0, EXIT3);
+ memset_s(bufW2, bufW2Len + 1, 0, bufW2Len + 1);
+
+ for (j = 0; j < bufW2Len / strlen(filebuf); j++) {
+ strcat_s(bufW2, bufW2Len + 1, filebuf);
+ }
+
+ for (j = 0; j < bufW1Len / bufW2Len; j++) {
+ strcat_s(bufW1, bufW1Len + 1, bufW2);
+ }
+
+ for (i = 0; i < bufWLen / bufW1Len; i++) {
+ strcat_s(bufW, bufWLen + 1, bufW1);
+ }
+ free(bufW1);
+ free(bufW2);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/002.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_NO_ERROR, off, EXIT2);
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ ret = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTE, ret, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, (BYTES_PER_MBYTE * (i + 1)), off, EXIT2);
+
+ LosTaskDelay(10); // delay time: 10
+ dprintf("PthreadF02 is excecuting\n");
+ }
+
+ off = lseek(fd, 64, SEEK_SET); // file position: 64
+ ICUNIT_GOTO_EQUAL(off, 64, off, EXIT2);
+
+ len = read(fd, readbuf, 64); // read length: 64
+ ICUNIT_GOTO_EQUAL(len, 64, len, EXIT2);
+
+ ret = stat(pathname1, &statfile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ // 3 * 1024 * 1024: filesize
+ ICUNIT_GOTO_EQUAL(statfile.st_size, 3 * 1024 * 1024, statfile.st_size, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ free(bufW);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT3:
+ free(bufW1);
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[70] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ off_t off;
+ struct stat statfile;
+
+ INT32 bufWLen = BYTES_PER_MBYTE;
+ INT32 bufW1Len = 512 * BYTES_PER_KBYTE; // 512 KB
+ INT32 bufW2Len = 16 * BYTES_PER_KBYTE; // 16 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, 0);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW1 = (CHAR *)malloc(bufW1Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW1, NULL, 0, EXIT2);
+ memset_s(bufW1, bufW1Len + 1, 0, bufW1Len + 1);
+
+ bufW2 = (CHAR *)malloc(bufW2Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW2, NULL, 0, EXIT3);
+ memset_s(bufW2, bufW2Len + 1, 0, bufW2Len + 1);
+
+ for (j = 0; j < bufW2Len / strlen(filebuf); j++) {
+ strcat_s(bufW2, bufW2Len + 1, filebuf);
+ }
+
+ for (j = 0; j < bufW1Len / bufW2Len; j++) {
+ strcat_s(bufW1, bufW1Len + 1, bufW2);
+ }
+
+ for (i = 0; i < bufWLen / bufW1Len; i++) {
+ strcat_s(bufW, bufWLen + 1, bufW1);
+ }
+ free(bufW1);
+ free(bufW2);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/003.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_NO_ERROR, off, EXIT2);
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ ret = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTE, ret, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, (BYTES_PER_MBYTE * (i + 1)), off, EXIT2);
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF03 is excecuting\n");
+ }
+
+ off = lseek(fd, 64, SEEK_SET); // seek offset: 64
+ ICUNIT_GOTO_EQUAL(off, 64, off, EXIT2);
+
+ len = read(fd, readbuf, 64); // read length: 64
+ ICUNIT_GOTO_EQUAL(len, 64, len, EXIT2);
+
+ ret = stat(pathname1, &statfile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ // 3 * 1024 * 1024: filesize
+ ICUNIT_GOTO_EQUAL(statfile.st_size, 3 * 1024 * 1024, statfile.st_size, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ free(bufW);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT3:
+ free(bufW1);
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+ rmdir(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread001(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread001", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_002.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..98175ae35a0780872028ed4110ad54c654beb7ee
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_002.cpp
@@ -0,0 +1,477 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[70] = "liteos";
+ CHAR writebuf[70] = "lite";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ off_t off;
+ struct stat statfile;
+
+ INT32 bufWLen = BYTES_PER_MBYTE;
+ INT32 bufW1Len = 512 * BYTES_PER_KBYTE; // 512 KB
+ INT32 bufW2Len = 16 * BYTES_PER_KBYTE; // 16 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, 0);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW1 = (CHAR *)malloc(bufW1Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW1, NULL, 0, EXIT2);
+ memset_s(bufW1, bufW1Len + 1, 0, bufW1Len + 1);
+
+ bufW2 = (CHAR *)malloc(bufW2Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW2, NULL, 0, EXIT3);
+ memset_s(bufW2, bufW2Len + 1, 0, bufW2Len + 1);
+
+ for (j = 0; j < bufW2Len / strlen(filebuf); j++) {
+ strcat_s(bufW2, bufW2Len + 1, filebuf);
+ }
+
+ for (j = 0; j < bufW1Len / bufW2Len; j++) {
+ strcat_s(bufW1, bufW1Len + 1, bufW2);
+ }
+
+ for (i = 0; i < bufWLen / bufW1Len; i++) {
+ strcat_s(bufW, bufWLen + 1, bufW1);
+ }
+ free(bufW1);
+ free(bufW2);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/004.txt"); // /storage/test/004.txt
+ fd1 = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_NO_ERROR, off, EXIT2);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/001.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_NO_ERROR, off, EXIT2);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ ret = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTE, ret, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, (BYTES_PER_MBYTE * (i + 1)), off, EXIT2);
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF01 is excecuting\n");
+ }
+
+ off = lseek(fd, 64, SEEK_SET); // seek offset: 64
+ ICUNIT_GOTO_EQUAL(off, 64, off, EXIT2);
+
+ len = read(fd, readbuf, 64); // read length: 64
+ ICUNIT_GOTO_EQUAL(len, 64, len, EXIT2);
+
+ ret = stat(pathname1, &statfile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ // 5 * 1024 * 1024: filesize
+ ICUNIT_GOTO_EQUAL(statfile.st_size, 5 * 1024 * 1024, statfile.st_size, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ free(bufW);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT3:
+ free(bufW1);
+EXIT2:
+ close(fd);
+ close(fd1);
+EXIT1:
+ unlink(pathname1);
+ unlink(pathname2);
+EXIT:
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[70] = "liteos";
+ CHAR writebuf[70] = "lite";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ off_t off;
+ struct stat statfile;
+
+ INT32 bufWLen = BYTES_PER_MBYTE;
+ INT32 bufW1Len = 512 * BYTES_PER_KBYTE; // 512 KB
+ INT32 bufW2Len = 16 * BYTES_PER_KBYTE; // 16 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, 0);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW1 = (CHAR *)malloc(bufW1Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW1, NULL, 0, EXIT2);
+ memset_s(bufW1, bufW1Len + 1, 0, bufW1Len + 1);
+
+ bufW2 = (CHAR *)malloc(bufW2Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW2, NULL, 0, EXIT3);
+ memset_s(bufW2, bufW2Len + 1, 0, bufW2Len + 1);
+
+ for (j = 0; j < bufW2Len / strlen(filebuf); j++) {
+ strcat_s(bufW2, bufW2Len + 1, filebuf);
+ }
+
+ for (j = 0; j < bufW1Len / bufW2Len; j++) {
+ strcat_s(bufW1, bufW1Len + 1, bufW2);
+ }
+
+ for (i = 0; i < bufWLen / bufW1Len; i++) {
+ strcat_s(bufW, bufWLen + 1, bufW1);
+ }
+ free(bufW1);
+ free(bufW2);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/005.txt");
+ fd1 = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_NO_ERROR, off, EXIT2);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/002.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_NO_ERROR, off, EXIT2);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ ret = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTE, ret, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, (BYTES_PER_MBYTE * (i + 1)), off, EXIT2);
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF02 is excecuting\n");
+ }
+
+ off = lseek(fd, 64, SEEK_SET); // seek offset: 64
+ ICUNIT_GOTO_EQUAL(off, 64, off, EXIT2);
+
+ len = read(fd, readbuf, 64); // read length: 64
+ ICUNIT_GOTO_EQUAL(len, 64, len, EXIT2);
+
+ ret = stat(pathname1, &statfile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ // 5 * 1024 * 1024: filesize
+ ICUNIT_GOTO_EQUAL(statfile.st_size, 5 * 1024 * 1024, statfile.st_size, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ free(bufW);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT3:
+ free(bufW1);
+EXIT2:
+ close(fd);
+ close(fd1);
+EXIT1:
+ unlink(pathname1);
+ unlink(pathname2);
+EXIT:
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 fd2 = -1;
+ INT32 ret, len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = JFFS_SHORT_ARRAY_LENGTH;
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[70] = "liteos";
+ CHAR writebuf[70] = "lite";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ off_t off;
+ struct stat statfile;
+
+ INT32 bufWLen = BYTES_PER_MBYTE;
+ INT32 bufW1Len = 512 * BYTES_PER_KBYTE; // 512 KB
+ INT32 bufW2Len = 16 * BYTES_PER_KBYTE; // 16 KB
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, 0);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ bufW1 = (CHAR *)malloc(bufW1Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW1, NULL, 0, EXIT2);
+ memset_s(bufW1, bufW1Len + 1, 0, bufW1Len + 1);
+
+ bufW2 = (CHAR *)malloc(bufW2Len + 1);
+ ICUNIT_GOTO_NOT_EQUAL(bufW2, NULL, 0, EXIT3);
+ memset_s(bufW2, bufW2Len + 1, 0, bufW2Len + 1);
+
+ for (j = 0; j < bufW2Len / strlen(filebuf); j++) {
+ strcat_s(bufW2, bufW2Len + 1, filebuf);
+ }
+
+ for (j = 0; j < bufW1Len / bufW2Len; j++) {
+ strcat_s(bufW1, bufW1Len + 1, bufW2);
+ }
+
+ for (i = 0; i < bufWLen / bufW1Len; i++) {
+ strcat_s(bufW, bufWLen + 1, bufW1);
+ }
+ free(bufW1);
+ free(bufW2);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/006.txt");
+ fd1 = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_NO_ERROR, off, EXIT2);
+
+ len = read(fd1, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/003.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT2);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_NO_ERROR, off, EXIT2);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ ret = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTE, ret, EXIT2);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, (BYTES_PER_MBYTE * (i + 1)), off, EXIT2);
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF03 is excecuting\n");
+ }
+
+ off = lseek(fd, 64, SEEK_SET); // seek offset: 64
+ ICUNIT_GOTO_EQUAL(off, 64, off, EXIT2);
+
+ len = read(fd, readbuf, 64); // read length: 64
+ ICUNIT_GOTO_EQUAL(len, 64, len, EXIT2);
+
+ ret = stat(pathname1, &statfile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ // 5 * 1024 * 1024: filesize
+ ICUNIT_GOTO_EQUAL(statfile.st_size, 5 * 1024 * 1024, statfile.st_size, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ free(bufW);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT3:
+ free(bufW1);
+EXIT2:
+ close(fd);
+ close(fd1);
+EXIT1:
+ unlink(pathname1);
+ unlink(pathname2);
+EXIT:
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+ rmdir(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread002(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread002", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_003.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fdd4f3b98bd433be5d27faa92ebbad4bcf8d77a3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_003.cpp
@@ -0,0 +1,541 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, index, index1;
+ INT32 fd[JFFS_MIDDLE_CYCLES] = {};
+ INT32 fd1[JFFS_MIDDLE_CYCLES] = {};
+ INT32 flag = 0;
+ INT32 readLen = 10;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd1[index1], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ ret = lseek(fd1[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ len = read(fd1[index1], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(1); // delay time: 1
+ dprintf("PthreadF01 is excecuting\n");
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, index, index1;
+ INT32 fd[JFFS_MIDDLE_CYCLES] = {};
+ INT32 fd1[JFFS_MIDDLE_CYCLES] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd1[index1], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ ret = lseek(fd1[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ len = read(fd1[index1], readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, index, index1;
+ INT32 fd[JFFS_MIDDLE_CYCLES] = {};
+ INT32 fd1[JFFS_MIDDLE_CYCLES] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd1[index1], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ ret = lseek(fd1[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ len = read(fd1[index1], readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(1); // delay time: 1
+ dprintf("PthreadF03 is excecuting\n");
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread003(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread003", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_004.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7a68941a804a647b486cf1ac04e43489e89c8589
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_004.cpp
@@ -0,0 +1,504 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd[JFFS_MIDDLE_CYCLES] = {};
+ INT32 fd1[JFFS_MIDDLE_CYCLES] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file_%d.txt",
+ index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+
+ len = write(fd1[index1], writebuf, strlen(writebuf));
+
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF01 is excecuting\n");
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file_%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file_%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd[JFFS_MIDDLE_CYCLES] = {};
+ INT32 fd1[JFFS_MIDDLE_CYCLES] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file_%d.txt",
+ index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+
+ len = write(fd1[index1], writebuf, strlen(writebuf));
+
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ LosTaskDelay(10); // delay time: 10
+ dprintf("PthreadF02 is excecuting\n");
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file_%d.txt",
+ i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file_%d.txt",
+ i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd[JFFS_MIDDLE_CYCLES] = {};
+ INT32 fd1[JFFS_MIDDLE_CYCLES] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file_%d.txt",
+ index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+
+ len = write(fd1[index1], writebuf, strlen(writebuf));
+
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is excecuting\n");
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file_%d.txt",
+ i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file_%d.txt",
+ i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread004(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread004", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_005.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f83ff62daac4ba2af6ba553758a1eb364a9dc596
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_005.cpp
@@ -0,0 +1,325 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file0.txt");
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ for (j = 0; j < 20; j++) { // loop times: 20
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ len = read(fd, readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1.txt");
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ for (j = 0; j < 20; j++) { // loop times: 20
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ len = read(fd, readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file2.txt");
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ for (j = 0; j < 20; j++) { // loop times: 20
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ len = read(fd, readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread005(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread005", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_006.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..481dee73810be50b6628889aeaef3da66a4ad429
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_006.cpp
@@ -0,0 +1,615 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ CHAR *bufW3 = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ index = 0;
+ for (i = 0; i < JFFS_CREATFILE_NUM; i++) {
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 5; j++) { // loop times: 5
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ bufW3 = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW3, NULL, NULL);
+ memset_s(bufW3, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW3, bufWLen + 1, filebuf);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index1], bufW3, strlen(bufW3));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = lseek(fd[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ len = read(fd[index1], readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufW3);
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", i);
+ unlink(pathname);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ unlink(pathname1);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ CHAR *bufW3 = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME01 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ index = 0;
+ for (i = 0; i < JFFS_CREATFILE_NUM; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 5; j++) { // loop times: 5
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ bufW3 = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW3, NULL, NULL);
+ memset_s(bufW3, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW3, bufWLen + 1, filebuf);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index1], bufW3, strlen(bufW3));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ ret = lseek(fd[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ len = read(fd[index1], readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufW3);
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ CHAR *bufW3 = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME02 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ index = 0;
+ for (i = 0; i < JFFS_CREATFILE_NUM; i++) {
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 5; j++) { // loop times: 5
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ bufW3 = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW3, NULL, NULL);
+ memset_s(bufW3, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW3, bufWLen + 1, filebuf);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index1], bufW3, strlen(bufW3));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ len = read(fd[index1], readbuf, 10); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufW3);
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread006(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread006", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_007.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2c9b992d4a2fbbf7827c4cd26740237c864120aa
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_007.cpp
@@ -0,0 +1,569 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, index, index1;
+ INT32 fd[20] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = "/storage/test";
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = "/storage/test/test00";
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = JFFS_MIDDLE_CYCLES;
+ for (i = JFFS_MIDDLE_CYCLES; i < JFFS_MIDDLE_NUM; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index1], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, index, index1;
+ INT32 fd[20] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME01 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = JFFS_MIDDLE_CYCLES;
+ for (i = JFFS_MIDDLE_CYCLES; i < JFFS_MIDDLE_NUM; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index1], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, index, index1;
+ INT32 fd[20] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = "/storage/test2";
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = "/storage/test2/test22";
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = JFFS_MIDDLE_CYCLES;
+ for (i = JFFS_MIDDLE_CYCLES; i < JFFS_MIDDLE_NUM; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index1], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread007(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread007", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_008.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8b29c9c51a8dd3465b54483d3ebc438e8ab8e884
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_008.cpp
@@ -0,0 +1,553 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[20] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1111";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufW);
+ index1 = JFFS_MIDDLE_CYCLES;
+ for (i = JFFS_MIDDLE_CYCLES; i < JFFS_MIDDLE_NUM; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt",
+ index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+ len = write(fd[index1], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[20] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1111";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME01 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufW);
+ index1 = JFFS_MIDDLE_CYCLES;
+ for (i = JFFS_MIDDLE_CYCLES; i < JFFS_MIDDLE_NUM; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt",
+ index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+ len = write(fd[index1], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[20] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "1111";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufW);
+ index1 = JFFS_MIDDLE_CYCLES;
+ for (i = JFFS_MIDDLE_CYCLES; i < JFFS_MIDDLE_NUM; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt",
+ index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+ len = write(fd[index1], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i = 1;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread008(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread008", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_009.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_009.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..82f5513ae32faeed496f85dc67be9f86c2f7035a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_009.cpp
@@ -0,0 +1,414 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME01 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ CHAR *bufW1 = NULL;
+ CHAR *bufW2 = NULL;
+ CHAR *bufW3 = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME02 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT3:
+ free(bufW1);
+EXIT2:
+ free(bufW);
+EXIT1:
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread009(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread009", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_010.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6cbbd1db05c37ebb293875c89c6414fa4e75a7e2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_010.cpp
@@ -0,0 +1,556 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 20; j++) { // loop times: 20
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = JFFS_MIDDLE_CYCLES;
+ for (i = index1; i < index1 + JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ len = write(fd[index1], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_MBYTE, len, EXIT1);
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file%d.txt", i);
+ unlink(pathname);
+ }
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file%d.txt", i);
+ unlink(pathname1);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME01 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 20; j++) { // loop times: 20
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = JFFS_MIDDLE_CYCLES;
+ for (i = index1; i < index1 + JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ len = write(fd[index1], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_MBYTE, len, EXIT1);
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file%d.txt", i);
+ unlink(pathname1);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag1, index, index1;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME02 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 20; j++) { // loop times: 20
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = JFFS_MIDDLE_CYCLES;
+ for (i = index1; i < index1 + JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ len = write(fd[index1], bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_MBYTE, len, EXIT1);
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf2);
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT2:
+ free(bufW);
+EXIT1:
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+
+ for (i = index1; i >= JFFS_MIDDLE_CYCLES; i--) {
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file%d.txt", i);
+ unlink(pathname1);
+ }
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread010(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread010", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_011.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_011.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..256f5f973689ae389bd6a449a72cdb0ed0de1392
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_011.cpp
@@ -0,0 +1,663 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ struct stat statbuf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/ttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd1, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+ ret = stat(buffile2, &statbuf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf2);
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ret = rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ret = rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME01 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ struct stat statbuf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(statbuf);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/ttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd1, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+ ret = stat(buffile2, &statbuf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf2);
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME02 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ struct stat statbuf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(statbuf);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/ttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd1, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &statbuf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf2);
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread011(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread011", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_012.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_012.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..907bbcf34f9dfe66f38a373f98e3780d46bcd47c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_012.cpp
@@ -0,0 +1,634 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/ttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ret = rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ret = rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME01 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/ttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf)); // 4
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME02 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/ttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread012(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread012", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_013.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_013.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5736f38bfb76a4a14b1bda82ac0b80d523fe607c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_013.cpp
@@ -0,0 +1,451 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME01 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME02 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = "/storage/test2/test22";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread013(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread013", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_014.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_014.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6173228a4c6b25109d153e216b3e83cd01dfa763
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_014.cpp
@@ -0,0 +1,618 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+static INT32 g_testNum = 20;
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME0 };
+ CHAR buffile2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ INT32 bufWLen = 512 * BYTES_PER_KBYTE; // 512 KB
+
+ flag = 0;
+ bufW = (CHAR *)malloc(BYTES_PER_MBYTE + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < g_testNum; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ len = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < g_testNum; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/ttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME01 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ INT32 bufWLen = 512 * BYTES_PER_KBYTE; // 512 KB
+
+ flag = 0;
+ bufW = (CHAR *)malloc(BYTES_PER_MBYTE + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < g_testNum; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ len = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < g_testNum; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/ttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME02 };
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf = { 0 };
+ INT32 bufWLen = 512 * BYTES_PER_KBYTE; // 512 KB
+
+ flag = 0;
+ bufW = (CHAR *)malloc(BYTES_PER_MBYTE + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < g_testNum; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ len = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF03 is excecuting\n");
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < g_testNum; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/ttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/ttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/ttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread014(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread014", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_015.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_015.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0f963dfc8a52d2d04596058185f61ee91253f719
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_015.cpp
@@ -0,0 +1,668 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = 256 * BYTES_PER_KBYTE; // 256 KB
+
+ flag = 0;
+ bufW = (CHAR *)malloc(BYTES_PER_MBYTE + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01-0 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/test%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ dprintf("mkdir filed f01\n");
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd1, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ dprintf("PthreadF01-1 is excecuting\n");
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname5, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/test_%d",
+ index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/test_%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/test%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/test_%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = 256 * BYTES_PER_KBYTE; // 256 KB
+
+ flag = 0;
+ bufW = (CHAR *)malloc(BYTES_PER_MBYTE + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(2); // delay time: 2
+ dprintf("PthreadF02-0 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/test%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ for (j = 0; j < 10; j++) { // loop times: 10
+ len = write(fd1, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ dprintf("PthreadF02-1 is excecuting\n");
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname5, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/test_%d",
+ index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/test_%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/test%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/test_%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = 256 * BYTES_PER_KBYTE; // 256 KB
+
+ flag = 0;
+ bufW = (CHAR *)malloc(BYTES_PER_MBYTE + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF03-0 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/test%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd1, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ dprintf("PthreadF03-1 is excecuting\n");
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname5, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/test_%d",
+ index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/test_%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/test%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/test_%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread015(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread015", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_016.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_016.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..33752c4e8e802aec1f26718ee1963dcc539a242e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_016.cpp
@@ -0,0 +1,649 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/tttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname5, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/tttest_%d",
+ index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/tttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dirbuf[100] = {NULL};
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/tttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname5, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/tttest_%d",
+ index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/tttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ret = rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ret = rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dirbuf[100] = {NULL};
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/tttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname5, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/tttest_%d",
+ index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/tttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ret = rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ret = rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread016(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread016", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_017.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_017.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6600a7e2854403a4e983759de1c973727d9f27ed
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_017.cpp
@@ -0,0 +1,450 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dirbuf[100] = {NULL};
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dirbuf[100] = {NULL};
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/testdir%d",
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/testdir_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/testdir_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/testdir%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/testdir_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dirbuf[100] = {NULL};
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test1%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test01_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test01_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test1%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test01_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread017(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread017", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_018.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_018.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f40476641bf2060aeacdd45c437a728af4459dc4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_018.cpp
@@ -0,0 +1,650 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/tttest%d",
+ index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname5, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/tttest_%d", index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test00/tttest%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/tttest%d", index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname5, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/tttest_%d", index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test11/tttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, index1;
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF03 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/tttest%d", index1);
+ ret = mkdir(pathname3, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname5, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/tttest_%d", index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test22/tttest%d",
+ i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ snprintf_s(pathname3, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/tttest_%d", i);
+ strcpy_s(pathname4, JFFS_STANDARD_NAME_LENGTH, pathname3);
+ strcat_s(pathname4, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/test_%d", i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread018(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread018", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_019.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_019.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cdfb448fa210bdf284264465e3599205201ad3bc
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_019.cpp
@@ -0,0 +1,449 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0: // fd[0]
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1: // fd[1]
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF01 is excecuting\n");
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test0/file2%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0: // fd[0]
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+ break;
+ case 1: // fd[1]
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test0/file2%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test0/file2%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test0/test1/file3%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0: // fd[0]
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1: // fd[1]
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is excecuting\n");
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test0/test1/file3_%d.txt", index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test0/test1/file3_%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test0/test1/file3_%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ strcat_s(bufname2, JFFS_STANDARD_NAME_LENGTH, "/test0");
+ strcat_s(bufname3, JFFS_STANDARD_NAME_LENGTH, "/test0/test1");
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread019(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread019", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_020.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_020.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ff23eca55bcbaa29be7207480fac696aa96b53f0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_020.cpp
@@ -0,0 +1,443 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0: // fd[0]
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is excecuting\n");
+ break;
+ case 1: // fd[1]
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file2%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0: // fd[0]
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1: // fd[1]
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is excecuting\n");
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file2%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file2%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file3%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0: // fd[0]
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1: // fd[1]
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is excecuting\n");
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file3_%d.txt",
+ index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file3_%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test2/file3_%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread020(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread020", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_021.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_021.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4a1f53230eabb070930aaf0f5dce8ea83b6a433a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_021.cpp
@@ -0,0 +1,424 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file1%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF01 is excecuting\n");
+ default:
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file1%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file1%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file2%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is excecuting\n");
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file2%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file2%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file3%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF03 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file3_%d.txt",
+ index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file3_%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test1/file3_%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread021(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread021", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_022.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_022.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6d0036623ccf27ddcaab391542115e9954598b98
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_022.cpp
@@ -0,0 +1,465 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file2%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file2%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file2%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file3%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF03 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file3_%d.txt", index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file3_%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file3_%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread022(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread022", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_023.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_023.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..77dd872ef45019c81d4cb5208c470a264d51d12c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_023.cpp
@@ -0,0 +1,465 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file1%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file1%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test/test00/file1%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file2%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is excecuting\n");
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file2%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test1/test11/file2%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file3%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF03 is excecuting\n");
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file3_%d.txt", index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file3_%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1,
+ "/storage/test2/test22/file3_%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME00 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME11 };
+ CHAR bufname5[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR bufname6[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME22 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread023(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread023", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_024.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_024.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9ad59b44cc51999dfce030cd443b4166022ab6ab
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_024.cpp
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF01 is excecuting\n");
+ default:
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file1%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file2%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is excecuting\n");
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file2%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file2%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file3%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF03 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file3_%d.txt",
+ index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file3_%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "/storage/test/file3_%d.txt", i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread024(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread024", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_025.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_025.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..735e5276d6a7c5b8f3e0130ad13dddfe68e88181
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_025.cpp
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 fd = -1;
+ INT32 ret, len, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ len = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT1);
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+ }
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = lseek(fd, -10, SEEK_CUR); // seek offset: -10
+ ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
+
+ len = read(fd, readbuf, strlen(writebuf)); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ free(bufW);
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 fd = -1;
+ INT32 ret, len, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ len = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT1);
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+ }
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = lseek(fd, -10, SEEK_CUR); // seek offset: -10
+ ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
+
+ len = read(fd, readbuf, strlen(writebuf)); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ free(bufW);
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 fd = -1;
+ INT32 ret, len, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ len = write(fd, bufW, strlen(bufW));
+ ICUNIT_GOTO_EQUAL(len, strlen(bufW), len, EXIT1);
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+ }
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ ret = lseek(fd, -10, SEEK_CUR); // seek offset: -10
+ ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
+
+ len = read(fd, readbuf, strlen(writebuf)); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ free(bufW);
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ LosTaskDelay(1); // delay time: 1
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread025(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread025", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_026.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_026.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..71df379692ff590999e29303c8a57a8367035fdf
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_026.cpp
@@ -0,0 +1,263 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ struct stat statbuf;
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/p01.txt");
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ len = read(fd, readbuf, strlen(writebuf)); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF01 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ struct stat statbuf;
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/p02.txt");
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF02 is executing\n");
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ len = read(fd, readbuf, strlen(writebuf)); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ LosTaskDelay(1); // delay time: 1
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_01 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ struct stat statbuf;
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/p03.txt");
+
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF03 is executing\n");
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ len = read(fd, readbuf, strlen(writebuf)); // read length: 10
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_0 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_01 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(1); // delay time: 1
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread026(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread026", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_027.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_027.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c99d143582697f1e7c5d44352fb2f29208feee08
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_027.cpp
@@ -0,0 +1,384 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME02, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME02, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME02, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread027(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread027", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_028.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_028.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8847fc21da7f1c85e2023162b21193318d4ad3e6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_028.cpp
@@ -0,0 +1,311 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, ret, len, index, flag;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+
+ flag = 0;
+
+ for (index = 0; index < JFFS_MIDDLE_CYCLES; index++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ len = write(fd[index], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, ret, len, index, flag;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+
+ flag = 0;
+
+ for (index = 0; index < JFFS_MIDDLE_CYCLES; index++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ len = write(fd[index], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, ret, len, index, flag;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+
+ flag = 0;
+
+ for (index = 0; index < JFFS_MIDDLE_CYCLES; index++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ len = write(fd[index], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread028(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread028", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_029.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_029.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ad4e055fd67966d5cb433c420fc1883718b053d0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_029.cpp
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_0 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_01 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread029(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread029", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_030.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_030.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3951bb7644810d2d68ccf1ae097a5a0c388268ab
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_030.cpp
@@ -0,0 +1,373 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME02, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME02, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME02, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread030(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread030", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_031.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_031.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c031870fcd7ca4772f83aafb227f311e709dae9d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_031.cpp
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, ret, len;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "abcd";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ fd[i] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], JFFS_IS_ERROR, fd[i], EXIT);
+
+ len = write(fd[i], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+ }
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, ret, len;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "abcd";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ fd[i] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], JFFS_IS_ERROR, fd[i], EXIT);
+
+ len = write(fd[i], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+ }
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, ret, len;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "abcd";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME0, i);
+ fd[i] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd[i], JFFS_IS_ERROR, fd[i], EXIT);
+
+ len = write(fd[i], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT1);
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+ }
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread031(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread031", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_032.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_032.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eb694c770e82148f44616cffa7e23dac0471f15c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_032.cpp
@@ -0,0 +1,372 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt", JFFS_PATH_NAME0,
+ i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file%d.txt",
+ JFFS_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_0 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_01 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread032(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread032", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_033.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_033.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0dda6229599a8241df1f2cfca0942c90c7b10051
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_033.cpp
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, offset;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dir = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME0,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, JFFS_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME0, i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME0, i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, offset;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dir = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME01,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, JFFS_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME01,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME01,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, offset;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dir = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME02,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, JFFS_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME02,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME02,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread033(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread033", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_034.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_034.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bf870176e6a8f1d4238d57ac9eb5b6adda3ccc84
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_034.cpp
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, fd, offset;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ DIR *dir = NULL;
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1%d", JFFS_PATH_NAME0,
+ i);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, JFFS_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+ }
+
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1%d", JFFS_PATH_NAME0,
+ j);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ closedir(dir);
+EXIT:
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1%d", JFFS_PATH_NAME0,
+ j);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, fd, offset;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ DIR *dir = NULL;
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2%d", JFFS_PATH_NAME0,
+ i);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, JFFS_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+ }
+
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2%d", JFFS_PATH_NAME0,
+ j);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ closedir(dir);
+EXIT:
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2%d", JFFS_PATH_NAME0,
+ j);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, fd, offset;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ DIR *dir = NULL;
+
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3%d", JFFS_PATH_NAME0,
+ i);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, JFFS_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+ }
+
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3%d", JFFS_PATH_NAME0,
+ j);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+EXIT1:
+ closedir(dir);
+EXIT:
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3%d", JFFS_PATH_NAME0,
+ j);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread034(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread034", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_035.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_035.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5111f36219bf529e269069ce26e07c02b9cea77a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_035.cpp
@@ -0,0 +1,430 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, offset;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dir = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME0,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, JFFS_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME0,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME0,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, offset;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dir = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME_0,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, JFFS_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME_0,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME_0,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, offset;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ DIR *dir = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME_01,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, JFFS_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME_01,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME_01,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_0 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_01 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread035(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread035", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_036.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_036.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a23040fd1c00a1f99de42354bd54e8563ff0f7c3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_036.cpp
@@ -0,0 +1,429 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME0,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME0,
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME0,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME0, i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME0,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME01,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME01,
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME01,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME01, i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME01,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME02,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME02,
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME02,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test%d", JFFS_PATH_NAME02, i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test_%d", JFFS_PATH_NAME02,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread036(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread036", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_037.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_037.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..02155611906af55e6868ed3c18c5d86240d54850
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_037.cpp
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, fd;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ DIR *dir = NULL;
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1%d", JFFS_PATH_NAME0,
+ i);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1_%d", JFFS_PATH_NAME0,
+ i);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+ }
+
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1_%d", JFFS_PATH_NAME0,
+ j);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+
+EXIT1:
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1%d", JFFS_PATH_NAME0, i);
+ rmdir(pathname);
+EXIT:
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1_%d", JFFS_PATH_NAME0,
+ j);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, fd;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ DIR *dir = NULL;
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2%d", JFFS_PATH_NAME0,
+ i);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2_%d", JFFS_PATH_NAME0,
+ i);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+ }
+
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2_%d", JFFS_PATH_NAME0,
+ j);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+
+EXIT1:
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2%d", JFFS_PATH_NAME0, i);
+ rmdir(pathname);
+EXIT:
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2_%d", JFFS_PATH_NAME0,
+ j);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, fd;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ DIR *dir = NULL;
+
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3%d", JFFS_PATH_NAME0,
+ i);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3_%d", JFFS_PATH_NAME0,
+ i);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+ }
+
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3_%d", JFFS_PATH_NAME0,
+ j);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ return NULL;
+
+EXIT1:
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3%d", JFFS_PATH_NAME0, i);
+ rmdir(pathname);
+EXIT:
+ for (j = i - 1; j >= 0; j--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3_%d", JFFS_PATH_NAME0,
+ j);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread037(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread037", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_038.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_038.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..93ed9ff72cd1bf7b3862d97f1ffcfa833209ebda
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_038.cpp
@@ -0,0 +1,432 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, offset;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1%d", JFFS_PATH_NAME0,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay time: 3
+ dprintf("PthreadF01 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1_%d", JFFS_PATH_NAME0,
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1_%d", JFFS_PATH_NAME0,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1%d", JFFS_PATH_NAME0, i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test1_%d", JFFS_PATH_NAME0,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, offset;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2%d", JFFS_PATH_NAME_0,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay time: 5
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2_%d", JFFS_PATH_NAME_0,
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2_%d", JFFS_PATH_NAME_0,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2%d", JFFS_PATH_NAME_0, i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test2_%d", JFFS_PATH_NAME_0,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index, offset;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufW = NULL;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3%d", JFFS_PATH_NAME_01,
+ index);
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ if (ret == -1) {
+ break;
+ }
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd, bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay time: 7
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname2, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3_%d",
+ JFFS_PATH_NAME_01, index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3_%d", JFFS_PATH_NAME_01,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3%d", JFFS_PATH_NAME_01, i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/test3_%d", JFFS_PATH_NAME_01,
+ i);
+ strcpy_s(pathname1, JFFS_STANDARD_NAME_LENGTH, pathname);
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_0 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_01 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread038(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread038", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_039.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_039.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1137fe71fec23d0bfb70fdfccbcf87d8770012ba
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_039.cpp
@@ -0,0 +1,437 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread039(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread039", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_040.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_040.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5709c906a0982ef275d0a16d4967581777330194
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_040.cpp
@@ -0,0 +1,453 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME02, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread040(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread040", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_041.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_041.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..95b1a84d96035f14651504b0f7f92cf3e786b4e1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_041.cpp
@@ -0,0 +1,452 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_0 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_01 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread041(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread041", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_042.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_042.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..73a96e72b91957e7d2f5feed4096a2ead5df86ed
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_042.cpp
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME02, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(6); // delay time: 6
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread042(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread042", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_043.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_043.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d8297b09d8fa2881210367205f6726a2c0383ca0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_043.cpp
@@ -0,0 +1,442 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(6); // delay time: 6
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread043(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread043", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_044.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_044.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6330ae3d276466070275d4a80dd05cf1d737698c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_044.cpp
@@ -0,0 +1,457 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MIDDLE_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_0 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_01 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(6); // delay time: 6
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread044(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MULTIPTHREAD_044", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_045.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_045.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7ab2bf69a7430587742a6549db82affebf05f7e8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_045.cpp
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME02, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread045(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread045", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_046.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_046.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0ee85f3607180f5bf336e63b68ee28f97bebfac5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_046.cpp
@@ -0,0 +1,442 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(6); // delay time: 6
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread046(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread046", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_047.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_047.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9cb764842d9be18f50a28c3b9c1c8a64b99556b8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_047.cpp
@@ -0,0 +1,457 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ LosTaskDelay(3); // delay time: 3
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_0 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_01 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(3); // delay time: 3
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread047(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread047", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_048.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_048.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cf74e095910529aa0330a9db7ec6a08eedeace3b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_048.cpp
@@ -0,0 +1,453 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME02, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME02, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME01 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME02 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread048(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread048", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_049.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_049.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4737de6634de6dbc27108ec0121e3069b0b115e5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_049.cpp
@@ -0,0 +1,437 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ INT32 readLen = 10;
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ struct stat st;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY5);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread049(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread049", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_050.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_050.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..95158bcb30c2a275e03d38da12b6d3d83ad68db4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_050.cpp
@@ -0,0 +1,452 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ INT32 readLen = 10;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, readLen);
+ ICUNIT_GOTO_EQUAL(len, readLen, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "0123456789", readbuf, EXIT1);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file1%d.txt",
+ JFFS_PATH_NAME0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ JffsStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file2%d.txt",
+ JFFS_PATH_NAME_0, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[10] = {};
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[FILE_BUF_SIZE] =
+ "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufW = NULL;
+ struct stat statbuf;
+ INT32 bufWLen = BYTES_PER_MBYTE;
+
+ flag = 0;
+ bufW = (CHAR *)malloc(bufWLen + 1);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufW, NULL, NULL);
+ memset_s(bufW, bufWLen + 1, 0, bufWLen + 1);
+
+ for (i = 0; i < bufWLen / strlen(filebuf); i++) {
+ strcat_s(bufW, bufWLen + 1, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < JFFS_MAX_CYCLES; i++) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3%d.txt",
+ JFFS_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // max file num: 3
+ case 0:
+ for (j = 0; j < JFFS_MAX_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay time: 3
+ break;
+ case 1:
+ for (j = 0; j < JFFS_MIDDLE_CYCLES; j++) {
+ len = write(fd[index], bufW, strlen(bufW));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay time: 5
+ break;
+ case 2: // fd[2]
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay time: 7
+ default:
+ break;
+ }
+
+ dprintf("PthreadF03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ snprintf_s(pathname1, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ }
+
+ g_TestCnt++;
+
+ free(bufW);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ snprintf_s(pathname, JFFS_STANDARD_NAME_LENGTH, JFFS_STANDARD_NAME_LENGTH - 1, "%s/file3_%d.txt",
+ JFFS_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_TestCnt = 0;
+ free(bufW);
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_0 };
+ CHAR bufname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME_01 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY4);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF02, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], JFFS2NUM_JFFS2_GC_THREAD_PRIORITY2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], PthreadF03, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread050(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread050", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_051.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_051.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..63eed4c535068a1682dd31a851db7ac9d131405b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_051.cpp
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static VOID *MutiJffs05101(void *arg)
+{
+ INT32 ret;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_051_01 2 \n");
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test");
+ ret =
+ JffsMultiWrite(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = JffsMultiRead(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDWR, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ unlink(pathname);
+
+ dprintf(" end muti_jffs_051_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ unlink(pathname);
+
+ g_TestCnt = 0;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ pthread_attr_t attr[JFFS_MAX_THREADS];
+ pthread_t threadId[JFFS_MAX_THREADS];
+ INT32 priority = 20;
+ INT32 testNum = 3;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ i = 0;
+ ret = PosixPthreadInit(&attr[i], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], MutiJffs05101, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], MutiJffs05101, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ i++;
+ ret = PosixPthreadInit(&attr[i], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[i], &attr[i], MutiJffs05101, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ while (g_TestCnt < testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, JFFS_MAX_THREADS, g_TestCnt);
+
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < JFFS_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+
+EXIT:
+ rmdir(pathname);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread051(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread051", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_052.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_052.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a4529faefd10a6a6f4731cb5a119bd99bcd971a0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_052.cpp
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs05201(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ dprintf(" start muti_jffs_052_01 1 \n");
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_52");
+
+ ret = JffsMultiRead(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDWR, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 52_01 \n");
+ }
+
+ dprintf(" end muti_jffs_052_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+
+ return NULL;
+}
+
+static VOID *MutiJffs05202(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ dprintf(" start muti_jffs_052_02 1 \n");
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_52");
+
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+
+ // file size: 1024, write size: 1024
+ ret = JffsMultiWrite(pathname, 1024, 1024, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ // file size: 1024, read size: 1
+ ret = JffsMultiRead(pathname, 1024, 1, O_RDWR, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 52_02 \n");
+ }
+
+ dprintf(" end muti_jffs_052_02 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_52");
+ ret =
+ JffsMultiWrite(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs05201, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs05202, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+EXIT:
+ rmdir(bufname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread052(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread052", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_053.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_053.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..57639165c7ca9a0b9605b13771654081c63480b2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_053.cpp
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs05301(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_053_01 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_53");
+ ret = JffsMultiRead(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDWR, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 53_01 \n");
+ }
+
+ dprintf(" end muti_jffs_053_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *MutiJffs05302(void *arg)
+{
+ INT32 ret, i;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+
+ dprintf(" start muti_jffs_053_02 1 \n");
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_53");
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+
+ fd = open(pathname, O_RDONLY, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 53_02 \n");
+ }
+
+ dprintf(" end muti_jffs_053_02 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_53");
+ ret =
+ JffsMultiWrite(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs05301, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs05302, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+EXIT:
+ rmdir(bufname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread053(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread053", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_054.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_054.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b6edd4897565fdfc75fa71d661a9b9cbac4af345
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_054.cpp
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs05401(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_054_01 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_54");
+ ret = JffsMultiRead(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDONLY, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 54_01 \n");
+ }
+
+ dprintf(" end muti_jffs_054_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *MutiJffs05402(void *arg)
+{
+ INT32 ret, i, len;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+
+ dprintf(" start muti_jffs_054_02 1 \n");
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_54");
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+
+ fd = open(pathname, O_WRONLY | O_CREAT, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 54_02 \n");
+ }
+
+ dprintf(" end muti_jffs_054_02 2 \n");
+
+ return NULL;
+
+EXIT1:
+ close(fd);
+
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_54");
+ ret =
+ JffsMultiWrite(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs05401, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs05402, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+EXIT:
+ rmdir(bufname1);
+
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread054(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread054", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_055.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_055.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..083a137a7d88df2570314c0031acbfd76d707dc0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_055.cpp
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs05501(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_055_01 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_55");
+ ret = JffsMultiRead(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDONLY, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 55_01 \n");
+ }
+
+ dprintf(" end muti_jffs_055_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *MutiJffs05502(void *arg)
+{
+ INT32 ret, i;
+ INT32 fd = -1;
+ struct stat buf1 = { 0 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_055_02 1 \n");
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_55");
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+ fd = open(pathname, O_WRONLY | O_CREAT, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 55_02 \n");
+ }
+
+ dprintf(" end muti_jffs_055_02 2 \n");
+
+ return NULL;
+
+EXIT1:
+ close(fd);
+
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_55");
+ ret =
+ JffsMultiWrite(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs05501, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs05502, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+EXIT:
+ rmdir(bufname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread055(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread055", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_056.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_056.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..69bc0f79abbab604ea9ad76dfa40cf18cbac89bb
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_056.cpp
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs05601(void *arg)
+{
+ INT32 ret;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_056_01 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_56");
+
+ ret = JffsMultiRead(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDONLY, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 56_01 \n");
+ }
+
+ dprintf(" end muti_jffs_056_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *MutiJffs05602(void *arg)
+{
+ INT32 ret;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ dprintf(" start muti_jffs_056_02 1 \n");
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_56");
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test_56_rename");
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+
+ rename(pathname, pathname1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 56_02 \n");
+ }
+
+ dprintf(" end muti_jffs_056_02 2 \n");
+
+ return NULL;
+
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_56");
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test_56_rename");
+ ret =
+ JffsMultiWrite(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs05601, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs05602, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ unlink(pathname);
+ unlink(pathname1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+ unlink(pathname1);
+EXIT:
+ rmdir(bufname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread056(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread056", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_057.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_057.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eee55b4c830272c96d8da437fa538c008b13483b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_057.cpp
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs05701(void *arg)
+{
+ INT32 ret;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_057_01 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_57");
+
+ ret = JffsMultiRead(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDONLY, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 57_01 \n");
+ }
+
+ dprintf(" end muti_jffs_057_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *MutiJffs05702(void *arg)
+{
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+
+ dprintf(" start muti_jffs_057_02 1 \n");
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_57");
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+
+ umount(pathname);
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 57_02 \n");
+ }
+
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+
+ dprintf(" end muti_jffs_057_02 2 \n");
+
+ return NULL;
+
+EXIT:
+
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+
+ g_TestCnt++;
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_57");
+ ret =
+ JffsMultiWrite(pathname, JFFS_PRESSURE_W_R_SIZE2, JFFS_PRESSURE_W_R_SIZE1, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs05701, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs05702, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+EXIT:
+ rmdir(bufname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread057(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread057", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_058.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_058.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c7b92b9ff043dbe1ad8325dbb6982f07306370b7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_058.cpp
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs05801(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_058_01 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_58");
+
+ // file size: 1024, write size: 16
+ ret = JffsMultiWrite(pathname, 1024, 16, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 58_01 \n");
+ }
+
+ dprintf(" end muti_jffs_058_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *MutiJffs05802(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_058_02 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_58");
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+
+ // file size: 1024, write size: 16
+ ret = JffsMultiWrite(pathname, 1024, 16, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ // file size: 1024, read size: 1
+ ret = JffsMultiRead(pathname, 1024, 1, O_RDWR, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 58_02 \n");
+ }
+
+ dprintf(" end muti_jffs_058_02 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_58");
+ // file size: 1024, write size: 10
+ ret = JffsMultiWrite(pathname, 1024, 10, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs05801, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs05802, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+EXIT:
+ rmdir(bufname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread058(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread058", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_059.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_059.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bfc980c8be22fb187ecf89c3be56ecee18b437f8
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_059.cpp
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs05901(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_059_01 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_59");
+
+ // file size: 1024, write size: 16
+ ret = JffsMultiWrite(pathname, 1024, 16, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 59_01 \n");
+ }
+
+ dprintf(" end muti_jffs_059_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *MutiJffs05902(void *arg)
+{
+ INT32 ret, i, len;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+
+ dprintf(" start muti_jffs_059_02 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_59");
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+
+ fd = open(pathname, O_WRONLY | O_CREAT, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 59_02 \n");
+ }
+
+ dprintf(" end muti_jffs_059_02 2 \n");
+
+ return NULL;
+
+EXIT1:
+ close(fd);
+
+EXIT:
+ g_TestCnt++;
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_59");
+ // file size: 1024, write size: 10
+ ret = JffsMultiWrite(pathname, 1024, 10, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs05901, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs05902, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+EXIT:
+ rmdir(bufname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread059(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread059", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_060.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_060.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b6649e5eb90231735c13d0339cd4b2e9985e6716
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_060.cpp
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs06001(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_060_01 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_60");
+
+ // file size: 1024, write size: 16
+ ret = JffsMultiWrite(pathname, 1024, 16, O_WRONLY | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 60_01 \n");
+ }
+
+ dprintf(" end muti_jffs_060_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *MutiJffs06002(void *arg)
+{
+ INT32 ret, i, len;
+ INT32 fd = -1;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "0000000000111111111122222222223333333333";
+
+ dprintf(" start muti_jffs_060_02 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_60");
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+
+ fd = open(pathname, O_RDONLY | O_CREAT, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ len = read(fd, readbuf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, JFFS_STANDARD_NAME_LENGTH, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 60_02 \n");
+ }
+
+ dprintf(" end muti_jffs_060_02 2 \n");
+
+ return NULL;
+
+EXIT1:
+ close(fd);
+
+EXIT:
+ g_TestCnt++;
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_60");
+ // file size: 1024, write size: 10
+ ret = JffsMultiWrite(pathname, 1024, 10, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs06001, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs06002, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+EXIT:
+ rmdir(bufname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread060(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread060", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_061.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_061.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..453ff4b22c2c1bd9c96ff47436954080cb678a32
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_061.cpp
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs06101(void *arg)
+{
+ INT32 ret;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_061_01 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_61");
+
+ // file size: 1024, write size: 16
+ ret = JffsMultiWrite(pathname, 1024, 16, O_WRONLY | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 61_01 \n");
+ }
+
+ dprintf(" end muti_jffs_061_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *MutiJffs06102(void *arg)
+{
+ INT32 ret, i;
+ INT32 fd = -1;
+ struct stat buf1 = { 0 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR buffile[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ dprintf(" start muti_jffs_061_02 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_61");
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+
+ fd = open(pathname, O_RDONLY | O_CREAT, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ JffsStatPrintf(buf1);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 61_02 \n");
+ }
+
+ dprintf(" end muti_jffs_061_02 2 \n");
+
+ return NULL;
+
+EXIT1:
+ close(fd);
+
+EXIT:
+ g_TestCnt++;
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_61");
+ // file size: 1024, write size: 10
+ ret = JffsMultiWrite(pathname, 1024, 10, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs06101, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs06102, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+EXIT:
+ rmdir(bufname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread061(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread061", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_062.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_062.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0a213ffaf37f797d59b031d5877db6ca9413d10a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_062.cpp
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs06201(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_062_01 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_62");
+
+ // file size: 1024, write size: 16
+ ret = JffsMultiWrite(pathname, 1024, 16, O_WRONLY | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 62_01 \n");
+ }
+
+ dprintf(" end muti_jffs_062_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *MutiJffs06202(void *arg)
+{
+ INT32 ret, i;
+ INT32 fd = -1;
+ struct stat buf1 = { 0 };
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+ dprintf(" start muti_jffs_062_02 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_62");
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test_62_rename");
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+
+ rename(pathname, pathname1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 62_02 \n");
+ }
+
+ dprintf(" end muti_jffs_062_02 2 \n");
+
+ return NULL;
+
+EXIT:
+ g_TestCnt++;
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_62");
+ strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/test_62_rename");
+ // file size: 1024, write size: 10
+ ret = JffsMultiWrite(pathname, 1024, 10, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs06201, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs06202, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ unlink(pathname);
+ unlink(pathname1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+ unlink(pathname1);
+EXIT:
+ rmdir(bufname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread062(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread062", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_063.cpp b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_063.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..929558884e85e3521d7cb4543d8b63cbd343fb81
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/pressure/It_vfs_jffs_multipthread_063.cpp
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static INT32 g_testNum = 2;
+
+static VOID *MutiJffs06301(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ dprintf(" start muti_jffs_063_01 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_63");
+
+ // file size: 1024, write size: 16
+ ret = JffsMultiWrite(pathname, 1024, 16, O_WRONLY | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 63_01 \n");
+ }
+
+ dprintf(" end muti_jffs_063_01 2 \n");
+
+ return NULL;
+EXIT:
+
+ g_TestCnt++;
+ return NULL;
+}
+
+static VOID *MutiJffs06302(void *arg)
+{
+ INT32 ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_MAIN_DIR0 };
+
+ dprintf(" start muti_jffs_063_02 1 \n");
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_63");
+ ICUNIT_GOTO_EQUAL(g_TestCnt, 0, g_TestCnt, EXIT);
+
+ umount(pathname);
+
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+
+ g_TestCnt++;
+
+ while (g_TestCnt < g_testNum) {
+ sleep(1);
+ dprintf(" sleep 63_02 \n");
+ }
+
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+
+ dprintf(" end muti_jffs_063_02 2 \n");
+
+ return NULL;
+
+EXIT:
+ mount(JFFS_DEV_PATH0, JFFS_MAIN_DIR0, JFFS_FILESYS_TYPE, 0, NULL);
+
+ g_TestCnt++;
+ return NULL;
+}
+
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, i;
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR bufname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ INT32 threadNum = 2;
+ pthread_attr_t attr[threadNum];
+ pthread_t threadId[threadNum];
+ INT32 priority = 20;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(bufname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname, JFFS_STANDARD_NAME_LENGTH, "/test_63");
+ // file size: 1024, write size: 10
+ ret = JffsMultiWrite(pathname, 1024, 10, O_RDWR | O_CREAT, JFFS_WR_TYPE_TEST);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ dprintf("start create task\n");
+ ret = PosixPthreadInit(&attr[0], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[0], &attr[0], MutiJffs06301, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadInit(&attr[1], priority);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&threadId[1], &attr[1], MutiJffs06302, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ dprintf("end create task\n");
+
+ while (g_TestCnt < g_testNum) {
+ sleep(10); // sleep time: 10
+ dprintf(" sleep \n");
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < threadNum; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_TestCnt, 2, g_TestCnt); // test number: 2
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ for (i = 0; i < threadNum; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < threadNum; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT1:
+ unlink(pathname);
+EXIT:
+ rmdir(bufname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffsMultipthread063(VOID)
+{
+ TEST_ADD_CASE("ItFsJffsMultipthread063", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_test_faccessat_001.cpp b/testsuites/unittest/fs/jffs/smoke/It_test_faccessat_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8e29b67ecf2bf952cfbc022f2d6ee262899c5718
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_test_faccessat_001.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+#include
+#include
+#include
+
+static UINT32 Testcase(VOID)
+{
+ int ret = 0;
+ int argc = 2;
+ char *argv[2];
+
+ argv[1] = (char *)"/lib/libc.so";
+
+ if (argc != 2) {
+ printf("Usage: %s \n", argv[0]);
+ exit(1);
+ }
+
+ ret = faccessat(AT_FDCWD, argv[1], R_OK, AT_EACCESS);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ if (ret < 0) {
+ printf("faccessat error for %s\n", argv[1]);
+ } else {
+ printf("read access OK\n");
+ }
+
+ if (open(argv[1], O_RDONLY) < 0) {
+ printf("open error for %s\n", argv[1]);
+ } else {
+ printf("open for reading OK\n");
+ }
+
+ return LOS_OK;
+}
+
+VOID IoTestFaccessat001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, Testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_test_faccessat_002.cpp b/testsuites/unittest/fs/jffs/smoke/It_test_faccessat_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..94c85ab1dcdefeb42e9b8f05ec4999e4130c41ba
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_test_faccessat_002.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+#include
+#include
+#include
+
+static UINT32 testcase(VOID)
+{
+ int ret = 0;
+
+ ret = faccessat(AT_FDCWD, FILEPATH_000, R_OK, AT_EACCESS);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ ret = open(FILEPATH_000, O_RDONLY);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+VOID IO_TEST_FACCESSAT_002(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_test_fstatat_001.cpp b/testsuites/unittest/fs/jffs/smoke/It_test_fstatat_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3b4ffb0baa32ffd592ec05b8bbfddda535371938
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_test_fstatat_001.cpp
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2019-2021, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+#include "sys/stat.h"
+
+static UINT32 testcase1(VOID)
+{
+ struct stat buf;
+ char *pathname = (char *)FILEPATH_775;
+ int ret = 0;
+ int fd = 0;
+
+ errno = 0;
+ fd = open(pathname, O_RDWR | O_CREAT);
+ TEST_PRINT("[INFO]%s:%d,%s,fd=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, fd, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, OUT);
+
+ errno = 0;
+ ret = fstatat(fd, pathname, &buf, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
+ ICUNIT_GOTO_EQUAL(buf.st_ino, 0, -1, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase2(VOID)
+{
+ struct stat buf;
+ char *pathname = (char *)FILEPATH_RELATIVE;
+ int ret = 0;
+ int fd = 0;
+
+ errno = 0;
+ ret = fstatat(AT_FDCWD, pathname, &buf, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
+ ICUNIT_GOTO_EQUAL(buf.st_ino, 0, -1, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase3(VOID)
+{
+ struct stat buf;
+ char *pathname = (char *)FILEPATH_775;
+ int ret = 0;
+ int fd = 0;
+
+ errno = 0;
+ fd = open(pathname, O_RDWR | O_CREAT);
+ TEST_PRINT("[INFO]%s:%d,%s,fd=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, fd, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, OUT);
+
+ errno = 0;
+ ret = fstatat(fd, pathname, &buf, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
+ ICUNIT_GOTO_EQUAL(buf.st_ino, 0, -1, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase4(VOID)
+{
+ struct stat buf;
+ char *pathname = (char *)FILEPATH_775;
+ int ret = 0;
+ int fd = 0;
+
+ errno = 0;
+ fd = open(pathname, O_RDWR | O_CREAT);
+ TEST_PRINT("[INFO]%s:%d,%s,fd=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, fd, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, OUT);
+
+ errno = 0;
+ ret = fstatat(fd, pathname, &buf, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
+ ICUNIT_GOTO_EQUAL(buf.st_ino, 0, -1, OUT);
+ ICUNIT_GOTO_EQUAL(errno, 0, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1();
+ testcase2();
+ testcase3();
+ testcase4();
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_FSTATAT_001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_test_fstatat_002.cpp b/testsuites/unittest/fs/jffs/smoke/It_test_fstatat_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..692f725ae2d8703b1366db052cc4989a63d989d0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_test_fstatat_002.cpp
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2019-2021, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+#include
+#include "sys/stat.h"
+#include "string.h"
+
+static UINT32 testcase8(VOID)
+{
+ struct stat buf;
+ char pathname[200] = FILEPATH_775;
+ int ret = 0;
+ int fd = 0;
+
+ /* omit to create test file dynamicly,use prepared test files in /storage instand. */
+ #if 0
+ errno = 0;
+ sprintf(pathname, "%s%s", __func__, ".tmp");
+ #endif
+
+ errno = 0;
+ fd = open(pathname, O_CREAT, 0777);
+ TEST_PRINT("[INFO]%s:%d,%s,fd=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, fd, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, OUT);
+
+ errno = 0;
+ //ret = fstatat(fd, pathname, &buf, 0);
+ ret = fstatat(fd, FILEPATH_RELATIVE, &buf, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, ENOTDIR, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase7(VOID)
+{
+ struct stat buf;
+ char *pathname = FILEPATH_NOACCESS;
+ char *dirname = DIRPATH_775;
+ DIR *dir = NULL;
+ int ret = 0;
+ int fd = 0;
+
+ errno = 0;
+ dir = opendir(dirname);
+ fd = dirfd(dir);
+ TEST_PRINT("[INFO]%s:%d,%s,fd=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, fd, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, OUT);
+
+ errno = 0;
+ //ret = fstatat(AT_FDCWD, pathname, &buf, 0);
+ ret = fstatat(fd, pathname, &buf, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase6(VOID)
+{
+ struct stat buf;
+ /* let the pathname more than 4096 characters,to generate the ENAMETOOLONG errno. */
+ char pathname[] = PATHNAME_ENAMETOOLONG;
+ int ret = 0;
+ char *dirname = DIRPATH_775;
+ DIR *dir = NULL;
+ int fd = 0;
+
+ errno = 0;
+ dir = opendir(dirname);
+ fd = dirfd(dir);
+ TEST_PRINT("[INFO]%s:%d,%s,fd=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, fd, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, OUT);
+
+ errno = 0;
+ ret = fstatat(fd, pathname, &buf, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase5(VOID)
+{
+ struct stat buf;
+ char pathname[] = FILEPATH_ENOENT;
+ int ret = 0;
+
+ errno = 0;
+ ret = fstatat(FD_EBADF, pathname, &buf, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase4(VOID)
+{
+ struct stat buf;
+ char pathname[] = FILEPATH_775;
+ errno = 0;
+ int ret = fstatat(FD_EFAULT, pathname, &buf, 0);
+
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, EFAULT, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase3(VOID)
+{
+ struct stat buf;
+ char pathname[] = "";
+ int ret = 0;
+
+ errno = 0;
+ ret = fstatat(AT_FDCWD, pathname, &buf, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase2(VOID)
+{
+ struct stat buf;
+ char pathname[] = FILEPATH_ENOENT;
+ int ret = 0;
+
+ errno = 0;
+ ret = fstatat(AT_FDCWD, pathname, &buf, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase1(VOID)
+{
+ struct stat buf;
+ char pathname[] = FILEPATH_000;
+ int ret = 0;
+
+ errno = 0;
+ ret = fstatat(1, pathname, &buf, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase8(); /* CASE:fd is no a dirfd */
+ testcase7();
+ testcase6();
+ testcase5();
+ testcase4();
+ testcase3();
+ testcase2();
+ testcase1(); /* CASE:no access */
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_FSTATAT_002(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_test_fstatfs_001.cpp b/testsuites/unittest/fs/jffs/smoke/It_test_fstatfs_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9e3efc5cc3bd41ef767b3dd416c6af043c062c6d
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_test_fstatfs_001.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2019-2021, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+#include
+#include "fcntl.h"
+#include "sys/vfs.h"
+
+static UINT32 testcase1(VOID)
+{
+ int fd;
+ struct statfs buf;
+ int ret;
+ errno = 0;
+
+ fd = open("/lib/libc.so", O_RDONLY);
+ ret = fstatfs(fd, &buf);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
+ TEST_PRINT("[INFO]The \"/lib/libc.so\" 's,buf->f_type=0x%x\n", buf.f_type);
+ TEST_PRINT("[INFO]Check the file's filesystem type:./musl/kernel/include/sys/statfs.h:#define JFFS2_SUPER_MAGIC 0x72b6\n");
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_ASSERT_EQUAL(buf.f_type, 0x72b6, -1);
+ ICUNIT_GOTO_EQUAL(buf.f_type, 0x72b6, -1, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1();
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_FSTATFS_001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_test_fstatfs_002.cpp b/testsuites/unittest/fs/jffs/smoke/It_test_fstatfs_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9014ee0d1891a6b6cacb5e22169a5d7a5f6d2738
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_test_fstatfs_002.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2019-2021, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+#include
+#include "fcntl.h"
+#include "sys/vfs.h"
+
+static UINT32 testcase1(VOID)
+{
+ struct statfs buf;
+ char *pathname = (char *)"./fstatfs.tmp";
+ int ret = 0;
+ int fd = 0;
+ errno = 0;
+
+ fd = open(pathname, O_RDWR | O_CREAT);
+ TEST_PRINT("[INFO]%s:%d,%s,fd=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, fd, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, OUT);
+
+ errno = 0;
+ ret = chmod(pathname, 0);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, OUT);
+
+ errno = 0;
+ ret = fstatfs(fd, &buf);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase2(VOID)
+{
+ struct statfs buf;
+ int ret;
+
+ errno = 0;
+ //ret = fstatfs(0xffffffff513, &buf);
+ ret = fstatfs(0xffffffff, &buf);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, OUT);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase3(VOID)
+{
+ struct statfs buf;
+ int ret;
+ int fd;
+
+ errno = 0;
+ fd = open("/lib/libc.so", O_RDONLY);
+
+ errno = 0;
+ ret = fstatfs(fd, &buf);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase4(VOID)
+{
+ struct statfs buf;
+ int ret;
+ int fd;
+
+ errno = 0;
+ fd = open("/lib/libc.so", O_RDONLY);
+
+ errno = 0;
+ ret = fstatfs(fd, nullptr);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT);
+ TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, OUT);
+
+ return LOS_OK;
+OUT:
+ return LOS_NOK;
+}
+
+static UINT32 testcase(VOID)
+{
+ testcase1();
+ testcase2();
+ testcase3(); /* EINVAL-傿•°é”™è¯¯--ç¼–è¯‘å™¨æœ‰å¯¹ç±»åž‹è¿›è¡Œä¿æŠ¤æ— æ³•æµ‹,å¦‚æžœå¼ºåˆ¶ç±»åž‹è½¬æ¢æ–¹å¼ä¼ å…¥å¯èƒ½ä¼šè¸©æ ˆä¹Ÿæ— 法识别 */
+ testcase4();
+
+ return LOS_OK;
+}
+
+VOID IO_TEST_FSTATFS_002(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, testcase, TEST_LIB, TEST_LIBC, TEST_LEVEL1, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_001.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..da7859089270b4cad295528bfd050c27df0ea027
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_001.cpp
@@ -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 "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ INT32 len = 0;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off = 0;
+
+ fd = open(pathname, O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ len = read(fd, readbuf, 50); // read length: 50
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+
+ len = read(fd, readbuf, 50); // read length: 50
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "liteos", readbuf, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, JFFS_IS_ERROR, off, EXIT1);
+
+ len = read(fd, readbuf, 50); // read length: 50
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567890", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs001(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_001", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_002.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8649f86e37f9e28dead5fa7988ca35444e109114
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_002.cpp
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 ret;
+ INT32 offset;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr;
+
+ g_TestCnt = 0;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname, "/0test");
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "1test", ptr->d_name, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0test", ptr->d_name, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT4);
+
+ return JFFS_NO_ERROR;
+EXIT4:
+ closedir(dir);
+ goto EXIT;
+EXIT3:
+ closedir(dir);
+EXIT2:
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ rmdir(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs002(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_002", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_003.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6f26ec84872469fc9962fe08f5310c493a24b319
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_003.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 fd, ret;
+ CHAR pathname[50] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr;
+ INT32 offset;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname, "/0test");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT5);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "2test", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0file", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "1test", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT5);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "0test", ptr->d_name, EXIT5);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT5);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT5);
+
+EXIT5:
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT5);
+EXIT4:
+ JffsStrcat2(pathname, "/1test", sizeof(pathname));
+ rmdir(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/2test", sizeof(pathname));
+ rmdir(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/0file", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/0test", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs003(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_003", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_005.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..13fb0665e1c57850eae4a5c7bb32f67f66c59a11
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_005.cpp
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 fd, fd1, fd2, ret;
+ CHAR pathname[30] = { JFFS_PATH_NAME0 };
+ DIR *dir = NULL;
+ struct dirent *ptr;
+ INT32 offset, offset1, offset2, offset3, offset4;
+
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname, "/test0");
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ JffsStrcat2(pathname, "/file1", sizeof(pathname));
+ fd1 = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ JffsStrcat2(pathname, "/file0", sizeof(pathname));
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ JffsStrcat2(pathname, "/test2", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ JffsStrcat2(pathname, "/file2", sizeof(pathname));
+ fd2 = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT5);
+
+ JffsStrcat2(pathname, "/test1", sizeof(pathname));
+ ret = mkdir(pathname, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT6);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT7);
+
+ offset1 = 0;
+ ptr = readdir(dir);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "file0", ptr->d_name, EXIT7);
+
+ offset2 = ptr->d_off;
+ ptr = readdir(dir);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "file1", ptr->d_name, EXIT7);
+
+ offset3 = ptr->d_off;
+ ptr = readdir(dir);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "file2", ptr->d_name, EXIT7);
+
+ offset4 = ptr->d_off;
+ ptr = readdir(dir);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "test0", ptr->d_name, EXIT7);
+
+ seekdir(dir, offset2);
+ rewinddir(dir);
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT7);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "file0", ptr->d_name, EXIT7);
+ ICUNIT_GOTO_EQUAL(offset, offset1, offset, EXIT7);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT7);
+
+ seekdir(dir, offset1);
+ rewinddir(dir);
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT7);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "file0", ptr->d_name, EXIT7);
+ ICUNIT_GOTO_EQUAL(offset, offset1, offset, EXIT7);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT7);
+
+ seekdir(dir, offset4);
+ rewinddir(dir);
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT7);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "file0", ptr->d_name, EXIT7);
+ ICUNIT_GOTO_EQUAL(offset, offset1, offset, EXIT7);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT7);
+
+ seekdir(dir, offset3);
+ rewinddir(dir);
+ offset = telldir(dir);
+ ptr = readdir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT7);
+ ICUNIT_GOTO_STRING_EQUAL(ptr->d_name, "file0", ptr->d_name, EXIT7);
+ ICUNIT_GOTO_EQUAL(offset, offset1, offset, EXIT7);
+ ICUNIT_GOTO_EQUAL(offset, ptr->d_off - 1, offset, EXIT7);
+
+EXIT7:
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT7);
+EXIT6:
+ JffsStrcat2(pathname, "/test1", sizeof(pathname));
+ rmdir(pathname);
+EXIT5:
+ JffsStrcat2(pathname, "/file2", sizeof(pathname));
+ close(fd2);
+ remove(pathname);
+EXIT4:
+ JffsStrcat2(pathname, "/test2", sizeof(pathname));
+ rmdir(pathname);
+EXIT3:
+ JffsStrcat2(pathname, "/file0", sizeof(pathname));
+ close(fd);
+ remove(pathname);
+EXIT2:
+ JffsStrcat2(pathname, "/file1", sizeof(pathname));
+ close(fd1);
+ remove(pathname);
+EXIT1:
+ JffsStrcat2(pathname, "/test0", sizeof(pathname));
+ rmdir(pathname);
+EXIT:
+ rmdir(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs005(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_005", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_021.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_021.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..70bf2183fbdaa513f034bce965512a458d1584fd
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_021.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 fd1, fd2, ret;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[50] = { JFFS_PATH_NAME0 };
+ CHAR bufdir1[30] = { JFFS_PATH_NAME0 };
+ CHAR bufdir2[30] = { JFFS_PATH_NAME0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname1, "/dir1");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat(pathname2, "/dir2");
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ strcat(bufdir2, "/dir2/dirfile2");
+ ret = mkdir(bufdir2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ strcat(bufdir1, "/dir1/dirfile1");
+ ret = mkdir(bufdir1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = rename(bufdir1, bufdir2); // dirfile1±ä³Édirfile2£¬dirfile2»á±»É¾³ý
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = rmdir(bufdir1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = rmdir(bufdir2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT4:
+ JffsStrcat2(bufdir1, "/dir1/dirfile1", strlen(pathname1));
+ remove(pathname1);
+EXIT3:
+ JffsStrcat2(bufdir2, "/dir2/dirfile2", strlen(pathname1));
+ remove(pathname1);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir2", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir1", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs021(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_021", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_022.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_022.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a7992f3809f5fe851baa226ea54475ca3163105c
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_022.cpp
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 fd1, fd2, ret, len;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile2[50] = { JFFS_PATH_NAME0 };
+ CHAR filebuf[20] = "1234567890";
+ CHAR readbuf[20] = {0};
+ off_t off;
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname1, "/dir1");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat(pathname2, "/dir2");
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ strcat(buffile1, "/dir1/file1");
+ fd1 = open(buffile1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, -1, fd1, EXIT6);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT6);
+
+ strcat(buffile2, "/dir2/file2");
+ fd2 = open(buffile2, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ off = lseek(fd2, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT8);
+
+ len = read(fd2, readbuf, 20); // read length: 20
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT8);
+
+ off = lseek(fd1, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT8); // file position: 20
+
+ len = read(fd1, readbuf, 20); // read length: 20
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT8);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT8);
+
+ ret = close(fd1); // ɾ³ý³É¹¦"/dir2/file2"
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT8);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT8);
+
+ ret = rename(buffile1, buffile2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT4);
+
+ ret = rmdir(pathname1); // dir1ɾ³ý³É¹¦
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT8);
+
+ fd2 = open(buffile2, O_NONBLOCK | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, -1, fd2, EXIT4);
+
+ len = read(fd2, readbuf, 20); // read length: 20
+ ICUNIT_GOTO_EQUAL(len, strlen(filebuf), len, EXIT4);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "1234567890", readbuf, EXIT4);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+
+ ret = unlink(buffile2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT4);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT8:
+ close(fd2);
+EXIT7:
+ JffsStrcat2(pathname1, "/dir2/file2", strlen(pathname1));
+ remove(pathname1);
+EXIT6:
+ close(fd1);
+EXIT5:
+ JffsStrcat2(pathname1, "/dir1/file1", strlen(pathname1));
+ remove(pathname1);
+ goto EXIT2;
+EXIT4:
+ close(fd2);
+EXIT3:
+ JffsStrcat2(pathname1, "/dir2/file2", strlen(pathname1));
+ remove(pathname1);
+ goto EXIT6;
+EXIT2:
+ JffsStrcat2(pathname1, "/dir2", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir1", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs022(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_022", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_026.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_026.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5e2dbde6ffcd749d851fa654a273b73e5c94d419
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_026.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 ret, fd, len;
+ off_t off;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile[50] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[301] = {0};
+ struct statfs buf1 = { 0 };
+ struct statfs buf2 = { 0 };
+ struct statfs buf3 = { 0 };
+ struct statfs buf4 = { 0 };
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname1, "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(buffile, "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = statfs(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.f_bavail, buf2.f_bavail, buf1.f_bavail, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.f_bfree, buf2.f_bfree, buf1.f_bfree, EXIT3);
+
+ len = write(fd,
+ "12345678901234567890123456789012345678901234567890abcdefghjk12345678901234567890123456789012345678901234567890"
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ 300); // write length: 300
+ ICUNIT_GOTO_EQUAL(len, 300, len, EXIT3);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT3);
+
+ len = read(fd, readbuf, 300); // read length: 300
+ ICUNIT_GOTO_EQUAL(len, 300, len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf,
+ "12345678901234567890123456789012345678901234567890abcdefghjk12345678901234567890123456789012345678901234567890"
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ readbuf, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = statfs(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = statfs(buffile, &buf4);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = unlink(buffile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ JffsStrcat2(pathname1, "/dir/files", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ JffsStrcat2(pathname1, "dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs026(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_026", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_027.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_027.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..816211ef81e63f6dface4e57f68631a255565fc6
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_027.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 ret, fd, len;
+ off_t off;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR buffile[50] = { JFFS_PATH_NAME0 };
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct stat buf3 = { 0 };
+ CHAR writebuf[20] = "ABCDEFGHJK";
+ CHAR readbuf[20] = {0};
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ strcat(pathname1, "/dir");
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ strcat(buffile, "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT3);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT3);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, -1, off, EXIT3);
+
+ len = read(fd, readbuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT3);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf2);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+ JffsStatPrintf(buf3);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_size, 10, buf1.st_size, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf2.st_size, 10, buf2.st_size, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf3.st_size, 0, buf3.st_size, EXIT3);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_mode & S_IFMT, S_IFREG, buf1.st_mode & S_IFMT, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf2.st_mode & S_IFMT, S_IFREG, buf2.st_mode & S_IFMT, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf3.st_mode & S_IFMT, S_IFDIR, buf3.st_mode & S_IFMT, EXIT3);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_blocks, buf2.st_blocks, buf1.st_blocks, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_size, buf2.st_size, buf1.st_size, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_blksize, buf2.st_blksize, buf1.st_blksize, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_ino, buf2.st_ino, buf1.st_ino, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_mode, buf2.st_mode, buf1.st_mode, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_mtim.tv_nsec, buf2.st_mtim.tv_nsec, buf1.st_mtim.tv_nsec, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(buffile);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ remove(buffile);
+EXIT1:
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs027(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_027", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_034.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_034.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..882cba32b53a41a5cd20059fc1e4d06ff28601f4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_034.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 ret, fd, len;
+ DIR *dir = NULL;
+ CHAR pathname1[50] = "/storage";
+ CHAR pathname2[50] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[20] = {0};
+
+ ret = mkdir(pathname2, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = umount(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ dir = opendir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(dir, NULL, dir, EXIT2);
+
+ ret = mount(JFFS_DEV_PATH0, "/storage", JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ dir = opendir(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT3);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ mount(JFFS_DEV_PATH0, "/storage", JFFS_FILESYS_TYPE, 0, NULL);
+ closedir(dir);
+ goto EXIT;
+EXIT1:
+ mount(JFFS_DEV_PATH0, "/storage", JFFS_FILESYS_TYPE, 0, NULL);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs034(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_034", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_035.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_035.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..09494447b2b366f01177cb4b5358d334ea7e502e
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_035.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 ret, fd, len;
+ CHAR pathname1[50] = { JFFS_PATH_NAME0 };
+ CHAR readbuf[50] = {0};
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, "01234567890123456789012345", 16); // write length: 16
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = umount("/jffs2_test");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = mount(JFFS_DEV_PATH0, "/jffs2_test", JFFS_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, "01234567890123456789012345", 16); // write length: 16
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = read(fd, readbuf, 20); // read length: 20
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT1); // file length: 16
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = umount("/jffs2_test/test/test123");
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = umount(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = mount(NULL, "/jffs2_test", "storage", 0, NULL);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = access("/jffs2_test", F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = access(pathname1, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ mount(JFFS_DEV_PATH0, "/jffs2_test", JFFS_FILESYS_TYPE, 0, NULL);
+EXIT1:
+ close(fd);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs035(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_035", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_094.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_094.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..09c9fa55c46150de7aa20854a23fe9969277b7ca
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_094.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ off_t off;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = ioctl(fd, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, -ENOSYS, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs094(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_094", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_095.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_095.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9fcafaaa0fbcf08edd619d771ac9897cdda5b8df
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_095.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ CHAR writebuf[JFFS_STANDARD_NAME_LENGTH] = "0123456789";
+
+ ret = mkdir(pathname1, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname2, "/test");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT2);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, strlen(writebuf), len, EXIT2);
+
+ ret = fsync(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ remove(pathname2);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs095(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_095", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_103.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_103.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3deef21bf9b4309032d4bc51c4aaee90a3fa75a7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_103.cpp
@@ -0,0 +1,101 @@
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+/* INT32 ret,fd,len;
+ off_t off;
+ CHAR pathname1[50] = JFFS_PATH_NAME0;
+ CHAR pathname2[50]=JFFS_PATH_NAME0;
+ struct stat64 buf1={0};
+ struct stat64 buf2={0};
+ struct stat buf3={0};
+ CHAR readbuf[20]={0};
+
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat(pathname1, "/dir");
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ strcat(pathname2, "/dir/files");
+ fd = open64(pathname2, O_NONBLOCK | O_CREAT | O_RDWR, 0777);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT3);
+
+ len = write(fd, "ABCDEFGHJK", 10);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT3);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(off, JFFS_IS_ERROR, off, EXIT3);
+
+ len = read(fd,readbuf,10);
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "ABCDEFGHJK", readbuf, EXIT3);
+
+ ret = stat64(pathname2, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ jffs_stat64_printf(buf1);
+
+ ret = fstat64(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ jffs_stat64_printf(buf2);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+ jffs_stat_printf(buf3);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_size, 10, buf1.st_size, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf2.st_size, 10, buf2.st_size, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf3.st_size, 0, buf3.st_size, EXIT3);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_mode& S_IFMT, S_IFREG, buf1.st_mode& S_IFMT, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf2.st_mode& S_IFMT, S_IFREG, buf2.st_mode& S_IFMT, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf3.st_mode& S_IFMT, S_IFDIR, buf3.st_mode& S_IFMT, EXIT3);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_blocks, buf2.st_blocks, buf1.st_blocks, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_size, buf2.st_size, buf1.st_size, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_blksize, buf2.st_blksize, buf1.st_blksize, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_ino, buf2.st_ino, buf1.st_ino, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_mode& S_IFMT, buf2.st_mode& S_IFMT, buf1.st_mode& S_IFMT, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.st_mtim.tv_nsec, buf2.st_mtim.tv_nsec, buf1.st_mtim.tv_nsec, EXIT3);
+
+ ret = close(fd) ;
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(pathname2) ;
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT3:
+ close(fd);
+EXIT2:
+ jffs_strcat2(pathname1, "/dir/files",strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ jffs_strcat2(pathname1, "/dir",strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(JFFS_PATH_NAME0);
+ return JFFS_NO_ERROR;*/
+}
+
+/*
+**********
+testcase brief in English
+**********
+*/
+
+VOID IT_FS_JFFS_103(VOID)
+{
+
+ TEST_ADD_CASE("IT_FS_JFFS_103", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+
+}
+
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_535.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_535.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..da5aa8307f061f82abf01aca26c1cc8885a0c367
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_535.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static UINT32 testcase(VOID)
+{
+ INT32 fd, len, ret;
+ CHAR filebuf[JFFS_STANDARD_NAME_LENGTH] = "1234567890abcde&";
+ CHAR readbuf[JFFS_STANDARD_NAME_LENGTH] = {0};
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+ long off;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, HIGHEST_AUTHORITY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT1);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT1);
+
+ len = write(fd, "END", 3); // write length: 3
+ ICUNIT_GOTO_EQUAL(len, 3, len, EXIT1);
+
+ off = lseek64(fd, JFFS_SHORT_ARRAY_LENGTH, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, JFFS_SHORT_ARRAY_LENGTH, off, EXIT1);
+
+ len = read(fd, readbuf, 6); // read length: 6
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcde&", readbuf, EXIT1);
+
+ off = lseek64(fd, 2, SEEK_CUR); // seek offset: 2
+ ICUNIT_GOTO_EQUAL(off, 18, off, EXIT1); // file position: 18
+
+ memset(readbuf, 0, sizeof(readbuf));
+
+ len = read(fd, readbuf, 5); // read length: 5
+ ICUNIT_GOTO_EQUAL(len, 5, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "34567", readbuf, EXIT1);
+
+ off = lseek64(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, 23, off, EXIT1); // file position: 23
+
+ len = read(fd, readbuf, 5); // read length: 5
+ ICUNIT_GOTO_EQUAL(len, 5, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "890ab", readbuf, EXIT1);
+
+ off = lseek64(fd, -2, SEEK_CUR); // seek offset: -2
+ ICUNIT_GOTO_EQUAL(off, 26, off, EXIT1); // file position: 26
+
+ len = read(fd, readbuf, 6); // read length: 6
+ ICUNIT_GOTO_EQUAL(len, 6, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "abcde&", readbuf, EXIT1);
+
+ off = lseek64(fd, -2, SEEK_END); // seek offset: -2
+ ICUNIT_GOTO_EQUAL(off, 49, off, EXIT1); // file size: 49
+
+ memset(readbuf, 0, sizeof(readbuf));
+ len = read(fd, readbuf, 5); // read length: 5
+ ICUNIT_GOTO_EQUAL(len, 2, len, EXIT1); // file size: 2
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "ND", readbuf, EXIT1);
+
+ off = lseek64(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 51, off, EXIT1); // file size: 51
+
+ len = read(fd, readbuf, 6); // read length: 6
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+
+ off = lseek64(fd, 2, SEEK_END); // seek offset: 2
+ ICUNIT_GOTO_EQUAL(off, 53, off, EXIT1); // file size: 53
+ len = read(fd, readbuf, 6); // read length: 6
+ ICUNIT_GOTO_EQUAL(len, JFFS_NO_ERROR, len, EXIT1);
+
+ len = write(fd, "mmm", 3); // write length: 3
+ ICUNIT_GOTO_EQUAL(len, 3, len, EXIT1);
+
+ off = lseek64(fd, -3, SEEK_END); // seek offset: -3
+ ICUNIT_GOTO_EQUAL(off, 53, off, EXIT1); // file size:49
+
+ len = read(fd, readbuf, 5); // read length: 5
+ ICUNIT_GOTO_EQUAL(len, 3, len, EXIT1); // file length: 3
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "mmm", readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return JFFS_NO_ERROR;
+}
+
+VOID ItFsJffs535(VOID)
+{
+ TEST_ADD_CASE("IT_FS_JFFS_535", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..33f32d8f5f58721990be6c8cebcb664a2f4c9548
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/It_vfs_jffs_Dac_001.cpp
@@ -0,0 +1,529 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+static uid_t g_testUID1 = 111;
+static uid_t g_testUID2 = 222;
+static char *g_testDIR = "TEST_D";
+
+/* umask */
+static int TestUmask(const char *path)
+{
+ mode_t mode;
+ int ret;
+ struct stat buf = { 0 };
+ char filename[128] = {0};
+
+ printf("%s, %d\n", __FUNCTION__, __LINE__);
+
+ mode = umask(0044); // umask: 0044
+ ICUNIT_ASSERT_EQUAL(mode, 0022, mode); // mode: 0022
+ mode = umask(0022); // umask: 0022
+ ICUNIT_ASSERT_EQUAL(mode, 0044, mode); // mode: 0044
+ sprintf(filename, "%s/%s", path, g_testDIR);
+ ret = mkdir(filename, HIGHEST_AUTHORITY);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = stat(filename, &buf);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(buf.st_mode, 040755, buf.st_mode);
+ rmdir(filename);
+ return 0;
+}
+
+/* open */
+static int TestOpen(const char *path)
+{
+ int ret;
+ char filename[64] = {0};
+ char filename1[64] = {0};
+ char filename2[64] = {0};
+ char filename3[64] = {0};
+
+ ret = setuid(g_testUID1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setgid(g_testUID1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ // uid 111, gid 111,home dir 0 0 757
+
+ sprintf(filename, "%s/%s", path, g_testDIR);
+ ret = mkdir(filename, 0753); // mode: 0753
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ sprintf(filename1, "%s/%s", filename, "f1");
+ ret = open(filename1, O_CREAT | O_WRONLY, 0755); // mode: 0755
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ close(ret);
+
+ ret = setuid(g_testUID2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setgid(g_testUID1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ // uid 222, gid 111,home dir 111 111 753
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ sprintf(filename2, "%s/%s", filename, "f2");
+ ret = open(filename2, O_CREAT | O_WRONLY, 0755); // mode: 0755
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ret = open(filename1, O_WRONLY);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(EACCES, errno, errno);
+
+ ret = setgid(g_testUID2);
+ // uid 222, gid 222,home dir 111 111 753
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ sprintf(filename3, "%s/%s", filename, "f3");
+ ret = open(filename3, O_CREAT | O_WRONLY, 0755); // mode: 0755
+ printf("%s, %d ret %d\n", __FUNCTION__, __LINE__, ret);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ close(ret);
+ ret = unlink(filename3);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ // file mode 755
+ ret = open(filename1, O_WRONLY);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ret = open(filename1, O_RDONLY);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ close(ret);
+
+ ret = setuid(g_testUID1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setgid(g_testUID1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = unlink(filename1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setuid(0);
+ ret = setgid(0);
+ ret = rmdir(filename);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+/* unlink */
+static int TestUnlink(const char *path)
+{
+ int ret;
+ char filename[64] = {0};
+ char filename1[64] = {0};
+
+ printf("%s, %d\n", __FUNCTION__, __LINE__);
+ // uid 0, gid 0, home dir 0 0 757
+ sprintf(filename, "%s/%s", path, g_testDIR);
+ ret = mkdir(filename, 0757); // mode 757
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ sprintf(filename1, "%s/%s", filename, "f1");
+
+ ret = open(filename1, O_CREAT | O_WRONLY, 0755); // mode: 0755
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ close(ret);
+
+ ret = setuid(g_testUID2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ // uid 222, gid 0
+ ret = unlink(filename1);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ret = setgid(g_testUID2);
+ // uid 222, gid 222
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = unlink(filename1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = rmdir(filename);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setuid(0);
+ ret = setgid(0);
+
+ return 0;
+}
+
+/* mkdir */
+/* rmdir */
+static int TestMkdir(const char *path)
+{
+ int ret;
+ char filename[64] = {0};
+
+ printf("%s, %d\n", __FUNCTION__, __LINE__);
+ // uid 0, gid 0, home dir 0 0 757
+ sprintf(filename, "%s/%s", path, g_testDIR);
+ ret = mkdir(filename, 0735); // mode 735
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = setuid(g_testUID2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = rmdir(filename);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = setgid(g_testUID2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = rmdir(filename);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = setuid(0);
+ ret = setgid(0);
+
+ return 0;
+}
+
+/* chmod */
+static int TestChmod(const char *path)
+{
+ int ret;
+ struct stat buf = { 0 };
+ char filename[64] = {0};
+ char filename1[64] = {0};
+
+ printf("%s, %d\n", __FUNCTION__, __LINE__);
+ // uid 0, gid 0, home dir 0 0 757
+ sprintf(filename, "%s/%s", path, g_testDIR);
+ ret = mkdir(filename, 0757); // mode 757
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ sprintf(filename1, "%s/%s", filename, "f1");
+
+ setuid(g_testUID2);
+ ret = chmod(filename, 0111); // mode: 0111
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ setuid(0);
+ ret = chmod(filename, 0111); // mode: 0111
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = stat(filename, &buf);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(buf.st_mode, 040111, buf.st_mode); // mode: 040111
+
+ ret = rmdir(filename);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setuid(0);
+ ret = setgid(0);
+
+ return 0;
+}
+
+/* stat chdir */
+static int TestStatChdir(const char *path)
+{
+ int ret;
+ struct stat buf = { 0 };
+ char filename[64] = {0};
+ char filename1[64] = {0};
+
+ printf("%s, %d\n", __FUNCTION__, __LINE__);
+ // uid 0, gid 0, home dir 0 0 757
+ sprintf(filename, "%s/%s", path, g_testDIR);
+ ret = mkdir(filename, 0700); // mode: 0700
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ sprintf(filename1, "%s/%s", filename, "f1");
+
+ ret = mkdir(filename1, 0755); // mode: 0755
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ ret = setuid(g_testUID2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ // uid 222, gid 0
+ ret = chdir(filename);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(EACCES, errno, errno);
+ ret = stat(filename1, &buf);
+ printf("%s, %d ret %d errno %d\n", __FUNCTION__, __LINE__, ret, errno);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = setuid(0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ // uid 222, gid 0
+ ret = chdir(filename);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = stat(filename1, &buf);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = rmdir(filename1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = chdir(JFFS_MAIN_DIR0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = rmdir(filename);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setuid(0);
+ ret = setgid(0);
+
+ return 0;
+}
+
+/* rename */
+static int TestRename(const char *path)
+{
+ int ret;
+ char filename[64] = {0};
+ char filename1[64] = {0};
+ char filename2[64] = {0};
+
+ ret = setuid(g_testUID1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setgid(g_testUID1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ // uid 111, gid 111,home dir 0 0 757
+
+ sprintf(filename, "%s/%s", path, g_testDIR);
+ ret = mkdir(filename, 0711); // mode: 0711
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ sprintf(filename1, "%s/%s", filename, "f1");
+ ret = mkdir(filename1, 0755); // mode: 0755
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ close(ret);
+
+ sprintf(filename2, "%s/%s", filename, "f2");
+ ret = rename(filename1, filename2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = setuid(g_testUID2);
+ // uid 222, gid 222,home dir 111 111 753
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ sprintf(filename2, "%s/%s", filename, "f2");
+ ret = rename(filename2, filename1);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = setuid(g_testUID1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setgid(g_testUID1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = rmdir(filename2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setuid(0);
+ ret = setgid(0);
+ ret = rmdir(filename);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+
+/* execve */
+/* access */
+static int TestAccess(const char *path)
+{
+ int ret;
+ char filename[64] = {0};
+
+ printf("%s, %d\n", __FUNCTION__, __LINE__);
+ // uid 0, gid 0, home dir 0 0 757
+ sprintf(filename, "%s/%s", path, g_testDIR);
+ ret = mkdir(filename, 0757); // mode 757
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = access(filename, F_OK);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = access(filename, R_OK);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = chmod(filename, 0311); // mode: 0311
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = access(filename, R_OK);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ret = access(filename, W_OK);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = chmod(filename, 0111); // mode: 0111
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = access(filename, W_OK);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ret = access(filename, X_OK);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = chmod(filename, 0011); // mode: 0011
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = access(filename, X_OK);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = rmdir(filename);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setuid(0);
+ ret = setgid(0);
+
+ return 0;
+}
+
+static int SetReadAndSearch()
+{
+ int capNum = 2;
+ struct __user_cap_header_struct capheader;
+ struct __user_cap_data_struct capdata[capNum];
+ int ret;
+
+ memset(&capheader, 0, sizeof(struct __user_cap_header_struct));
+ memset(capdata, 0, capNum * sizeof(struct __user_cap_data_struct));
+ capdata[0].permitted = 0xffffffff;
+ capdata[1].permitted = 0xffffffff;
+ capheader.version = _LINUX_CAPABILITY_VERSION_3;
+ capdata[CAP_TO_INDEX(CAP_SETPCAP)].effective |= CAP_TO_MASK(CAP_SETPCAP);
+ capdata[CAP_TO_INDEX(CAP_SETUID)].effective |= CAP_TO_MASK(CAP_SETUID);
+ capdata[CAP_TO_INDEX(CAP_SETGID)].effective |= CAP_TO_MASK(CAP_SETGID);
+ capdata[CAP_TO_INDEX(CAP_CHOWN)].effective |= CAP_TO_MASK(CAP_CHOWN);
+ capdata[CAP_TO_INDEX(CAP_DAC_READ_SEARCH)].effective |= CAP_TO_MASK(CAP_DAC_READ_SEARCH);
+ ret = capset(&capheader, &capdata[0]);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return 0;
+}
+
+static int TestCapReadSearch()
+{
+ int ret;
+ char filenameParent[64] = {0};
+ char filenameChild[64] = {0};
+
+ ret = setuid(0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setgid(0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = mkdir("/storage/test_jffs2", 0757); // mode 0757
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ sprintf(filenameParent, "%s/%s", "/storage/test_jffs2", "testParent");
+ sprintf(filenameChild, "%s/%s", filenameParent, "testChild");
+ ret = mkdir(filenameParent, 0222); // mode 0222
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ SetReadAndSearch();
+ ret = mkdir(filenameChild, 0777); // mode 0777
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = rmdir(filenameParent);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = rmdir("/storage/test_jffs2");
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+/* execve */
+/* access */
+
+static int TestJffsDac(const char *path)
+{
+ int ret = TestUmask(path);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ umask(0);
+ ret = TestOpen(path);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = TestUnlink(path);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = TestMkdir(path);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = TestChmod(path);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = TestStatChdir(path);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = TestRename(path);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = TestAccess(path);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ umask(0022); // umask: 0022
+ return 0;
+}
+
+static int ChildFunc(VOID)
+{
+ int capNum = 2;
+ struct __user_cap_header_struct capheader;
+ struct __user_cap_data_struct capdata[capNum];
+ int ret;
+
+ memset(&capheader, 0, sizeof(struct __user_cap_header_struct));
+ memset(capdata, 0, capNum * sizeof(struct __user_cap_data_struct));
+ capdata[0].permitted = 0xffffffff;
+ capdata[1].permitted = 0xffffffff;
+ capheader.version = _LINUX_CAPABILITY_VERSION_3;
+ capdata[CAP_TO_INDEX(CAP_SETPCAP)].effective |= CAP_TO_MASK(CAP_SETPCAP);
+ capdata[CAP_TO_INDEX(CAP_SETUID)].effective |= CAP_TO_MASK(CAP_SETUID);
+ capdata[CAP_TO_INDEX(CAP_SETGID)].effective |= CAP_TO_MASK(CAP_SETGID);
+ capdata[CAP_TO_INDEX(CAP_CHOWN)].effective |= CAP_TO_MASK(CAP_CHOWN);
+ ret = capset(&capheader, &capdata[0]);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setuid(0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setgid(0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ /* jffs2 & rootfs test case */
+ ret = mkdir("/storage/test_jffs", 0757); // mode 757
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ chmod("/storage/test_jffs", 0757); // mode 757
+ ret = TestJffsDac("/storage/test_jffs");
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ rmdir("/storage/test_jffs");
+
+ ret = setuid(2); // uid: 2
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = setgid(2); // gid: 2
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+static int testcase(VOID)
+{
+ int ret;
+ int status = 0;
+ pid_t pid = fork();
+ ICUNIT_GOTO_WITHIN_EQUAL(pid, 0, 100000, pid, EXIT); // pid must in range 0 - 100000
+ if (pid == 0) {
+ ret = ChildFunc();
+ printf("err line :%d error code: %d\n", 0, 0);
+ exit(0);
+ }
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_GOTO_EQUAL(ret, pid, ret, EXIT);
+
+ pid = fork();
+ ICUNIT_GOTO_WITHIN_EQUAL(pid, 0, 100000, pid, EXIT); // pid must in range 0 - 100000
+ if (pid == 0) {
+ ret = TestCapReadSearch();
+ printf("err line :%d error code: %d\n", 0, 0);
+ exit(0);
+ }
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_GOTO_EQUAL(ret, pid, ret, EXIT);
+ status = WEXITSTATUS(status);
+ ICUNIT_GOTO_EQUAL(status, 0, status, EXIT);
+
+ return 0;
+
+EXIT:
+ return 1;
+}
+
+
+void ItTestDac001(void)
+{
+ TEST_ADD_CASE("IT_SEC_DAC_001", testcase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_001.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bb4fabd004a0ca74f2bf82ad0656f758947b1dac
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_001.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+#define FILEPATH "/storage/test.txt"
+
+static int TestCase(void)
+{
+ FILE *fp = NULL;
+ int fd = -1;
+ char buf[10U] = "123456789";
+ char rdbuf[10U] = {0};
+ int ret = -1;
+
+ fd = open(FILEPATH, O_RDWR | O_EXCL | O_CREAT, JFFS_FILE_MODE);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ /* r+ */
+ fp = fdopen(fd, "r+");
+ ICUNIT_GOTO_NOT_EQUAL(fp, JFFS_TO_NULL, fp, EXIT);
+
+ ret = fwrite(buf, 10U, 1, fp);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = fseek(fp, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = fread(rdbuf, 10U, 1, fp);
+ ICUNIT_GOTO_EQUAL(ret, 1, ret, EXIT);
+
+ ret = fclose(fp);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ fd = open(FILEPATH, O_RDWR);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ /* a+ */
+ fp = fdopen(fd, "a+");
+ ICUNIT_GOTO_NOT_EQUAL(fp, JFFS_TO_NULL, fp, EXIT);
+
+ ret = fwrite(buf, 10U, 1, fp);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = fseek(fp, 0, SEEK_SET);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = fread(rdbuf, 10U, 1, fp);
+ ICUNIT_GOTO_EQUAL(ret, 1, ret, EXIT);
+
+ ret = fclose(fp);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = remove(FILEPATH);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ fclose(fp);
+ remove(FILEPATH);
+
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs001(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_001", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_002.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..49b577bbb39af7da35e4e4319c7161bec889408b
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_002.cpp
@@ -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.
+ */
+#include "It_fs_jffs.h"
+#include
+#include
+#include
+
+#define FILEPATH "/storage/test.txt"
+#define FILEPATHLEN (strlen(FILEPATH) + 1U)
+
+static int TestCase(void)
+{
+ INT32 fd = -1;
+ INT32 ret = 0;
+ CHAR pathname[FILEPATHLEN] = FILEPATH;
+ struct statvfs fileInfo = {0};
+
+ fd = open(pathname, O_CREAT | O_RDWR | O_EXCL, JFFS_FILE_MODE);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ ret = fstatvfs(fd, &fileInfo);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ close(fd);
+ remove(pathname);
+
+ return JFFS_NO_ERROR;
+
+EXIT:
+ close(fd);
+ remove(pathname);
+
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs002(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_002", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_003.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..93976ce4007f2aab3bd190361f4a5e2e79e4a4e5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_003.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+#define DIRPATH1 "/storage/test1"
+#define DIRPATH2 "/storage/test2"
+
+static int TestCase(void)
+{
+ INT32 ret = -1;
+ INT32 dirFd = -1;
+ INT32 fd = -1;
+ INT32 len = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = DIRPATH1;
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = DIRPATH2;
+ DIR *dir = NULL;
+
+ ret = mkdir(pathname1, JFFS_FILE_MODE);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = renameat(AT_FDCWD, DIRPATH1, AT_FDCWD, DIRPATH2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ dir = opendir(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ dirFd = dirfd(dir);
+ ICUNIT_GOTO_NOT_EQUAL(dirFd, JFFS_IS_ERROR, dirFd, EXIT1);
+
+ ret = strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test1.txt");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname2, O_EXCL | O_CREAT | O_RDWR, JFFS_FILE_MODE);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, "01234567890", 11);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = renameat(dirFd, "test1.txt", dirFd, "test2.txt");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = unlink("/storage/test2/test2.txt");
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = rmdir(DIRPATH2);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(fd);
+EXIT2:
+ unlink(pathname2);
+ closedir(dir);
+EXIT:
+ rmdir(DIRPATH2);
+ return JFFS_NO_ERROR;
+}
+
+void ItTestFsJffs003(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_003", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_004.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2af3c8fd479a91bbe107a2609877feef14cc2d33
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_004.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+#define MOUNT_FILEPATH "/storage/mounts"
+
+static int TestCase(void)
+{
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = MOUNT_FILEPATH;
+ struct mntent *mnt = NULL;
+ FILE *fp = NULL;
+ int ret = -1;
+ struct mntent mountsData = {
+ .mnt_fsname = "jffs",
+ .mnt_dir = "/",
+ .mnt_type = "jffs",
+ .mnt_opts = nullptr,
+ .mnt_freq = 0,
+ .mnt_passno = 0,
+ };
+
+ fp = setmntent(pathname1, "r+");
+ ICUNIT_GOTO_NOT_EQUAL(fp, NULL, fp, EXIT);
+
+ mnt = getmntent(fp);
+ ICUNIT_GOTO_NOT_EQUAL(mnt, NULL, mnt, EXIT);
+
+ ret = strcmp(mnt->mnt_fsname, mountsData.mnt_fsname);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = strcmp(mnt->mnt_dir, mountsData.mnt_dir);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = strcmp(mnt->mnt_type, mountsData.mnt_type);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(mnt->mnt_freq, mountsData.mnt_freq, mnt.mnt_freq, EXIT);
+ ICUNIT_GOTO_EQUAL(mnt->mnt_passno, mountsData.mnt_passno, mnt.mnt_passno, EXIT);
+
+EXIT:
+ endmntent(fp);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs004(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_004", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_005.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8f21d415517b47c07395c2a2a07ccc0af0168ef5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_005.cpp
@@ -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.
+ */
+#include "It_fs_jffs.h"
+
+static int TestCase(void)
+{
+ FILE *fp = NULL;
+ char *buf = "hello tmpfile !";
+ char rbuf[20] = {0};
+ int i = 0;
+ int ret = -1;
+
+ fp = tmpfile();
+ ICUNIT_GOTO_NOT_EQUAL(fp, NULL, fp, EXIT);
+
+ ret = fwrite(buf, strlen(buf), 1, fp);
+ ICUNIT_GOTO_EQUAL(ret, 1, ret, EXIT);
+
+ ret = fseek(fp, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = fread(rbuf, strlen(buf), 1, fp);
+ ICUNIT_GOTO_EQUAL(ret, 1, ret, EXIT);
+
+ ret = memcmp(buf, rbuf, strlen(buf));
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ fclose(fp);
+ return JFFS_NO_ERROR;
+
+EXIT:
+ fclose(fp);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs005(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_005", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_008.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8c603fbb7403c5acc0be90f821496349efdc8aa3
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_008.cpp
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+#include
+
+#define FILE_PATH "/storage/testlockf.txt"
+
+/* F_TLOCKã€F_ULOCK */
+static int TestCase0(void)
+{
+ int fd = -1;
+ int ret;
+
+ fd = open(FILE_PATH, O_WRONLY, JFFS_FILE_MODE);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ /* lock 0-3 Regions */
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = lockf(fd, F_TLOCK, 3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ /* unlock 1 Regions */
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = lseek(fd, 1, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(ret, 1, ret, EXIT);
+
+ ret = lockf(fd, F_ULOCK, 1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ close(fd);
+ return 0;
+
+EXIT:
+ close(fd);
+ return -1;
+}
+
+/* F_TEST */
+static int TestCase1(void)
+{
+ int fd = -1;
+ int ret;
+
+ fd = open(FILE_PATH, O_WRONLY, JFFS_FILE_MODE);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ /* lock 0-3 Regions */
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = lockf(fd, F_LOCK, 3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ /* try lock 1 Region */
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = lseek(fd, 1, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(ret, 1, ret, EXIT);
+
+ ret = lockf(fd, F_TEST, 1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ /* try lock 3 Region */
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = lseek(fd, 3, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(ret, 3, ret, EXIT);
+
+ ret = lockf(fd, F_TEST, 1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ close(fd);
+ return 0;
+
+EXIT:
+ close(fd);
+ return -1;
+}
+
+/* F_LOCK */
+static int TestCase2(void)
+{
+ int fd = -1;
+ int ret;
+
+ fd = open(FILE_PATH, O_WRONLY, JFFS_FILE_MODE);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ /* lock 0-3 Regions */
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = lockf(fd, F_LOCK, 3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ /* lock 2-5 Region */
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = lseek(fd, 2, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(ret, 2, ret, EXIT);
+
+ ret = lockf(fd, F_LOCK, 3);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ close(fd);
+ return 0;
+
+EXIT:
+ close(fd);
+ return -1;
+}
+
+static int TestCase(void)
+{
+ int fd = -1;
+ int ret;
+
+ fd = open(FILE_PATH, O_WRONLY | O_CREAT, JFFS_FILE_MODE);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = TestCase0();
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = TestCase1();
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = TestCase2();
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+EXIT:
+ close(fd);
+ unlink(FILE_PATH);
+}
+
+void ItTestFsJffs008(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_008", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_010.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..883630d3bbc5f15a8bb4f981eabf782a315562b5
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_010.cpp
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_fs_jffs.h"
+#include
+
+#define RECV_SIGNUM 5U
+
+#define RTSIG0 (SIGRTMIN + 7)
+#define RTSIG1 (SIGRTMIN + 6)
+#define ERRSIG (SIGRTMAX + 10)
+
+static int m_sig[RECV_SIGNUM] = {0};
+static char *m_recvData = NULL;
+char m_msg[] = "hello sigqueue";
+static int m_recvCount = 0;
+
+void Handler(int sig, siginfo_t *info, void *ctx)
+{
+ m_sig[m_recvCount] = sig;
+ m_recvData = (char *)info->si_value.sival_ptr;
+ m_recvCount++;
+}
+
+void SonProcess0(pid_t pid)
+{
+ union sigval msg;
+
+ msg.sival_ptr = m_msg;
+ sigqueue(pid, RTSIG1, msg);
+ sigqueue(pid, RTSIG0, msg);
+ sigqueue(pid, RTSIG1, msg);
+
+ sleep(3);
+ exit(0);
+}
+
+static int TestCase0(void)
+{
+ pid_t pid0 = -1;
+ pid_t pid1 = -1;
+ int ret = -1;
+ struct sigaction act = {0};
+ act.sa_sigaction = Handler;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = SA_SIGINFO;
+ int i = 0;
+ int expectSig[RECV_SIGNUM] = {RTSIG1, RTSIG0, RTSIG1};
+
+ ret = sigaction(RTSIG1, &act, NULL);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = sigaction(RTSIG0, &act, NULL);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ pid1 = getpid();
+ pid0 = fork();
+ if (pid0 == 0) {
+ SonProcess0(pid1);
+ } else {
+ sleep(2);
+ for (i = 0; i 0) {
+ close(fd);
+ }
+ unlink(pathname2);
+EXIT:
+ rmdir(pathname2);
+ rmdir(pathname1);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs101(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_101", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_102.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_102.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a2321b315e48881a8784b81c886f93bad315e6aa
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_102.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+#define TEST_STRLEN 30
+
+static int TestCase(void)
+{
+ INT32 fd = 0;
+ INT32 ret = JFFS_IS_ERROR;
+ CHAR pathname1[TEST_STRLEN] = JFFS_PATH_NAME0;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_EXCL, 0777);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = fchmod(fd, S_IREAD);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ if (fd > 0) {
+ close(fd);
+ }
+ unlink(pathname1);
+EXIT:
+ rmdir(pathname1);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs102(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_102", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_103.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_103.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9c8f3045fdab30521fa022c4dbf3cf86bc2e93c4
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_103.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+#define TEST_STRLEN 30
+
+static int TestCase(void)
+{
+ INT32 dirfd = 0;
+ INT32 fd = 0;
+ INT32 ret = JFFS_IS_ERROR;
+ CHAR pathname0[TEST_STRLEN] = JFFS_PATH_NAME0;
+ CHAR pathname1[TEST_STRLEN] = JFFS_PATH_NAME0;
+ CHAR pathname2[TEST_STRLEN] = JFFS_PATH_NAME0;
+ struct stat info = {0};
+
+ ret = mkdir(pathname0, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, TEST_STRLEN, "/test1");
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chmod(pathname1, S_IRUSR | S_IRGRP | S_IROTH);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ stat(pathname1, &info);
+ ret = info.st_mode & (S_IRUSR | S_IRGRP | S_IROTH);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+
+ dirfd = open(pathname0, O_DIRECTORY);
+ ICUNIT_GOTO_NOT_EQUAL(dirfd, JFFS_IS_ERROR, dirfd, EXIT);
+
+ ret = fchmodat(fd, "test1", S_IREAD, 0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ stat(pathname1, &info);
+ ret = info.st_mode & S_IREAD;
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+
+ ret = close(dirfd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dirfd = open(pathname0, O_DIRECTORY);
+ ICUNIT_GOTO_NOT_EQUAL(dirfd, JFFS_IS_ERROR, dirfd, EXIT);
+
+ strcat_s(pathname2, TEST_STRLEN, "/test.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, 0777);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = chmod(pathname2, S_IRUSR | S_IRGRP | S_IROTH);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ stat(pathname2, &info);
+ ret = info.st_mode & (S_IRUSR | S_IRGRP | S_IROTH);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = fchmodat(dirfd, "test.txt", S_IREAD, 0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ stat(pathname2, &info);
+ ret = info.st_mode & S_IREAD;
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+
+ ret = close(dirfd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT1:
+ if (dirfd > 0) {
+ close(dirfd);
+ }
+ if (fd > 0) {
+ close(fd);
+ }
+EXIT:
+ remove(pathname2);
+ remove(pathname1);
+ remove(pathname0);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs103(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_103", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_104.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_104.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4957e7bd296d9e401a4cee48573d142366e206f7
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_104.cpp
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+#define TEST_STRLEN 30
+
+static int TestCase(void)
+{
+ INT32 fd = 0;
+ INT32 dirfd = 0;
+ INT32 ret = JFFS_IS_ERROR;
+ CHAR pathname0[TEST_STRLEN] = JFFS_PATH_NAME0;
+ CHAR pathname1[TEST_STRLEN] = JFFS_PATH_NAME0;
+ CHAR pathname2[TEST_STRLEN] = JFFS_PATH_NAME0;
+ struct stat info = {0};
+
+ ret = mkdir(pathname0, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, TEST_STRLEN, "/test1");
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chown(pathname1, 1, 1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ stat(pathname1, &info);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_uid, 1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_gid, 1, ret, EXIT);
+
+ dirfd = open(pathname1, O_DIRECTORY);
+ fd = dirfd;
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = fchown(fd, 10, 10);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ stat(pathname1, &info);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_uid, 10, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_gid, 10, ret, EXIT1);
+
+ ret = close(dirfd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, TEST_STRLEN, "/test.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, 0777);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = chown(pathname2, 1, 1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ stat(pathname2, &info);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_uid, 1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_gid, 1, ret, EXIT1);
+
+ ret = fchown(fd, 10, 10);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ stat(pathname2, &info);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_uid, 10, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_gid, 10, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ if (dirfd > 0) {
+ close(dirfd);
+ }
+ if (fd > 0) {
+ close(fd);
+ }
+EXIT:
+ remove(pathname2);
+ remove(pathname1);
+ remove(pathname0);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs104(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_104", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_105.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_105.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..824aca2e413f4e0116ea50e1ffbdc9d5aafab69a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_105.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+#define TEST_STRLEN 30
+
+static int TestCase(void)
+{
+ INT32 dirfd = 0;
+ INT32 fd = 0;
+ INT32 ret = JFFS_IS_ERROR;
+ CHAR pathname0[TEST_STRLEN] = JFFS_PATH_NAME0;
+ CHAR pathname1[TEST_STRLEN] = JFFS_PATH_NAME0;
+ CHAR pathname2[TEST_STRLEN] = JFFS_PATH_NAME0;
+ struct stat info = {0};
+
+ ret = mkdir(pathname0, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname1, TEST_STRLEN, "/test1");
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = chown(pathname1, 1, 1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ stat(pathname1, &info);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_uid, 1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_gid, 1, ret, EXIT);
+
+ dirfd = open(pathname0, O_DIRECTORY);
+ fd = dirfd;
+ ICUNIT_GOTO_NOT_EQUAL(dirfd, JFFS_IS_ERROR, dirfd, EXIT);
+
+ ret = fchownat(dirfd, "test1", 10, 10, 0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ stat(pathname1, &info);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_uid, 10, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_gid, 10, ret, EXIT1);
+
+ ret = close(dirfd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dirfd = open(pathname0, O_DIRECTORY);
+ ICUNIT_GOTO_NOT_EQUAL(dirfd, JFFS_IS_ERROR, dirfd, EXIT);
+
+ strcat_s(pathname2, TEST_STRLEN, "/test.txt");
+ fd = open(pathname2, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, 0777);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = chown(pathname2, 1, 1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ stat(pathname2, &info);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_uid, 1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_gid, 1, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = fchownat(dirfd, "test.txt", 10, 10, 0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ stat(pathname2, &info);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_uid, 10, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL((uid_t)info.st_gid, 10, ret, EXIT1);
+
+ ret = close(dirfd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname0);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ return JFFS_NO_ERROR;
+EXIT1:
+ if (dirfd > 0) {
+ close(dirfd);
+ }
+ if (fd > 0) {
+ close(fd);
+ }
+EXIT:
+ remove(pathname2);
+ remove(pathname1);
+ remove(pathname0);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs105(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_105", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_106.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_106.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4772382712e452ae015e45ee8fce140160b5e0f0
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_106.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+#define TEST_STR "abcdefghijk"
+
+static int TestCase(void)
+{
+ INT32 ret = JFFS_IS_ERROR;
+ INT32 fd = 0;
+ INT32 len = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME0;
+ CHAR buf[JFFS_STANDARD_NAME_LENGTH] = TEST_STR;
+ CHAR str[JFFS_STANDARD_NAME_LENGTH] = "";
+ FILE *ptr = NULL;
+ fd = open(pathname1, O_CREAT | O_RDWR, 0777);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+ len = write(fd, buf, JFFS_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT);
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
+ ptr = freopen(pathname1, "rb", stdin);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT1);
+ ret = scanf_s("%s", JFFS_STANDARD_NAME_LENGTH, str);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ ret = strcmp(buf, str);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fclose(ptr);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT1:
+ if (fd > 0) {
+ close(fd);
+ }
+EXIT:
+ unlink(pathname1);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs106(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_106", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_107.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_107.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..40da416a5e3d8bd1022f638224de8718cdb24387
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_107.cpp
@@ -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 "It_fs_jffs.h"
+
+#define TEST_STR "abcdefghijk"
+
+static int TestCase(void)
+{
+ INT32 ret, dirFd, fd, len;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ dirFd = dirfd(dir);
+ ICUNIT_GOTO_NOT_EQUAL(dirFd, JFFS_IS_ERROR, dirFd, EXIT1);
+
+ fd = openat(dirFd, "test.txt", O_CREAT | O_RDWR | O_TRUNC);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, "01234567890123456789012345", 16);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = unlinkat(dirFd, "test.txt", 0);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME01);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(fd);
+ unlink(pathname1);
+ closedir(dir);
+EXIT:
+ rmdir(JFFS_PATH_NAME01);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs107(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_107", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_108.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_108.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f2a2ba3205d22f71f62ec5d1280369a9d61d3727
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_108.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+static int TestCase(void)
+{
+ INT32 ret = JFFS_IS_ERROR;
+ INT32 fd = 0;
+ INT32 dirfd = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ time_t timep;
+ time_t timep1;
+ struct tm p;
+ struct stat fstate;
+ struct timespec times[2];
+ char dateTime[64];
+ struct tm t;
+
+ p.tm_sec = 30;
+ p.tm_min = 27;
+ p.tm_hour = 16;
+ p.tm_mday = 18;
+ p.tm_mon = 0;
+ p.tm_year = 2020 - 1900;
+ p.tm_wday = 1;
+ p.tm_yday = 17;
+ p.tm_isdst = 0;
+
+ timep = mktime(&p);
+
+ p.tm_min = 28;
+ p.tm_hour = 17;
+ timep1 = mktime(&p);
+
+ times[0].tv_sec = timep;
+ times[0].tv_nsec = 0;
+ times[1].tv_sec = timep1;
+ times[1].tv_nsec = 0;
+
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test.txt");
+ fd = open(pathname2, O_CREAT | O_RDWR | O_TRUNC);
+ dirfd = fd;
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ dirfd = open(pathname1, O_DIRECTORY);
+ ICUNIT_GOTO_NOT_EQUAL(dirfd, JFFS_IS_ERROR, dirfd, EXIT);
+
+ utimensat(dirfd, "test.txt", times, 0);
+ ret = stat(pathname2, &fstate);
+ ICUNIT_GOTO_EQUAL(fstate.st_atim.tv_sec, timep, fstate.st_atim.tv_sec, EXIT1);
+ ICUNIT_GOTO_EQUAL(fstate.st_mtim.tv_sec, timep1, fstate.st_mtim.tv_sec, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = close(dirfd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME01);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ if (fd > 0) {
+ close(fd);
+ }
+ if (dirfd > 0) {
+ close(dirfd);
+ }
+ unlink(pathname2);
+EXIT:
+ rmdir(JFFS_PATH_NAME01);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs108(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_108", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_109.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_109.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..227cb86ce1ad1176a6dd8c712ce5bf617d8bf698
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_109.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+static int TestCase(void)
+{
+ INT32 ret = JFFS_IS_ERROR;
+ INT32 fd = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ time_t timep;
+ time_t timep1;
+ struct tm p;
+ struct stat fstate;
+ struct timeval times[2];
+ char dateTime[64];
+ struct tm t;
+
+ p.tm_sec = 30;
+ p.tm_min = 27;
+ p.tm_hour = 16;
+ p.tm_mday = 18;
+ p.tm_mon = 0;
+ p.tm_year = 2020 - 1900;
+ p.tm_wday = 1;
+ p.tm_yday = 17;
+ p.tm_isdst = 0;
+
+ timep = mktime(&p);
+
+ p.tm_min = 28;
+ p.tm_hour = 17;
+ timep1 = mktime(&p);
+
+ times[0].tv_sec = timep;
+ times[0].tv_usec = 0;
+ times[1].tv_sec = timep1;
+ times[1].tv_usec = 0;
+
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test.txt");
+ fd = open(pathname2, O_CREAT | O_RDWR | O_TRUNC);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ utimes(pathname2, times);
+ ret = stat(pathname2, &fstate);
+ ICUNIT_GOTO_EQUAL(fstate.st_atim.tv_sec, timep, fstate.st_atim.tv_sec, EXIT1);
+ ICUNIT_GOTO_EQUAL(fstate.st_mtim.tv_sec, timep1, fstate.st_mtim.tv_sec, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME01);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ if (fd > 0) {
+ close(fd);
+ }
+ unlink(pathname2);
+EXIT:
+ rmdir(JFFS_PATH_NAME01);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs109(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_109", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_110.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_110.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a2c0b98d9d4e3353441d2a862e46de882b515b7f
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_110.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+static int TestCase(void)
+{
+ INT32 ret = JFFS_IS_ERROR;
+ INT32 fd = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ time_t timep;
+ time_t timep1;
+ struct tm p;
+ struct stat fstate;
+ struct utimbuf times;
+ char dateTime[64];
+ struct tm t;
+
+ p.tm_sec = 30;
+ p.tm_min = 27;
+ p.tm_hour = 16;
+ p.tm_mday = 18;
+ p.tm_mon = 0;
+ p.tm_year = 2020 - 1900;
+ p.tm_wday = 1;
+ p.tm_yday = 17;
+ p.tm_isdst = 0;
+
+ timep = mktime(&p);
+
+ p.tm_min = 28;
+ p.tm_hour = 17;
+ timep1 = mktime(&p);
+
+ times.actime = timep;
+ times.modtime = timep1;
+
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test.txt");
+ fd = open(pathname2, O_CREAT | O_RDWR | O_TRUNC);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ utime(pathname2, ×);
+ ret = stat(pathname2, &fstate);
+ ICUNIT_GOTO_EQUAL(fstate.st_atim.tv_sec, timep, fstate.st_atim.tv_sec, EXIT1);
+ ICUNIT_GOTO_EQUAL(fstate.st_mtim.tv_sec, timep1, fstate.st_mtim.tv_sec, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME01);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ if (fd > 0) {
+ close(fd);
+ }
+ unlink(pathname2);
+EXIT:
+ rmdir(JFFS_PATH_NAME01);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs110(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_110", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_111.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_111.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..62b79a8a6707a774e85af3dae6ad7c1bb4896f47
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_111.cpp
@@ -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 "It_fs_jffs.h"
+
+static int TestCase(void)
+{
+ INT32 ret = JFFS_IS_ERROR;
+ INT32 fd = 0;
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ time_t timep;
+ time_t timep1;
+ struct tm p;
+ struct stat fstate;
+ struct timespec times[2];
+ struct tm t;
+
+ p.tm_sec = 30;
+ p.tm_min = 27;
+ p.tm_hour = 16;
+ p.tm_mday = 18;
+ p.tm_mon = 0;
+ p.tm_year = 2020 - 1900;
+ p.tm_wday = 1;
+ p.tm_yday = 17;
+ p.tm_isdst = 0;
+
+ timep = mktime(&p);
+
+ p.tm_min = 28;
+ p.tm_hour = 17;
+ timep1 = mktime(&p);
+
+ times[0].tv_sec = timep;
+ times[0].tv_nsec = 0;
+ times[1].tv_sec = timep1;
+ times[1].tv_nsec = 0;
+
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test.txt");
+ fd = open(pathname2, O_CREAT | O_RDWR | O_TRUNC);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ futimens(fd, times);
+ ret = stat(pathname2, &fstate);
+ ICUNIT_GOTO_EQUAL(fstate.st_atim.tv_sec, timep, fstate.st_atim.tv_sec, EXIT1);
+ ICUNIT_GOTO_EQUAL(fstate.st_mtim.tv_sec, timep1, fstate.st_mtim.tv_sec, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname2);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = rmdir(JFFS_PATH_NAME01);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ if (fd > 0) {
+ close(fd);
+ }
+ unlink(pathname2);
+EXIT:
+ rmdir(JFFS_PATH_NAME01);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs111(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_111", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_112.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_112.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f973935380a7cfd6704114cbac122f4ae26720c1
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_112.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+static int TestCase(void)
+{
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = JFFS_MAIN_DIR0;
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = JFFS_MAIN_DIR0;
+ CHAR *dname = NULL;
+ INT32 ret;
+ INT32 fd = 0;
+ DIR *dir1 = NULL;
+ DIR *dir2 = NULL;
+
+ dir1 = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir1, NULL, dir1, EXIT);
+
+ ret = closedir(dir1);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test123");
+ ret = mkdir(pathname2, 0777);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ fd = open(pathname2, O_DIRECTORY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ dir2 = fdopendir(fd);
+ ICUNIT_GOTO_NOT_EQUAL(dir2, NULL, dir2, EXIT2);
+
+ ret = closedir(dir2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ if (fd) {
+ close(fd);
+ }
+ if (dir2) {
+ closedir(dir2);
+ }
+EXIT1:
+ remove(pathname2);
+ return JFFS_IS_ERROR;
+EXIT:
+ if (dir1) {
+ closedir(dir1);
+ }
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs112(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_112", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_113.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_113.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1e65fc74f8b6362200e3db13e12ea65017033a3a
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_113.cpp
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_fs_jffs.h"
+
+static FILE *g_filep;
+#define NUM 64
+#define COUNT 10
+
+void *DoChild()
+{
+ int fd = 0;
+ int ret, count;
+ char buf[NUM];
+
+ flockfile(g_filep);
+
+ if (fseek(g_filep, 0L, SEEK_SET) == -1) {
+ perror("fseek()");
+ }
+ ret = fread(buf, NUM, 1, g_filep);
+
+ count = atoi(buf);
+ ++count;
+ sprintf_s(buf, NUM, "%d", count);
+ if (fseek(g_filep, 0L, SEEK_SET) == -1) {
+ perror("fseek()");
+ }
+ ret = fwrite(buf, strlen(buf), 1, g_filep);
+
+ funlockfile(g_filep);
+
+ return NULL;
+}
+
+static int TestCase(void)
+{
+ INT32 ret = JFFS_IS_ERROR;
+ INT32 fd = 0;
+ INT32 count = 0;
+ pthread_t tid[COUNT];
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ CHAR buf[COUNT];
+
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ strcat_s(pathname2, JFFS_STANDARD_NAME_LENGTH, "/test12345.txt");
+ g_filep = fopen(pathname2, "w+");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ for (count = 0; count < COUNT; count++) {
+ ret = pthread_create(tid + count, NULL, DoChild, NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ for (count = 0; count < COUNT; count++) {
+ ret = pthread_join(tid[count], NULL);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = fclose(g_filep);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname2, O_RDONLY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ ret = read(fd, buf, COUNT);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = atoi(buf);
+ ICUNIT_GOTO_EQUAL(ret, COUNT, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+
+ ret = unlink(pathname2);
+ g_filep = nullptr;
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME01);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ if (fd > 0) {
+ close(fd);
+ }
+ unlink(pathname2);
+ g_filep = nullptr;
+EXIT:
+ rmdir(JFFS_PATH_NAME01);
+ return JFFS_IS_ERROR;
+}
+
+void ItTestFsJffs113(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_113", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_201.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_201.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8a0eec75ac9c1c513f71e281b055c28b6bf32c47
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_201.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_fs_jffs.h"
+#include
+#include
+
+#define FILEPATH "./test.txt"
+
+static int TestCase(void)
+{
+ int ret = -1;
+ int fd = -1;
+
+ fd = open(FILEPATH, O_RDWR | O_CREAT, 0777);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, JFFS_IS_ERROR, fd);
+
+ ret = isastream(fd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, JFFS_IS_ERROR, ret);
+
+ ret = close(fd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, JFFS_IS_ERROR, ret);
+
+ ret = remove(FILEPATH);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, JFFS_IS_ERROR, ret);
+}
+
+void ItTestFsJffs201(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_201", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_202.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_202.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7c1e3d5c8e758da018d19eabc697dc02242072f2
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_202.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_fs_jffs.h"
+
+#define FILEPATH "./test.txt"
+
+static int TestCase(void)
+{
+ FILE *stream = nullptr;
+ wchar_t *buf = nullptr;
+ size_t len = -1;
+ off_t eob = -1;
+ int ret = -1;
+
+ stream = open_wmemstream(&buf, &len);
+ ICUNIT_ASSERT_NOT_EQUAL(stream, NULL, JFFS_IS_ERROR);
+
+ fprintf(stream, "hello my world");
+
+ ret = fflush(stream);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, JFFS_IS_ERROR, ret);
+ ICUNIT_ASSERT_EQUAL(buf, "hello my world", -1);
+ eob = ftello(stream);
+ ICUNIT_ASSERT_NOT_EQUAL(eob, JFFS_IS_ERROR, eob);
+
+ ret = fseeko(stream, 0, SEEK_SET);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, JFFS_IS_ERROR, ret);
+
+ fprintf(stream, "good-bye");
+ ret = fseeko(stream, eob, SEEK_SET);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, JFFS_IS_ERROR, ret);
+
+ ret = fclose(stream);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, JFFS_IS_ERROR, ret);
+
+ ICUNIT_ASSERT_EQUAL(buf, "good-bye", -1);
+ free(buf);
+}
+
+void ItTestFsJffs202(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_202", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_203.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_203.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..85d6498a81f7cb3bb03f1cd5a7c6104561013941
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_203.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_fs_jffs.h"
+
+#define FILEPATH "./test.txt"
+
+static int TestCase(void)
+{
+ INT32 ret = -1;
+ INT32 dirFd = -1;
+ INT32 fd = -1;
+ INT32 len = -1;
+
+ CHAR pathname1[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ CHAR pathname2[JFFS_STANDARD_NAME_LENGTH] = JFFS_PATH_NAME01;
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+
+ ret = mkdir(pathname1, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ dirFd = dirfd(dir);
+ ICUNIT_GOTO_NOT_EQUAL(dirFd, JFFS_IS_ERROR, dirFd, EXIT1);
+
+ ret = strcat_s(pathname2, sizeof(pathname2), "/test.txt");
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
+ fd = open(pathname2, O_CREAT | O_RDWR | O_TRUNC);
+ ICUNIT_GOTO_NOT_EQUAL(fd, JFFS_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, "01234567890123456789012345", 16);
+
+ ret = close(fd);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = renameat(dirFd, "test.txt", dirFd, "TEST.txt");
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT2);
+
+ ret = strcat_s(pathname1, JFFS_STANDARD_NAME_LENGTH, "/TEST.txt");
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT2);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ ret = rmdir(JFFS_PATH_NAME01);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(fd);
+EXIT2:
+ unlink(pathname1);
+ closedir(dir);
+EXIT:
+ rmdir(JFFS_PATH_NAME01);
+ return JFFS_NO_ERROR;
+}
+
+void ItTestFsJffs203(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_203", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_204.cpp b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_204.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1206baffb25b356e4109119682aa83fe826e1779
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/smoke/it_test_fs_jffs_204.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_fs_jffs.h"
+
+#define DIRPATH "/storage/test"
+#define FILEPATH "/storage/test/1.txt"
+
+static int TestCase(void)
+{
+ INT32 dirFd = -1;
+ INT32 fd = -1;
+ INT32 flags = -1;
+ INT32 ret = -1;
+ DIR *dir = nullptr;
+ ret = mkdir(DIRPATH, 0777);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT);
+ dir = opendir(DIRPATH);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ fd = open("FILEPATH", O_CREAT | O_RDWR, 0777);
+ dirFd = dirfd(dir);
+ ICUNIT_GOTO_NOT_EQUAL(dirFd, JFFS_IS_ERROR, dirFd, EXIT1);
+
+ ret = unlinkat(dirFd, DIRPATH, 0);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ ret = unlinkat(dirFd, FILEPATH, AT_REMOVEDIR);
+ ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
+
+ return JFFS_NO_ERROR;
+
+EXIT1:
+ close(fd);
+ unlink(DIRPATH);
+ closedir(dir);
+EXIT:
+ rmdir(JFFS_PATH_NAME01);
+ return JFFS_NO_ERROR;
+}
+
+void ItTestFsJffs204(void)
+{
+ TEST_ADD_CASE("It_Test_Fs_Jffs_204", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/jffs/vfs_jffs_test.cpp b/testsuites/unittest/fs/jffs/vfs_jffs_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2b12f2be47335a76b5692c65b663f959ecb84057
--- /dev/null
+++ b/testsuites/unittest/fs/jffs/vfs_jffs_test.cpp
@@ -0,0 +1,8496 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_jffs.h"
+
+#if 1
+struct iovec g_jffsIov[10];
+
+INT32 g_jffsFd = 0;
+DIR *g_jffsDir = nullptr;
+INT32 g_jffsFilesMax = 10;
+INT32 g_jffsFlag = 0;
+INT32 g_jffsFlagF01 = 0;
+INT32 g_jffsFlagF02 = 0;
+INT32 g_TestCnt = 0;
+
+INT32 g_jffsFd11[JFFS_MAXIMUM_SIZES];
+INT32 g_jffsFd12[JFFS_MAXIMUM_SIZES][JFFS_MAXIMUM_SIZES];
+
+CHAR g_jffsPathname1[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME1 };
+CHAR g_jffsPathname2[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME1 };
+CHAR g_jffsPathname3[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME1 };
+CHAR g_jffsPathname4[JFFS_STANDARD_NAME_LENGTH] = { JFFS_PATH_NAME0 };
+
+CHAR g_jffsPathname6[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME1 };
+CHAR g_jffsPathname7[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME1 };
+CHAR g_jffsPathname8[JFFS_NAME_LIMITTED_SIZE] = { JFFS_PATH_NAME1 };
+
+CHAR g_jffsPathname11[JFFS_MAXIMUM_SIZES][JFFS_NAME_LIMITTED_SIZE] = { 0, };
+CHAR g_jffsPathname12[JFFS_MAXIMUM_SIZES][JFFS_NAME_LIMITTED_SIZE] = { 0, };
+CHAR g_jffsPathname13[JFFS_MAXIMUM_SIZES][JFFS_NAME_LIMITTED_SIZE] = { 0, };
+#endif
+INT32 g_jffsGrandSize[JFFS_MAX_DEF_BUF_NUM] = { 29, 30290, 3435, 235, 12345, 80,
+ 9845, 564, 34862, 123, 267890, 36, 6788, 86, 234567, 1232, 514, 50, 678, 9864, 333333 };
+
+pthread_mutex_t g_jffs2GlobalLock1;
+pthread_mutex_t g_jffs2GlobalLock2;
+
+#if 1
+INT32 JffsMultiWrite(CHAR *path, INT64 fileSize, INT32 writeSize, int oflags, INT32 interfaceType)
+{
+ INT32 ret, fd;
+ INT64 total = 0;
+ INT64 totalSize = 0;
+
+ CHAR *writeBuf;
+ FILE *file;
+
+ writeBuf = (CHAR *)malloc(writeSize);
+ ICUNIT_GOTO_NOT_EQUAL(writeBuf, NULL, writeBuf, EXIT);
+
+ if (interfaceType == 1) {
+ fd = open(path, oflags, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ goto EXIT1;
+ }
+ } else {
+ file = fopen(path, "w+b");
+ if (file == nullptr) {
+ goto EXIT2;
+ }
+ }
+
+ while (1) {
+ if (interfaceType == 1) {
+ ret = write(fd, writeBuf, writeSize);
+ if (ret <= 0) {
+ if (errno == ENOSPC) {
+ dprintf("No space !! %s,\n", strerror(errno));
+ goto EXIT1;
+ }
+ dprintf("jffs_multi_write fail,path = %s,ret=:%d ,errno=:%d!\n", path, ret, errno);
+ goto EXIT1;
+ }
+ } else {
+ ret = fwrite(writeBuf, 1, writeSize, file);
+ if (ret <= 0 || ret != writeSize) {
+ if (errno == ENOSPC) {
+ dprintf("No space !! %s,\n", strerror(errno));
+ }
+ dprintf("jffs_multi_write error! %s ,path=:%s, ret = %d,\n", strerror(errno), path, ret);
+
+ goto EXIT2;
+ }
+ }
+ total += ret;
+ totalSize += ret;
+
+ if (total >= JFFS_WR_CAP_SIZE_TEST) {
+ if (interfaceType == 1) {
+ } else {
+ }
+ total = 0;
+ }
+
+ if (fileSize <= totalSize) {
+ break;
+ }
+ }
+
+ if (interfaceType == 1) {
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ } else {
+ ret = fclose(file);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ free(writeBuf);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ fclose(file);
+ goto EXIT;
+EXIT1:
+ close(fd);
+EXIT:
+ free(writeBuf);
+ return JFFS_IS_ERROR;
+}
+
+
+INT32 JffsMultiRead(CHAR *path, INT64 fileSize, INT32 readSize, int oflags, INT32 interfaceType)
+{
+ INT32 fd, ret;
+ INT64 total = 0;
+ INT64 totalSize = 0;
+ FILE *file;
+ CHAR *readBuf;
+
+ readBuf = (CHAR *)malloc(readSize);
+ ICUNIT_ASSERT_NOT_EQUAL(readBuf, NULL, readBuf);
+
+ if (interfaceType == 1) {
+ fd = open(path, oflags, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ goto EXIT1;
+ }
+ } else {
+ file = fopen(path, "rb");
+ if (file == nullptr) {
+ goto EXIT2;
+ }
+ }
+
+ while (1) {
+ if (interfaceType == 1) {
+ ret = read(fd, readBuf, readSize);
+ if (ret < 0) {
+ dprintf("ret = %d,%s read fail!-->(X),\n", ret, path);
+ goto EXIT1;
+ }
+ if (!ret) {
+ dprintf("warning: read ret = 0,\n");
+ goto EXIT1;
+ }
+ } else {
+ ret = fread(readBuf, 1, readSize, file);
+ if (ret <= 0) {
+ if (feof(file) == 1) {
+ dprintf("yyy feof of %s,\n", path);
+ } else {
+ dprintf("fread error!,\n");
+ goto EXIT2;
+ }
+ }
+ }
+ total += ret;
+ totalSize += ret;
+
+ if (total >= JFFS_WR_CAP_SIZE_TEST) {
+ total = 0;
+ }
+
+ if (fileSize <= totalSize) {
+ break;
+ }
+ }
+
+ if (interfaceType == 1) {
+ ret = close(fd);
+ if (ret < 0) {
+ dprintf("fail to close %s!\n", strerror(errno));
+ }
+ } else {
+ ret = fclose(file);
+ if (ret < 0) {
+ dprintf("fail to fclose %s!\n", strerror(errno));
+ }
+ }
+
+ free(readBuf);
+ return JFFS_NO_ERROR;
+EXIT2:
+ fclose(file);
+EXIT1:
+ close(fd);
+ free(readBuf);
+ return JFFS_IS_ERROR;
+}
+#endif
+
+INT32 JffsFixWrite(CHAR *path, INT64 fileSize, INT32 writeSize, INT32 interfaceType)
+{
+ INT32 ret, i, fd;
+ INT64 total = 0;
+ CHAR filebuf[256] = "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalal";
+ INT64 perTime;
+ INT64 totalSize = 0;
+ INT64 totalTime = 0;
+ INT32 cycleCount = 0;
+ INT32 taskId;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ DOUBLE testSpeed;
+ CHAR *pid;
+ CHAR *writeBuf;
+ FILE *file;
+
+ taskId = strlen(path);
+ pid = path + taskId - 1;
+ taskId = atoi(pid);
+
+ writeBuf = (CHAR *)malloc(writeSize);
+ ICUNIT_GOTO_NOT_EQUAL(writeBuf, NULL, writeBuf, EXIT);
+ memset(writeBuf, 0, writeSize);
+
+ for (i = 0; i < writeSize / 256; i++) { // 256 means the maxsize of write len
+ strcat(writeBuf, filebuf);
+ }
+
+ gettimeofday(&testTime1, 0);
+ if (interfaceType == 1) {
+ fd = open(path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ printf("Task_%d fail to open %s,\n", taskId, path);
+ goto EXIT1;
+ }
+ } else {
+ file = fopen(path, "w+b");
+ if (file == nullptr) {
+ printf("Task_%d fail to fopen %s,\n", taskId, path);
+ goto EXIT2;
+ }
+ }
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+ printf("fix_Write TaskID:%3d,open %s ,task %lld ms ,\n", taskId, path, perTime / MSECS_PER_SEC);
+
+ gettimeofday(&testTime1, 0);
+
+ while (1) {
+ if (interfaceType == 1) {
+ ret = write(fd, writeBuf, writeSize);
+ if (ret <= 0) {
+ if (errno == ENOSPC) {
+ printf("No space !! %s,\n", strerror(errno));
+ goto EXIT1;
+ }
+ printf("fix_write fail,path = %s,ret=:%d ,errno=:%d!\n", path, ret, errno);
+ goto EXIT1;
+ }
+ } else {
+ ret = fwrite(writeBuf, 1, writeSize, file);
+ if (ret <= 0 || ret != writeSize) {
+ if (errno == ENOSPC) {
+ printf("No space !! %s,\n", strerror(errno));
+ }
+ printf("fix_fwrite error! %s ,path=:%s, ret = %d,\n", strerror(errno), path, ret);
+
+ goto EXIT2;
+ }
+ }
+ total += ret;
+ totalSize += ret;
+ if (total >= JFFS_WR_CAP_SIZE_TEST) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+
+ if (interfaceType == 1) {
+ printf("fix_Write TaskID:%3d,%d time write, write %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n",
+ taskId, cycleCount++, total, perTime, testSpeed);
+ } else {
+ printf("fix_fwrite TaskID:%3d,%d time write, write %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n",
+ taskId, cycleCount++, total, perTime, testSpeed);
+ }
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+
+ if (fileSize <= totalSize) {
+ break;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+
+ printf("\nfix_Write TaskID:%3d,total write=%lld , time=%lld,arv speed =%0.3lfMB/s ,\n", taskId, totalSize,
+ totalTime, testSpeed);
+ gettimeofday(&testTime1, 0);
+ if (interfaceType == 1) {
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ } else {
+ ret = fclose(file);
+ ICUNIT_GOTO_EQUAL(ret, JFFS_NO_ERROR, ret, EXIT1);
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ printf("fix_Write TaskID:%3d,sucess to fclose the %s ,task:%lld ms,\n", taskId, path, MSECS_PER_SEC / MSECS_PER_SEC);
+
+ free(writeBuf);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ fclose(file);
+ goto EXIT;
+EXIT1:
+ close(fd);
+EXIT:
+ free(writeBuf);
+ return JFFS_NO_ERROR;
+}
+
+INT32 JffsFixRead(CHAR *path, INT64 fileSize, INT32 readSize, INT32 interfaceType)
+{
+ INT32 fd, taskId, ret;
+ INT32 cycleCount = 0;
+ INT64 total = 0;
+ INT64 totalSize = 0;
+ INT64 perTime;
+ INT64 totalTime = 0;
+ FILE *file;
+ CHAR *readBuf;
+ CHAR *pid;
+ DOUBLE testSpeed;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ taskId = strlen(path);
+ pid = path + taskId - 1;
+ taskId = atoi(pid);
+
+ readBuf = (CHAR *)malloc(readSize);
+ ICUNIT_ASSERT_NOT_EQUAL(readBuf, NULL, readBuf);
+
+ gettimeofday(&testTime1, 0);
+
+ if (interfaceType == 1) {
+ fd = open(path, O_RDWR, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ printf("Task_%d fail to open %s,\n", taskId, path);
+ goto EXIT1;
+ }
+ } else {
+ file = fopen(path, "rb");
+ if (file == nullptr) {
+ printf("Task_%d fail to fopen %s,\n", taskId, path);
+ goto EXIT2;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ printf("fix_Read TaskID:%3d,open %s , task:%lld ms,\n", taskId, path, perTime / MSECS_PER_SEC);
+
+ gettimeofday(&testTime1, 0);
+
+ while (1) {
+ if (interfaceType == 1) {
+ ret = read(fd, readBuf, readSize);
+ if (ret < 0) {
+ printf("ret = %d,%s read fail!-->(X),\n", ret, path);
+ goto EXIT1;
+ }
+ if (!ret) {
+ printf("warning: read ret = 0,\n");
+ goto EXIT1;
+ }
+ } else {
+ ret = fread(readBuf, 1, readSize, file);
+ if (ret <= 0) {
+ if (feof(file) == 1) {
+ printf("feof of %s,\n", path);
+ } else {
+ printf("fread error!,\n");
+ goto EXIT2;
+ }
+ }
+ }
+ total += ret;
+ totalSize += ret;
+
+ if (total >= JFFS_WR_CAP_SIZE_TEST) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+
+ printf("fix_Read TaskID:%3d,times %d, read %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n", taskId,
+ cycleCount++, total, perTime, testSpeed);
+
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+
+ if (fileSize <= totalSize) {
+ break;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+
+ printf("\nfix_Read TaskID:%3d,total read=%lld , time=%lld,arv speed =%0.3lfMB/s ,\n", taskId, totalSize,
+ totalTime, testSpeed);
+
+ gettimeofday(&testTime1, 0);
+ if (interfaceType == 1) {
+ ret = close(fd);
+ if (ret < 0) {
+ printf("fail to close %s!\n", strerror(errno));
+ }
+ } else {
+ ret = fclose(file);
+ if (ret < 0) {
+ dprintf("fail to fclose %s!\n", strerror(errno));
+ }
+ }
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ dprintf("fix_Read TaskID:%3d, fclose %s!,task:%lld ms,\n", taskId, path, perTime / MSECS_PER_SEC);
+
+ ret = remove(path);
+ if (ret < 0) {
+ dprintf("fail to remove %s!\n", strerror(errno));
+ }
+
+ dprintf("Read TaskID:%3d,sucess to fread the %s,\n", taskId, path);
+ free(readBuf);
+ return 0;
+EXIT2:
+ fclose(file);
+EXIT1:
+ close(fd);
+ free(readBuf);
+ return JFFS_NO_ERROR;
+}
+
+INT32 JffsRandWrite(CHAR *path, INT64 fileSize, INT32 interfaceType)
+{
+ INT32 ret, i, fd;
+ INT32 cycleCount = 0;
+ INT32 taskId;
+ CHAR filebuf[256] = "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalal";
+ INT64 total = 0;
+ INT64 totalSize = 0;
+ INT64 perTime;
+ INT64 totalTime = 0;
+ CHAR *writeBuf;
+ CHAR *pid;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ DOUBLE testSpeed;
+ FILE *file;
+
+ taskId = strlen(path);
+ pid = path + taskId - 1;
+ taskId = atoi(pid);
+
+ writeBuf = (CHAR *)malloc(JFFS_PRESSURE_W_R_SIZE);
+ ICUNIT_GOTO_NOT_EQUAL(writeBuf, NULL, writeBuf, EXIT);
+ memset(writeBuf, 0, JFFS_PRESSURE_W_R_SIZE);
+
+ for (i = 0; i < JFFS_PRESSURE_W_R_SIZE / 256; i++) { // 256 means the maxsize of write len
+ strcat(writeBuf, filebuf);
+ }
+
+ gettimeofday(&testTime1, 0);
+ if (interfaceType == 1) {
+ fd = open(path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ dprintf("Task_%d fail to open %s,\n", taskId, path);
+ goto EXIT1;
+ }
+ } else {
+ file = fopen(path, "w+b");
+ if (file == nullptr) {
+ dprintf("Task_%d fail to fopen %s,\n", taskId, path);
+ goto EXIT2;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+ dprintf("rand_write TaskID:%3d,open %s , cost:%lld ms,\n", taskId, path, perTime / MSECS_PER_SEC);
+
+ gettimeofday(&testTime1, 0);
+
+ i = 0;
+
+ while (1) {
+ if (interfaceType == 1) {
+ ret = write(fd, writeBuf, g_jffsGrandSize[i]);
+ if (ret <= 0) {
+ dprintf("ret = %d,%s write fail!-->(X),\n", ret, path);
+ if (errno == ENOSPC) {
+ dprintf("No space !! %s,\n", strerror(errno));
+ goto EXIT1;
+ }
+ goto EXIT1;
+ }
+ } else {
+ ret = fwrite(writeBuf, 1, g_jffsGrandSize[i], file);
+ if (ret <= 0 || ret != g_jffsGrandSize[i]) {
+ if (errno == ENOSPC) {
+ dprintf("No space !! %s,\n", strerror(errno));
+ }
+ dprintf("rand_Write TaskID:%3d,fwrite error! %s , ret = %d,\n", taskId, strerror(errno), ret);
+ goto EXIT2;
+ }
+ }
+
+ total += ret;
+ totalSize += ret;
+ if (total >= JFFS_WR_CAP_SIZE_TEST) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+
+ dprintf("rand_Write TaskID:%3d,%d time write, write %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n",
+ taskId, cycleCount++, total, perTime, testSpeed);
+
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+
+ if (fileSize <= totalSize) {
+ break;
+ }
+ if (++i >= JFFS_MAX_DEF_BUF_NUM)
+ i = 0;
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+ dprintf("--------------------------------\n");
+ dprintf("rand_Write TaskID:%3d,total write=%lld , time=%lld,arv speed =%0.3lfMB/s ,\n", taskId, totalSize,
+ totalTime, testSpeed);
+
+ gettimeofday(&testTime1, 0);
+ if (interfaceType == 1) {
+ ret = close(fd);
+ if (ret < 0) {
+ dprintf("rand_Write TaskID:%3d,fail to close %s!\n", taskId, strerror(errno));
+ goto EXIT1;
+ }
+ } else {
+ ret = fclose(file);
+ if (ret < 0) {
+ dprintf("rand_Write TaskID:%3d,fail to fclose %s!\n", taskId, strerror(errno));
+ goto EXIT2;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ dprintf("rand_Write TaskID:%3d,sucess to fclose the %s ,task %lld,\n", taskId, path, perTime / MSECS_PER_SEC);
+
+ free(writeBuf);
+
+ return JFFS_NO_ERROR;
+EXIT2:
+ fclose(file);
+ goto EXIT;
+EXIT1:
+ close(fd);
+EXIT:
+ free(writeBuf);
+ return JFFS_NO_ERROR;
+}
+
+
+INT32 JffsRandRead(CHAR *path, INT64 fileSize, INT32 interfaceType)
+{
+ INT32 ret, fd, i;
+ INT32 cycleCount = 0;
+ INT32 taskId;
+ INT64 total = 0;
+ INT64 totalSize = 0;
+ INT64 perTime;
+ INT64 totalTime = 0;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ DOUBLE testSpeed;
+ CHAR *pid;
+ CHAR *readBuf;
+ FILE *file;
+
+ taskId = strlen(path);
+ pid = path + taskId - 1;
+ taskId = atoi(pid);
+
+ readBuf = (CHAR *)malloc(JFFS_PRESSURE_W_R_SIZE);
+ ICUNIT_GOTO_NOT_EQUAL(readBuf, NULL, readBuf, EXIT);
+
+ gettimeofday(&testTime1, 0);
+ if (interfaceType == 1) {
+ fd = open(path, O_RDWR, S_IRUSR | S_IWUSR);
+ if (-1 == fd) {
+ printf("fail to open %s\n", path);
+ goto EXIT1;
+ }
+ } else {
+ file = fopen(path, "rb");
+ if (file == nullptr) {
+ printf("fail to fopen %s\n", path);
+ goto EXIT2;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+ printf("rand_read, open %s , task:%lld ms,\n", path, perTime / MSECS_PER_SEC);
+
+ i = 0;
+ gettimeofday(&testTime1, 0);
+
+ while (1) {
+ if (interfaceType == 1) {
+ ret = read(fd, readBuf, g_jffsGrandSize[i]);
+ if (ret < 0) {
+ printf("ret = %d,%s read fail!-->(X)\n", ret, path);
+ goto EXIT1;
+ }
+ if (!ret) {
+ printf("warning: read ret = 0,\n");
+ }
+ } else {
+ ret = fread(readBuf, 1, g_jffsGrandSize[i], file);
+ if (ret <= 0) {
+ if (feof(file) == 1) {
+ printf("feof of %s\n", path);
+ } else {
+ printf("fread error!\n");
+ goto EXIT2;
+ }
+ }
+ }
+ total += ret;
+ totalSize += ret;
+
+ if (total >= JFFS_WR_CAP_SIZE_TEST) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+
+ dprintf("rand_Read TaskID:%3d, times %d, read %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n", taskId,
+ cycleCount++, total, perTime, testSpeed);
+
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+
+ if (fileSize <= totalSize) {
+ break;
+ }
+ if (++i >= JFFS_MAX_DEF_BUF_NUM)
+ i = 0;
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * USECS_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_MBYTE;
+ printf("--------------------------------\n");
+ printf("rand_Read TaskID:%3d ,total read=%lld , time=%lld,arv speed =%0.3lfMB/s ,\n", taskId, totalSize,
+ totalTime, testSpeed);
+
+ gettimeofday(&testTime1, 0);
+ if (interfaceType == 1) {
+ ret = close(fd);
+ if (ret < 0) {
+ printf("fail to close %s!\n", strerror(errno));
+ }
+ } else {
+ ret = fclose(file);
+ if (ret < 0) {
+ printf("fail to fclose %s!\n", strerror(errno));
+ }
+ }
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ printf(" rand_Read TaskID:%3d,fclose %s!,task:%lld ms,\n", taskId, path, perTime / MSECS_PER_SEC);
+
+ ret = remove(path);
+ if (ret < 0) {
+ printf("fail to fclose %s!\n", strerror(errno));
+ }
+
+ printf("rand_Read TaskID:%3d,sucess to fread the %s,\n", taskId, path);
+
+ free(readBuf);
+ return JFFS_NO_ERROR;
+
+EXIT2:
+ fclose(file);
+ goto EXIT1;
+EXIT1:
+ close(fd);
+EXIT:
+ free(readBuf);
+ return JFFS_NO_ERROR;
+}
+
+INT32 JffsDeleteDirs(char *str, int n)
+{
+ struct dirent *ptr;
+ int ret;
+ DIR *dir;
+ int i = 0;
+
+ ret = chdir(str);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ dir = opendir(str);
+ ICUNIT_ASSERT_NOT_EQUAL(dir, NULL, dir);
+
+ rewinddir(dir);
+ while ((ptr = readdir(dir)) != nullptr) {
+ if ((strcmp(ptr->d_name, "..") == 0) || (strcmp(ptr->d_name, ".") == 0))
+ continue;
+
+ if (i == n) {
+ break;
+ }
+ i++;
+
+ ret = rmdir(ptr->d_name);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+ }
+
+ ret = closedir(dir);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ ret = rmdir(str);
+ ICUNIT_ASSERT_EQUAL(ret, JFFS_NO_ERROR, ret);
+
+ return JFFS_NO_ERROR;
+}
+INT32 JffsDeletefile(int fd, char *pathname)
+{
+ int ret;
+
+ ret = close(fd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = unlink(pathname);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return JFFS_NO_ERROR;
+}
+
+INT32 JffsStrcat2(char *pathname, char *str, int len)
+{
+ memset(pathname, 0, len);
+ strcpy(pathname, JFFS_PATH_NAME0);
+ strcat(pathname, str);
+
+ return 0;
+}
+INT32 JffsScandirFree(struct dirent **namelist, int n)
+{
+ if (n < 0 || namelist == nullptr) {
+ return -1;
+ } else if (n == 0) {
+ free(namelist);
+ return 0;
+ }
+ while (n--) {
+ free(namelist[n]);
+ }
+ free(namelist);
+
+ return 0;
+}
+
+INT32 JffsStatPrintf(struct stat sb)
+{
+#if VFS_STAT_PRINTF == 1
+
+ dprintf("File type: ");
+
+ switch (sb.st_mode & S_IFMT) {
+ case S_IFBLK:
+ dprintf("block device\n");
+ break;
+ case S_IFCHR:
+ dprintf("character device\n");
+ break;
+ case S_IFDIR:
+ dprintf("directory\n");
+ break;
+ case S_IFIFO:
+ dprintf("FIFO/pipe\n");
+ break;
+ case S_IFLNK:
+ dprintf("symlink\n");
+ break;
+ case S_IFREG:
+ dprintf("regular file\n");
+ break;
+ case S_IFSOCK:
+ dprintf("socket\n");
+ break;
+ default:
+ dprintf("unknown?\n");
+ break;
+ }
+
+ switch (sb.st_mode & S_IRWXU) {
+ case S_IRUSR:
+ dprintf("Owners have read permission\n");
+ break;
+ case S_IWUSR:
+ dprintf("Owners have write permission\n");
+ break;
+ case S_IXUSR:
+ dprintf("Owners have execute permissions\n");
+ break;
+ default:
+ break;
+ }
+
+ switch (sb.st_mode & S_IRWXG) {
+ case S_IRGRP:
+ dprintf("Group has read permission\n");
+ break;
+ case S_IWGRP:
+ dprintf("Group has write permission\n");
+ break;
+ case S_IXGRP:
+ dprintf("Group has execute permission\n");
+ break;
+ default:
+ break;
+ }
+
+ switch (sb.st_mode & S_IRWXO) {
+ case S_IROTH:
+ dprintf("Other have read permission\n");
+ break;
+ case S_IWOTH:
+ dprintf("Other has write permission\n");
+ break;
+ case S_IXOTH:
+ dprintf("Other has execute permission\n");
+ break;
+ default:
+ break;
+ }
+
+ dprintf("I-node number: %ld\n", (long)sb.st_ino);
+ dprintf("Mode: %lo (octal)\n", (unsigned long)sb.st_mode);
+ dprintf("Link count: %ld\n", (long)sb.st_nlink);
+ dprintf("Ownership: UID=%ld GID=%ld\n", (long)sb.st_uid, (long)sb.st_gid);
+
+ dprintf("Preferred I/O block size: %ld bytes\n", (long)sb.st_blksize);
+ dprintf("File size: %lld bytes\n", (long long)sb.st_size);
+ dprintf("Blocks allocated: %lld\n", (long long)sb.st_blocks);
+
+ dprintf("Last status change: %s", ctime(&sb.st_ctime));
+ dprintf("Last file access: %s", ctime(&sb.st_atime));
+ dprintf("Last file modification: %s\n", ctime(&sb.st_mtime));
+
+#endif
+ return 0;
+}
+
+INT32 JffsStatfsPrintf(struct statfs buf)
+{
+#if VFS_STATFS_PRINTF == 1
+ dprintf("type of file system : 0x%x\n", buf.f_type);
+ dprintf("optimal transfer block size : %ld\n", (long)buf.f_bsize);
+ dprintf("total data blocks in file system : %ld\n", (long)buf.f_blocks);
+ dprintf("free blocks in fs : %ld\n", (long)buf.f_bfree);
+ dprintf("free blocks available to unprivileged user : %ld\n", (long)buf.f_bavail);
+ dprintf("total file nodes in file system : %ld\n", (long)buf.f_files);
+
+ dprintf("free file nodes in fs : %ld\n", (long)buf.f_ffree);
+ dprintf("file system id : %d\n", buf.f_fsid.__val[0]);
+ dprintf("maximum length of filenames : 0x%x\n", buf.f_namelen);
+ dprintf("fragment size: %d\n\n", buf.f_frsize);
+#endif
+ return 0;
+}
+
+
+using namespace testing::ext;
+namespace OHOS {
+class VfsJffsTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+#if defined(LOSCFG_USER_TEST_FULL)
+/* *
+ * @tc.name: IT_JFFS_002
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs002, TestSize.Level0)
+{
+ ItJffs002();
+}
+
+/* *
+ * @tc.name: IT_JFFS_004
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs004, TestSize.Level0)
+{
+ ItJffs004();
+}
+
+/* *
+ * @tc.name: IT_JFFS_007
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs007, TestSize.Level0)
+{
+ ItJffs007();
+}
+
+/* *
+ * @tc.name: IT_JFFS_009
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs009, TestSize.Level0)
+{
+ ItJffs009();
+}
+
+/* *
+ * @tc.name: IT_JFFS_010
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs010, TestSize.Level0)
+{
+ ItJffs010();
+}
+
+/* *
+ * @tc.name: IT_JFFS_011
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs011, TestSize.Level0)
+{
+ ItJffs011();
+}
+
+/* *
+ * @tc.name: IT_JFFS_012
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs012, TestSize.Level0)
+{
+ ItJffs012();
+}
+
+/* *
+ * @tc.name: IT_JFFS_013
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs013, TestSize.Level0)
+{
+ ItJffs013();
+}
+
+/* *
+ * @tc.name: IT_JFFS_015
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs015, TestSize.Level0)
+{
+ ItJffs015();
+}
+
+/* *
+ * @tc.name: IT_JFFS_017
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs017, TestSize.Level0)
+{
+ ItJffs017();
+}
+
+/* *
+ * @tc.name: IT_JFFS_018
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs018, TestSize.Level0)
+{
+ ItJffs018();
+}
+
+/* *
+ * @tc.name: IT_JFFS_019
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs019, TestSize.Level0)
+{
+ ItJffs019();
+}
+
+/* *
+ * @tc.name: IT_JFFS_022
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs022, TestSize.Level0)
+{
+ ItJffs022();
+}
+
+/* *
+ * @tc.name: IT_JFFS_025
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs025, TestSize.Level0)
+{
+ ItJffs025();
+}
+
+/* *
+ * @tc.name: IT_JFFS_026
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs026, TestSize.Level0)
+{
+ ItJffs026();
+}
+
+/* *
+ * @tc.name: IT_JFFS_027
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs027, TestSize.Level0)
+{
+ ItJffs027();
+}
+
+/* *
+ * @tc.name: IT_JFFS_030
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs030, TestSize.Level0)
+{
+ ItJffs030();
+}
+
+/* *
+ * @tc.name: IT_JFFS_032
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs032, TestSize.Level0)
+{
+ ItJffs032();
+}
+
+/* *
+ * @tc.name: IT_JFFS_033
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs033, TestSize.Level0)
+{
+ ItJffs033();
+}
+
+/* *
+ * @tc.name: IT_JFFS_034
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs034, TestSize.Level0)
+{
+ ItJffs034();
+}
+
+/* *
+ * @tc.name: IT_JFFS_035
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs035, TestSize.Level0)
+{
+ ItJffs035();
+}
+
+/* *
+ * @tc.name: IT_JFFS_036
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs036, TestSize.Level0)
+{
+ ItJffs036();
+}
+
+/* *
+ * @tc.name: IT_JFFS_037
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs037, TestSize.Level0)
+{
+ ItJffs037();
+}
+
+/* *
+ * @tc.name: IT_JFFS_038
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs038, TestSize.Level0)
+{
+ ItJffs038();
+}
+
+/* *
+ * @tc.name: IT_JFFS_040
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs040, TestSize.Level0)
+{
+ ItJffs040();
+}
+
+/* *
+ * @tc.name: IT_JFFS_041
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs041, TestSize.Level0)
+{
+ ItJffs041();
+}
+
+/* *
+ * @tc.name: IT_JFFS_042
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs042, TestSize.Level0)
+{
+ ItJffs042();
+}
+
+/* *
+ * @tc.name: IT_JFFS_021
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs021, TestSize.Level0)
+{
+ ItJffs021();
+}
+
+/* *
+ * @tc.name: IT_JFFS_043
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs043, TestSize.Level0)
+{
+ ItJffs043();
+}
+
+/* *
+ * @tc.name: IT_JFFS_044
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItJffs044, TestSize.Level0)
+{
+ ItJffs044();
+}
+
+
+/* *
+ * @tc.name: ItFsJffs004
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs004, TestSize.Level0)
+{
+ ItFsJffs004();
+}
+
+/* *
+ * @tc.name: ItFsJffs006
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs006, TestSize.Level0)
+{
+ ItFsJffs006();
+}
+
+/* *
+ * @tc.name: ItFsJffs008
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs008, TestSize.Level0)
+{
+ ItFsJffs008();
+}
+
+/* *
+ * @tc.name: ItFsJffs009
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs009, TestSize.Level0)
+{
+ ItFsJffs009();
+}
+
+/* *
+ * @tc.name: ItFsJffs011
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs011, TestSize.Level0)
+{
+ ItFsJffs011();
+}
+
+/* *
+ * @tc.name: ItFsJffs012
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs012, TestSize.Level0)
+{
+ ItFsJffs012();
+}
+
+/* *
+ * @tc.name: ItFsJffs013
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs013, TestSize.Level0)
+{
+ ItFsJffs013();
+}
+
+/* *
+ * @tc.name: ItFsJffs014
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs014, TestSize.Level0)
+{
+ ItFsJffs014();
+}
+
+/* *
+ * @tc.name: ItFsJffs015
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs015, TestSize.Level0)
+{
+ ItFsJffs015();
+}
+
+/* *
+ * @tc.name: ItFsJffs016
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs016, TestSize.Level0)
+{
+ ItFsJffs016();
+}
+
+/* *
+ * @tc.name: ItFsJffs017
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs017, TestSize.Level0)
+{
+ ItFsJffs017();
+}
+
+/* *
+ * @tc.name: ItFsJffs018
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs018, TestSize.Level0)
+{
+ ItFsJffs018();
+}
+
+/* *
+ * @tc.name: ItFsJffs019
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs019, TestSize.Level0)
+{
+ ItFsJffs019();
+}
+
+/* *
+ * @tc.name: ItFsJffs020
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs020, TestSize.Level0)
+{
+ ItFsJffs020();
+}
+
+/* *
+ * @tc.name: ItFsJffs023
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs023, TestSize.Level0)
+{
+ ItFsJffs023();
+}
+
+/* *
+ * @tc.name: ItFsJffs024
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs024, TestSize.Level0)
+{
+ ItFsJffs024();
+}
+
+/* *
+ * @tc.name: ItFsJffs025
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs025, TestSize.Level0)
+{
+ ItFsJffs025();
+}
+
+/* *
+ * @tc.name: ItFsJffs029
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs029, TestSize.Level0)
+{
+ ItFsJffs029();
+}
+
+/* *
+ * @tc.name: ItFsJffs030
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs030, TestSize.Level0)
+{
+ ItFsJffs030();
+}
+
+/* *
+ * @tc.name: ItFsJffs031
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs031, TestSize.Level0)
+{
+ ItFsJffs031();
+}
+
+/* *
+ * @tc.name: ItFsJffs032
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs032, TestSize.Level0)
+{
+ ItFsJffs032();
+}
+
+/* *
+ * @tc.name: ItFsJffs033
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs033, TestSize.Level0)
+{
+ ItFsJffs033();
+}
+
+/* *
+ * @tc.name: ItFsJffs037
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs037, TestSize.Level0)
+{
+ ItFsJffs037();
+}
+
+/* *
+ * @tc.name: ItFsJffs038
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs038, TestSize.Level0)
+{
+ ItFsJffs038();
+}
+
+/* *
+ * @tc.name: ItFsJffs039
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs039, TestSize.Level0)
+{
+ ItFsJffs039();
+}
+
+/* *
+ * @tc.name: ItFsJffs040
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs040, TestSize.Level0)
+{
+ ItFsJffs040();
+}
+
+/* *
+ * @tc.name: ItFsJffs041
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs041, TestSize.Level0)
+{
+ ItFsJffs041();
+}
+
+/* *
+ * @tc.name: ItFsJffs042
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs042, TestSize.Level0)
+{
+ ItFsJffs042();
+}
+
+/* *
+ * @tc.name: ItFsJffs043
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs043, TestSize.Level0)
+{
+ ItFsJffs043();
+}
+
+/* *
+ * @tc.name: ItFsJffs044
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs044, TestSize.Level0)
+{
+ ItFsJffs044();
+}
+
+/* *
+ * @tc.name: ItFsJffs045
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs045, TestSize.Level0)
+{
+ ItFsJffs045();
+}
+
+/* *
+ * @tc.name: ItFsJffs046
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs046, TestSize.Level0)
+{
+ ItFsJffs046();
+}
+
+/* *
+ * @tc.name: ItFsJffs048
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs048, TestSize.Level0)
+{
+ ItFsJffs048();
+}
+
+/* *
+ * @tc.name: ItFsJffs049
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs049, TestSize.Level0)
+{
+ ItFsJffs049();
+}
+
+/* *
+ * @tc.name: ItFsJffs050
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs050, TestSize.Level0)
+{
+ ItFsJffs050();
+}
+
+/* *
+ * @tc.name: ItFsJffs053
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs053, TestSize.Level0)
+{
+ ItFsJffs053();
+}
+
+/* *
+ * @tc.name: ItFsJffs055
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs055, TestSize.Level0)
+{
+ ItFsJffs055();
+}
+
+/* *
+ * @tc.name: ItFsJffs056
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs056, TestSize.Level0)
+{
+ ItFsJffs056();
+}
+
+/* *
+ * @tc.name: ItFsJffs057
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs057, TestSize.Level0)
+{
+ ItFsJffs057();
+}
+
+/* *
+ * @tc.name: ItFsJffs059
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs059, TestSize.Level0)
+{
+ ItFsJffs059();
+}
+
+/* *
+ * @tc.name: ItFsJffs060
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs060, TestSize.Level0)
+{
+ ItFsJffs060();
+}
+
+/* *
+ * @tc.name: ItFsJffs061
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs061, TestSize.Level0)
+{
+ ItFsJffs061();
+}
+
+/* *
+ * @tc.name: ItFsJffs062
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs062, TestSize.Level0)
+{
+ ItFsJffs062();
+}
+
+/* *
+ * @tc.name: ItFsJffs063
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs063, TestSize.Level0)
+{
+ ItFsJffs063();
+}
+
+/* *
+ * @tc.name: ItFsJffs064
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs064, TestSize.Level0)
+{
+ ItFsJffs064();
+}
+
+/* *
+ * @tc.name: ItFsJffs066
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs066, TestSize.Level0)
+{
+ ItFsJffs066();
+}
+
+/* *
+ * @tc.name: ItFsJffs068
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs068, TestSize.Level0)
+{
+ ItFsJffs068();
+}
+
+/* *
+ * @tc.name: ItFsJffs069
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs069, TestSize.Level0)
+{
+ ItFsJffs069();
+}
+
+/* *
+ * @tc.name: ItFsJffs070
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs070, TestSize.Level0)
+{
+ ItFsJffs070();
+}
+
+/* *
+ * @tc.name: ItFsJffs077
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs077, TestSize.Level0)
+{
+ ItFsJffs077();
+}
+
+/* *
+ * @tc.name: ItFsJffs078
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs078, TestSize.Level0)
+{
+ ItFsJffs078();
+}
+
+/* *
+ * @tc.name: ItFsJffs079
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs079, TestSize.Level0)
+{
+ ItFsJffs079();
+}
+
+/* *
+ * @tc.name: ItFsJffs081
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs081, TestSize.Level0)
+{
+ ItFsJffs081();
+}
+
+/* *
+ * @tc.name: ItFsJffs082
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs082, TestSize.Level0)
+{
+ ItFsJffs082();
+}
+
+/* *
+ * @tc.name: ItFsJffs083
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs083, TestSize.Level0)
+{
+ ItFsJffs083();
+}
+
+/* *
+ * @tc.name: ItFsJffs084
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs084, TestSize.Level0)
+{
+ ItFsJffs084();
+}
+
+/* *
+ * @tc.name: ItFsJffs085
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs085, TestSize.Level0)
+{
+ ItFsJffs085();
+}
+
+/* *
+ * @tc.name: ItFsJffs088
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs088, TestSize.Level0)
+{
+ ItFsJffs088();
+}
+
+/* *
+ * @tc.name: ItFsJffs090
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs090, TestSize.Level0)
+{
+ ItFsJffs090();
+}
+
+/* *
+ * @tc.name: ItFsJffs093
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs093, TestSize.Level0)
+{
+ ItFsJffs093();
+}
+
+/* *
+ * @tc.name: ItFsJffs096
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs096, TestSize.Level0)
+{
+ ItFsJffs096();
+}
+
+/* *
+ * @tc.name: ItFsJffs099
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs099, TestSize.Level0)
+{
+ ItFsJffs099();
+}
+
+/* *
+ * @tc.name: ItFsJffs100
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs100, TestSize.Level0)
+{
+ ItFsJffs100();
+}
+
+/* *
+ * @tc.name: ItFsJffs104
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs104, TestSize.Level0)
+{
+ ItFsJffs104();
+}
+
+/* *
+ * @tc.name: ItFsJffs116
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs116, TestSize.Level0)
+{
+ ItFsJffs116();
+}
+
+/* *
+ * @tc.name: ItFsJffs117
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs117, TestSize.Level0)
+{
+ ItFsJffs117();
+}
+
+/* *
+ * @tc.name: ItFsJffs118
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs118, TestSize.Level0)
+{
+ ItFsJffs118();
+}
+
+/* *
+ * @tc.name: ItFsJffs119
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs119, TestSize.Level0)
+{
+ ItFsJffs119();
+}
+
+/* *
+ * @tc.name: ItFsJffs120
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs120, TestSize.Level0)
+{
+ ItFsJffs120();
+}
+
+/* *
+ * @tc.name: ItFsJffs121
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs121, TestSize.Level0)
+{
+ ItFsJffs121();
+}
+
+/* *
+ * @tc.name: ItFsJffs123
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs123, TestSize.Level0)
+{
+ ItFsJffs123();
+}
+
+/* *
+ * @tc.name: ItFsJffs126
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs126, TestSize.Level0)
+{
+ ItFsJffs126();
+}
+
+/* *
+ * @tc.name: ItFsJffs127
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs127, TestSize.Level0)
+{
+ ItFsJffs127();
+}
+
+/* *
+ * @tc.name: ItFsJffs128
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs128, TestSize.Level0)
+{
+ ItFsJffs128();
+}
+
+/* *
+ * @tc.name: ItFsJffs129
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs129, TestSize.Level0)
+{
+ ItFsJffs129();
+}
+
+/* *
+ * @tc.name: ItFsJffs130
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs130, TestSize.Level0)
+{
+ ItFsJffs130();
+}
+
+/* *
+ * @tc.name: ItFsJffs131
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs131, TestSize.Level0)
+{
+ ItFsJffs131();
+}
+
+/* *
+ * @tc.name: ItFsJffs132
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs132, TestSize.Level0)
+{
+ ItFsJffs132();
+}
+
+/* *
+ * @tc.name: ItFsJffs133
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs133, TestSize.Level0)
+{
+ ItFsJffs133();
+}
+
+/* *
+ * @tc.name: ItFsJffs134
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs134, TestSize.Level0)
+{
+ ItFsJffs134();
+}
+
+/* *
+ * @tc.name: ItFsJffs135
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs135, TestSize.Level0)
+{
+ ItFsJffs135();
+}
+
+/* *
+ * @tc.name: ItFsJffs136
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs136, TestSize.Level0)
+{
+ ItFsJffs136();
+}
+
+/* *
+ * @tc.name: ItFsJffs137
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs137, TestSize.Level0)
+{
+ ItFsJffs137();
+}
+
+/* *
+ * @tc.name: ItFsJffs138
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs138, TestSize.Level0)
+{
+ ItFsJffs138();
+}
+
+/* *
+ * @tc.name: ItFsJffs139
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs139, TestSize.Level0)
+{
+ ItFsJffs139();
+}
+
+/* *
+ * @tc.name: ItFsJffs140
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs140, TestSize.Level0)
+{
+ ItFsJffs140();
+}
+
+/* *
+ * @tc.name: ItFsJffs141
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs141, TestSize.Level0)
+{
+ ItFsJffs141();
+}
+
+/* *
+ * @tc.name: ItFsJffs142
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs142, TestSize.Level0)
+{
+ ItFsJffs142();
+}
+
+/* *
+ * @tc.name: ItFsJffs143
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs143, TestSize.Level0)
+{
+ ItFsJffs143();
+}
+
+/* *
+ * @tc.name: ItFsJffs144
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs144, TestSize.Level0)
+{
+ ItFsJffs144();
+}
+
+/* *
+ * @tc.name: ItFsJffs145
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs145, TestSize.Level0)
+{
+ ItFsJffs145();
+}
+
+/* *
+ * @tc.name: ItFsJffs146
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs146, TestSize.Level0)
+{
+ ItFsJffs146();
+}
+
+/* *
+ * @tc.name: ItFsJffs147
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs147, TestSize.Level0)
+{
+ ItFsJffs147();
+}
+
+/* *
+ * @tc.name: ItFsJffs148
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs148, TestSize.Level0)
+{
+ ItFsJffs148();
+}
+
+/* *
+ * @tc.name: ItFsJffs149
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs149, TestSize.Level0)
+{
+ ItFsJffs149();
+}
+
+/* *
+ * @tc.name: ItFsJffs150
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs150, TestSize.Level0)
+{
+ ItFsJffs150();
+}
+
+/* *
+ * @tc.name: ItFsJffs151
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs151, TestSize.Level0)
+{
+ ItFsJffs151();
+}
+
+/* *
+ * @tc.name: ItFsJffs152
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs152, TestSize.Level0)
+{
+ ItFsJffs152();
+}
+
+/* *
+ * @tc.name: ItFsJffs153
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs153, TestSize.Level0)
+{
+ ItFsJffs153();
+}
+
+/* *
+ * @tc.name: ItFsJffs154
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs154, TestSize.Level0)
+{
+ ItFsJffs154();
+}
+
+/* *
+ * @tc.name: ItFsJffs155
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs155, TestSize.Level0)
+{
+ ItFsJffs155();
+}
+
+/* *
+ * @tc.name: ItFsJffs156
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs156, TestSize.Level0)
+{
+ ItFsJffs156();
+}
+
+/* *
+ * @tc.name: ItFsJffs157
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs157, TestSize.Level0)
+{
+ ItFsJffs157();
+}
+
+/* *
+ * @tc.name: ItFsJffs158
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs158, TestSize.Level0)
+{
+ ItFsJffs158();
+}
+
+/* *
+ * @tc.name: ItFsJffs159
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs159, TestSize.Level0)
+{
+ ItFsJffs159();
+}
+
+/* *
+ * @tc.name: ItFsJffs160
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs160, TestSize.Level0)
+{
+ ItFsJffs160();
+}
+
+/* *
+ * @tc.name: ItFsJffs161
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs161, TestSize.Level0)
+{
+ ItFsJffs161();
+}
+
+/* *
+ * @tc.name: ItFsJffs162
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs162, TestSize.Level0)
+{
+ ItFsJffs162();
+}
+
+/* *
+ * @tc.name: ItFsJffs163
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs163, TestSize.Level0)
+{
+ ItFsJffs163();
+}
+
+/* *
+ * @tc.name: ItFsJffs164
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs164, TestSize.Level0)
+{
+ ItFsJffs164();
+}
+
+/* *
+ * @tc.name: ItFsJffs165
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs165, TestSize.Level0)
+{
+ ItFsJffs165();
+}
+
+/* *
+ * @tc.name: ItFsJffs166
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs166, TestSize.Level0)
+{
+ ItFsJffs166();
+}
+
+/* *
+ * @tc.name: ItFsJffs167
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs167, TestSize.Level0)
+{
+ ItFsJffs167();
+}
+
+/* *
+ * @tc.name: ItFsJffs168
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs168, TestSize.Level0)
+{
+ ItFsJffs168();
+}
+
+/* *
+ * @tc.name: ItFsJffs169
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs169, TestSize.Level0)
+{
+ ItFsJffs169();
+}
+
+/* *
+ * @tc.name: ItFsJffs170
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs170, TestSize.Level0)
+{
+ ItFsJffs170();
+}
+
+/* *
+ * @tc.name: ItFsJffs171
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs171, TestSize.Level0)
+{
+ ItFsJffs171();
+}
+
+/* *
+ * @tc.name: ItFsJffs172
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs172, TestSize.Level0)
+{
+ ItFsJffs172();
+}
+
+/* *
+ * @tc.name: ItFsJffs173
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs173, TestSize.Level0)
+{
+ ItFsJffs173();
+}
+
+/* *
+ * @tc.name: ItFsJffs175
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs175, TestSize.Level0)
+{
+ ItFsJffs175();
+}
+
+/* *
+ * @tc.name: ItFsJffs176
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs176, TestSize.Level0)
+{
+ ItFsJffs176();
+}
+
+/* *
+ * @tc.name: ItFsJffs177
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs177, TestSize.Level0)
+{
+ ItFsJffs177();
+}
+
+/* *
+ * @tc.name: ItFsJffs178
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs178, TestSize.Level0)
+{
+ ItFsJffs178();
+}
+
+/* *
+ * @tc.name: ItFsJffs179
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs179, TestSize.Level0)
+{
+ ItFsJffs179();
+}
+
+/* *
+ * @tc.name: ItFsJffs180
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs180, TestSize.Level0)
+{
+ ItFsJffs180();
+}
+
+/* *
+ * @tc.name: ItFsJffs182
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs182, TestSize.Level0)
+{
+ ItFsJffs182();
+}
+
+/* *
+ * @tc.name: ItFsJffs183
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs183, TestSize.Level0)
+{
+ ItFsJffs183();
+}
+
+/* *
+ * @tc.name: ItFsJffs184
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs184, TestSize.Level0)
+{
+ ItFsJffs184();
+}
+
+/* *
+ * @tc.name: ItFsJffs185
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs185, TestSize.Level0)
+{
+ ItFsJffs185();
+}
+
+/* *
+ * @tc.name: ItFsJffs187
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs187, TestSize.Level0)
+{
+ ItFsJffs187();
+}
+
+/* *
+ * @tc.name: ItFsJffs188
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs188, TestSize.Level0)
+{
+ ItFsJffs188();
+}
+
+/* *
+ * @tc.name: ItFsJffs189
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs189, TestSize.Level0)
+{
+ ItFsJffs189();
+}
+
+/* *
+ * @tc.name: ItFsJffs190
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs190, TestSize.Level0)
+{
+ ItFsJffs190();
+}
+
+/* *
+ * @tc.name: ItFsJffs191
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs191, TestSize.Level0)
+{
+ ItFsJffs191();
+}
+
+/* *
+ * @tc.name: ItFsJffs192
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs192, TestSize.Level0)
+{
+ ItFsJffs192();
+}
+
+/* *
+ * @tc.name: ItFsJffs193
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs193, TestSize.Level0)
+{
+ ItFsJffs193();
+}
+
+/* *
+ * @tc.name: ItFsJffs194
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs194, TestSize.Level0)
+{
+ ItFsJffs194();
+}
+
+/* *
+ * @tc.name: ItFsJffs195
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs195, TestSize.Level0)
+{
+ ItFsJffs195();
+}
+
+/* *
+ * @tc.name: ItFsJffs196
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs196, TestSize.Level0)
+{
+ ItFsJffs196();
+}
+
+/* *
+ * @tc.name: ItFsJffs197
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs197, TestSize.Level0)
+{
+ ItFsJffs197();
+}
+
+/* *
+ * @tc.name: ItFsJffs198
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs198, TestSize.Level0)
+{
+ ItFsJffs198();
+}
+
+/* *
+ * @tc.name: ItFsJffs199
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs199, TestSize.Level0)
+{
+ ItFsJffs199();
+}
+
+/* *
+ * @tc.name: ItFsJffs200
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs200, TestSize.Level0)
+{
+ ItFsJffs200();
+}
+
+/* *
+ * @tc.name: ItFsJffs202
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs202, TestSize.Level0)
+{
+ ItFsJffs202();
+}
+
+/* *
+ * @tc.name: ItFsJffs203
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs203, TestSize.Level0)
+{
+ ItFsJffs203();
+}
+
+/* *
+ * @tc.name: ItFsJffs204
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs204, TestSize.Level0)
+{
+ ItFsJffs204();
+}
+
+/* *
+ * @tc.name: ItFsJffs205
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs205, TestSize.Level0)
+{
+ ItFsJffs205();
+}
+
+/* *
+ * @tc.name: ItFsJffs206
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs206, TestSize.Level0)
+{
+ ItFsJffs206();
+}
+
+/* *
+ * @tc.name: ItFsJffs207
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs207, TestSize.Level0)
+{
+ ItFsJffs207();
+}
+
+/* *
+ * @tc.name: ItFsJffs208
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs208, TestSize.Level0)
+{
+ ItFsJffs208();
+}
+
+/* *
+ * @tc.name: ItFsJffs209
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs209, TestSize.Level0)
+{
+ ItFsJffs209();
+}
+
+/* *
+ * @tc.name: ItFsJffs210
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs210, TestSize.Level0)
+{
+ ItFsJffs210();
+}
+
+/* *
+ * @tc.name: ItFsJffs211
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs211, TestSize.Level0)
+{
+ ItFsJffs211();
+}
+
+/* *
+ * @tc.name: ItFsJffs212
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs212, TestSize.Level0)
+{
+ ItFsJffs212();
+}
+
+/* *
+ * @tc.name: ItFsJffs213
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs213, TestSize.Level0)
+{
+ ItFsJffs213();
+}
+
+/* *
+ * @tc.name: ItFsJffs214
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs214, TestSize.Level0)
+{
+ ItFsJffs214();
+}
+
+/* *
+ * @tc.name: ItFsJffs215
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs215, TestSize.Level0)
+{
+ ItFsJffs215();
+}
+
+/* *
+ * @tc.name: ItFsJffs216
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs216, TestSize.Level0)
+{
+ ItFsJffs216();
+}
+
+/* *
+ * @tc.name: ItFsJffs217
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs217, TestSize.Level0)
+{
+ ItFsJffs217();
+}
+
+/* *
+ * @tc.name: ItFsJffs218
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs218, TestSize.Level0)
+{
+ ItFsJffs218();
+}
+
+/* *
+ * @tc.name: ItFsJffs219
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs219, TestSize.Level0)
+{
+ ItFsJffs219();
+}
+
+/* *
+ * @tc.name: ItFsJffs220
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs220, TestSize.Level0)
+{
+ ItFsJffs220();
+}
+
+/* *
+ * @tc.name: ItFsJffs221
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs221, TestSize.Level0)
+{
+ ItFsJffs221();
+}
+
+/* *
+ * @tc.name: ItFsJffs222
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs222, TestSize.Level0)
+{
+ ItFsJffs222();
+}
+
+/* *
+ * @tc.name: ItFsJffs223
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs223, TestSize.Level0)
+{
+ ItFsJffs223();
+}
+
+/* *
+ * @tc.name: ItFsJffs224
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs224, TestSize.Level0)
+{
+ ItFsJffs224();
+}
+
+/* *
+ * @tc.name: ItFsJffs225
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs225, TestSize.Level0)
+{
+ ItFsJffs225();
+}
+
+/* *
+ * @tc.name: ItFsJffs226
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs226, TestSize.Level0)
+{
+ ItFsJffs226();
+}
+
+/* *
+ * @tc.name: ItFsJffs227
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs227, TestSize.Level0)
+{
+ ItFsJffs227();
+}
+
+/* *
+ * @tc.name: ItFsJffs228
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs228, TestSize.Level0)
+{
+ ItFsJffs228();
+}
+
+/* *
+ * @tc.name: ItFsJffs229
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs229, TestSize.Level0)
+{
+ ItFsJffs229();
+}
+
+/* *
+ * @tc.name: ItFsJffs230
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs230, TestSize.Level0)
+{
+ ItFsJffs230();
+}
+
+/* *
+ * @tc.name: ItFsJffs231
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs231, TestSize.Level0)
+{
+ ItFsJffs231();
+}
+
+/* *
+ * @tc.name: ItFsJffs232
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs232, TestSize.Level0)
+{
+ ItFsJffs232();
+}
+
+/* *
+ * @tc.name: ItFsJffs233
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs233, TestSize.Level0)
+{
+ ItFsJffs233();
+}
+
+/* *
+ * @tc.name: ItFsJffs234
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs234, TestSize.Level0)
+{
+ ItFsJffs234();
+}
+
+/* *
+ * @tc.name: ItFsJffs235
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs235, TestSize.Level0)
+{
+ ItFsJffs235();
+}
+
+/* *
+ * @tc.name: ItFsJffs236
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs236, TestSize.Level0)
+{
+ ItFsJffs236();
+}
+
+/* *
+ * @tc.name: ItFsJffs237
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs237, TestSize.Level0)
+{
+ ItFsJffs237();
+}
+
+/* *
+ * @tc.name: ItFsJffs238
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs238, TestSize.Level0)
+{
+ ItFsJffs238();
+}
+
+/* *
+ * @tc.name: ItFsJffs239
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs239, TestSize.Level0)
+{
+ ItFsJffs239();
+}
+
+/* *
+ * @tc.name: ItFsJffs240
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs240, TestSize.Level0)
+{
+ ItFsJffs240();
+}
+
+/* *
+ * @tc.name: ItFsJffs241
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs241, TestSize.Level0)
+{
+ ItFsJffs241();
+}
+
+/* *
+ * @tc.name: ItFsJffs242
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs242, TestSize.Level0)
+{
+ ItFsJffs242();
+}
+
+/* *
+ * @tc.name: ItFsJffs243
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs243, TestSize.Level0)
+{
+ ItFsJffs243();
+}
+
+/* *
+ * @tc.name: ItFsJffs244
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs244, TestSize.Level0)
+{
+ ItFsJffs244();
+}
+
+/* *
+ * @tc.name: ItFsJffs245
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs245, TestSize.Level0)
+{
+ ItFsJffs245();
+}
+
+/* *
+ * @tc.name: ItFsJffs246
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs246, TestSize.Level0)
+{
+ ItFsJffs246();
+}
+
+/* *
+ * @tc.name: ItFsJffs247
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs247, TestSize.Level0)
+{
+ ItFsJffs247();
+}
+
+/* *
+ * @tc.name: ItFsJffs248
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs248, TestSize.Level0)
+{
+ ItFsJffs248();
+}
+
+/* *
+ * @tc.name: ItFsJffs249
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs249, TestSize.Level0)
+{
+ ItFsJffs249();
+}
+
+/* *
+ * @tc.name: ItFsJffs250
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs250, TestSize.Level0)
+{
+ ItFsJffs250();
+}
+
+/* *
+ * @tc.name: ItFsJffs251
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs251, TestSize.Level0)
+{
+ ItFsJffs251();
+}
+
+/* *
+ * @tc.name: ItFsJffs252
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs252, TestSize.Level0)
+{
+ ItFsJffs252();
+}
+
+/* *
+ * @tc.name: ItFsJffs253
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs253, TestSize.Level0)
+{
+ ItFsJffs253();
+}
+
+/* *
+ * @tc.name: ItFsJffs254
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs254, TestSize.Level0)
+{
+ ItFsJffs254();
+}
+
+/* *
+ * @tc.name: ItFsJffs255
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs255, TestSize.Level0)
+{
+ ItFsJffs255();
+}
+
+/* *
+ * @tc.name: ItFsJffs256
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs256, TestSize.Level0)
+{
+ ItFsJffs256();
+}
+
+/* *
+ * @tc.name: ItFsJffs257
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs257, TestSize.Level0)
+{
+ ItFsJffs257();
+}
+
+/* *
+ * @tc.name: ItFsJffs258
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs258, TestSize.Level0)
+{
+ ItFsJffs258();
+}
+
+/* *
+ * @tc.name: ItFsJffs259
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs259, TestSize.Level0)
+{
+ ItFsJffs259();
+}
+
+/* *
+ * @tc.name: ItFsJffs260
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs260, TestSize.Level0)
+{
+ ItFsJffs260();
+}
+
+/* *
+ * @tc.name: ItFsJffs261
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs261, TestSize.Level0)
+{
+ ItFsJffs261();
+}
+
+/* *
+ * @tc.name: ItFsJffs262
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs262, TestSize.Level0)
+{
+ ItFsJffs262();
+}
+
+/* *
+ * @tc.name: ItFsJffs263
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs263, TestSize.Level0)
+{
+ ItFsJffs263();
+}
+
+/* *
+ * @tc.name: ItFsJffs264
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs264, TestSize.Level0)
+{
+ ItFsJffs264();
+}
+
+/* *
+ * @tc.name: ItFsJffs265
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs265, TestSize.Level0)
+{
+ ItFsJffs265();
+}
+
+/* *
+ * @tc.name: ItFsJffs266
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs266, TestSize.Level0)
+{
+ ItFsJffs266();
+}
+
+/* *
+ * @tc.name: ItFsJffs267
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs267, TestSize.Level0)
+{
+ ItFsJffs267();
+}
+
+/* *
+ * @tc.name: ItFsJffs268
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs268, TestSize.Level0)
+{
+ ItFsJffs268();
+}
+
+/* *
+ * @tc.name: ItFsJffs269
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs269, TestSize.Level0)
+{
+ ItFsJffs269();
+}
+
+/* *
+ * @tc.name: ItFsJffs270
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs270, TestSize.Level0)
+{
+ ItFsJffs270();
+}
+
+/* *
+ * @tc.name: ItFsJffs271
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs271, TestSize.Level0)
+{
+ ItFsJffs271();
+}
+
+/* *
+ * @tc.name: ItFsJffs272
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs272, TestSize.Level0)
+{
+ ItFsJffs272();
+}
+
+/* *
+ * @tc.name: ItFsJffs273
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs273, TestSize.Level0)
+{
+ ItFsJffs273();
+}
+
+/* *
+ * @tc.name: ItFsJffs274
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs274, TestSize.Level0)
+{
+ ItFsJffs274();
+}
+
+/* *
+ * @tc.name: ItFsJffs275
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs275, TestSize.Level0)
+{
+ ItFsJffs275();
+}
+
+/* *
+ * @tc.name: ItFsJffs276
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs276, TestSize.Level0)
+{
+ ItFsJffs276();
+}
+
+/* *
+ * @tc.name: ItFsJffs277
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs277, TestSize.Level0)
+{
+ ItFsJffs277();
+}
+
+/* *
+ * @tc.name: ItFsJffs278
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs278, TestSize.Level0)
+{
+ ItFsJffs278();
+}
+
+/* *
+ * @tc.name: ItFsJffs279
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs279, TestSize.Level0)
+{
+ ItFsJffs279();
+}
+
+/* *
+ * @tc.name: ItFsJffs280
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs280, TestSize.Level0)
+{
+ ItFsJffs280();
+}
+
+/* *
+ * @tc.name: ItFsJffs281
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs281, TestSize.Level0)
+{
+ ItFsJffs281();
+}
+
+/* *
+ * @tc.name: ItFsJffs282
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs282, TestSize.Level0)
+{
+ ItFsJffs282();
+}
+
+/* *
+ * @tc.name: ItFsJffs283
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs283, TestSize.Level0)
+{
+ ItFsJffs283();
+}
+
+/* *
+ * @tc.name: ItFsJffs284
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs284, TestSize.Level0)
+{
+ ItFsJffs284();
+}
+
+/* *
+ * @tc.name: ItFsJffs285
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs285, TestSize.Level0)
+{
+ ItFsJffs285();
+}
+
+/* *
+ * @tc.name: ItFsJffs288
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs288, TestSize.Level0)
+{
+ ItFsJffs288();
+}
+
+/* *
+ * @tc.name: ItFsJffs289
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs289, TestSize.Level0)
+{
+ ItFsJffs289();
+}
+
+/* *
+ * @tc.name: ItFsJffs290
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs290, TestSize.Level0)
+{
+ ItFsJffs290();
+}
+
+/* *
+ * @tc.name: ItFsJffs291
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs291, TestSize.Level0)
+{
+ ItFsJffs291();
+}
+
+/* *
+ * @tc.name: ItFsJffs292
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs292, TestSize.Level0)
+{
+ ItFsJffs292();
+}
+
+/* *
+ * @tc.name: ItFsJffs293
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs293, TestSize.Level0)
+{
+ ItFsJffs293();
+}
+
+/* *
+ * @tc.name: ItFsJffs294
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs294, TestSize.Level0)
+{
+ ItFsJffs294();
+}
+
+/* *
+ * @tc.name: ItFsJffs295
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs295, TestSize.Level0)
+{
+ ItFsJffs295();
+}
+
+/* *
+ * @tc.name: ItFsJffs296
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs296, TestSize.Level0)
+{
+ ItFsJffs296();
+}
+
+/* *
+ * @tc.name: ItFsJffs297
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs297, TestSize.Level0)
+{
+ ItFsJffs297();
+}
+
+/* *
+ * @tc.name: ItFsJffs298
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs298, TestSize.Level0)
+{
+ ItFsJffs298();
+}
+
+/* *
+ * @tc.name: ItFsJffs299
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs299, TestSize.Level0)
+{
+ ItFsJffs299();
+}
+
+/* *
+ * @tc.name: ItFsJffs300
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs300, TestSize.Level0)
+{
+ ItFsJffs300();
+}
+
+/* *
+ * @tc.name: ItFsJffs301
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs301, TestSize.Level0)
+{
+ ItFsJffs301();
+}
+
+/* *
+ * @tc.name: ItFsJffs302
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs302, TestSize.Level0)
+{
+ ItFsJffs302();
+}
+
+/* *
+ * @tc.name: ItFsJffs303
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs303, TestSize.Level0)
+{
+ ItFsJffs303();
+}
+
+/* *
+ * @tc.name: ItFsJffs304
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs304, TestSize.Level0)
+{
+ ItFsJffs304();
+}
+
+/* *
+ * @tc.name: ItFsJffs305
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs305, TestSize.Level0)
+{
+ ItFsJffs305();
+}
+
+/* *
+ * @tc.name: ItFsJffs306
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs306, TestSize.Level0)
+{
+ ItFsJffs306();
+}
+
+/* *
+ * @tc.name: ItFsJffs307
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs307, TestSize.Level0)
+{
+ ItFsJffs307();
+}
+
+/* *
+ * @tc.name: ItFsJffs308
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs308, TestSize.Level0)
+{
+ ItFsJffs308();
+}
+
+/* *
+ * @tc.name: ItFsJffs309
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs309, TestSize.Level0)
+{
+ ItFsJffs309();
+}
+
+/* *
+ * @tc.name: ItFsJffs310
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs310, TestSize.Level0)
+{
+ ItFsJffs310();
+}
+
+/* *
+ * @tc.name: ItFsJffs311
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs311, TestSize.Level0)
+{
+ ItFsJffs311();
+}
+
+/* *
+ * @tc.name: ItFsJffs312
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs312, TestSize.Level0)
+{
+ ItFsJffs312();
+}
+
+/* *
+ * @tc.name: ItFsJffs313
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs313, TestSize.Level0)
+{
+ ItFsJffs313();
+}
+
+/* *
+ * @tc.name: ItFsJffs314
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs314, TestSize.Level0)
+{
+ ItFsJffs314();
+}
+
+/* *
+ * @tc.name: ItFsJffs315
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs315, TestSize.Level0)
+{
+ ItFsJffs315();
+}
+
+/* *
+ * @tc.name: ItFsJffs316
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs316, TestSize.Level0)
+{
+ ItFsJffs316();
+}
+
+/* *
+ * @tc.name: ItFsJffs317
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs317, TestSize.Level0)
+{
+ ItFsJffs317();
+}
+
+/* *
+ * @tc.name: ItFsJffs318
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs318, TestSize.Level0)
+{
+ ItFsJffs318();
+}
+
+/* *
+ * @tc.name: ItFsJffs319
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs319, TestSize.Level0)
+{
+ ItFsJffs319();
+}
+
+/* *
+ * @tc.name: ItFsJffs320
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs320, TestSize.Level0)
+{
+ ItFsJffs320();
+}
+
+/* *
+ * @tc.name: ItFsJffs321
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs321, TestSize.Level0)
+{
+ ItFsJffs321();
+}
+
+/* *
+ * @tc.name: ItFsJffs322
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs322, TestSize.Level0)
+{
+ ItFsJffs322();
+}
+
+/* *
+ * @tc.name: ItFsJffs323
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs323, TestSize.Level0)
+{
+ ItFsJffs323();
+}
+
+/* *
+ * @tc.name: ItFsJffs324
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs324, TestSize.Level0)
+{
+ ItFsJffs324();
+}
+
+/* *
+ * @tc.name: ItFsJffs325
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs325, TestSize.Level0)
+{
+ ItFsJffs325();
+}
+
+/* *
+ * @tc.name: ItFsJffs326
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs326, TestSize.Level0)
+{
+ ItFsJffs326();
+}
+
+/* *
+ * @tc.name: ItFsJffs327
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs327, TestSize.Level0)
+{
+ ItFsJffs327();
+}
+
+/* *
+ * @tc.name: ItFsJffs328
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs328, TestSize.Level0)
+{
+ ItFsJffs328();
+}
+
+/* *
+ * @tc.name: ItFsJffs329
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs329, TestSize.Level0)
+{
+ ItFsJffs329();
+}
+
+/* *
+ * @tc.name: ItFsJffs330
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs330, TestSize.Level0)
+{
+ ItFsJffs330();
+}
+
+/* *
+ * @tc.name: ItFsJffs331
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs331, TestSize.Level0)
+{
+ ItFsJffs331();
+}
+
+/* *
+ * @tc.name: ItFsJffs332
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs332, TestSize.Level0)
+{
+ ItFsJffs332();
+}
+
+/* *
+ * @tc.name: ItFsJffs333
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs333, TestSize.Level0)
+{
+ ItFsJffs333();
+}
+
+/* *
+ * @tc.name: ItFsJffs334
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs334, TestSize.Level0)
+{
+ ItFsJffs334();
+}
+
+/* *
+ * @tc.name: ItFsJffs335
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs335, TestSize.Level0)
+{
+ ItFsJffs335();
+}
+
+/* *
+ * @tc.name: ItFsJffs336
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs336, TestSize.Level0)
+{
+ ItFsJffs336();
+}
+
+/* *
+ * @tc.name: ItFsJffs337
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs337, TestSize.Level0)
+{
+ ItFsJffs337();
+}
+
+/* *
+ * @tc.name: ItFsJffs338
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs338, TestSize.Level0)
+{
+ ItFsJffs338();
+}
+
+/* *
+ * @tc.name: ItFsJffs339
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs339, TestSize.Level0)
+{
+ ItFsJffs339();
+}
+
+/* *
+ * @tc.name: ItFsJffs340
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs340, TestSize.Level0)
+{
+ ItFsJffs340();
+}
+
+/* *
+ * @tc.name: ItFsJffs342
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs342, TestSize.Level0)
+{
+ ItFsJffs342();
+}
+
+/* *
+ * @tc.name: ItFsJffs343
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs343, TestSize.Level0)
+{
+ ItFsJffs343();
+}
+
+/* *
+ * @tc.name: ItFsJffs344
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs344, TestSize.Level0)
+{
+ ItFsJffs344();
+}
+
+/* *
+ * @tc.name: ItFsJffs346
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs346, TestSize.Level0)
+{
+ ItFsJffs346();
+}
+
+/* *
+ * @tc.name: ItFsJffs352
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs352, TestSize.Level0)
+{
+ ItFsJffs352();
+}
+
+/* *
+ * @tc.name: ItFsJffs353
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs353, TestSize.Level0)
+{
+ ItFsJffs353();
+}
+
+/* *
+ * @tc.name: ItFsJffs354
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs354, TestSize.Level0)
+{
+ ItFsJffs354();
+}
+
+/* *
+ * @tc.name: ItFsJffs355
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs355, TestSize.Level0)
+{
+ ItFsJffs355();
+}
+
+/* *
+ * @tc.name: ItFsJffs356
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs356, TestSize.Level0)
+{
+ ItFsJffs356();
+}
+
+/* *
+ * @tc.name: ItFsJffs357
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs357, TestSize.Level0)
+{
+ ItFsJffs357();
+}
+
+/* *
+ * @tc.name: ItFsJffs358
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs358, TestSize.Level0)
+{
+ ItFsJffs358();
+}
+
+/* *
+ * @tc.name: ItFsJffs359
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs359, TestSize.Level0)
+{
+ ItFsJffs359();
+}
+
+/* *
+ * @tc.name: ItFsJffs360
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs360, TestSize.Level0)
+{
+ ItFsJffs360();
+}
+
+/* *
+ * @tc.name: ItFsJffs361
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs361, TestSize.Level0)
+{
+ ItFsJffs361();
+}
+
+/* *
+ * @tc.name: ItFsJffs362
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs362, TestSize.Level0)
+{
+ ItFsJffs362();
+}
+
+/* *
+ * @tc.name: ItFsJffs364
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs364, TestSize.Level0)
+{
+ ItFsJffs364();
+}
+
+/* *
+ * @tc.name: ItFsJffs365
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs365, TestSize.Level0)
+{
+ ItFsJffs365();
+}
+
+/* *
+ * @tc.name: ItFsJffs366
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs366, TestSize.Level0)
+{
+ ItFsJffs366();
+}
+
+/* *
+ * @tc.name: ItFsJffs367
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs367, TestSize.Level0)
+{
+ ItFsJffs367();
+}
+
+/* *
+ * @tc.name: ItFsJffs368
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs368, TestSize.Level0)
+{
+ ItFsJffs368();
+}
+
+/* *
+ * @tc.name: ItFsJffs369
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs369, TestSize.Level0)
+{
+ ItFsJffs369();
+}
+
+/* *
+ * @tc.name: ItFsJffs370
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs370, TestSize.Level0)
+{
+ ItFsJffs370();
+}
+
+/* *
+ * @tc.name: ItFsJffs371
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs371, TestSize.Level0)
+{
+ ItFsJffs371();
+}
+
+/* *
+ * @tc.name: ItFsJffs372
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs372, TestSize.Level0)
+{
+ ItFsJffs372();
+}
+
+/* *
+ * @tc.name: ItFsJffs373
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs373, TestSize.Level0)
+{
+ ItFsJffs373();
+}
+
+/* *
+ * @tc.name: ItFsJffs374
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs374, TestSize.Level0)
+{
+ ItFsJffs374();
+}
+
+/* *
+ * @tc.name: ItFsJffs375
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs375, TestSize.Level0)
+{
+ ItFsJffs375();
+}
+
+/* *
+ * @tc.name: ItFsJffs376
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs376, TestSize.Level0)
+{
+ ItFsJffs376();
+}
+
+/* *
+ * @tc.name: ItFsJffs377
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs377, TestSize.Level0)
+{
+ ItFsJffs377();
+}
+
+/* *
+ * @tc.name: ItFsJffs378
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs378, TestSize.Level0)
+{
+ ItFsJffs378();
+}
+
+/* *
+ * @tc.name: ItFsJffs379
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs379, TestSize.Level0)
+{
+ ItFsJffs379();
+}
+
+/* *
+ * @tc.name: ItFsJffs380
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs380, TestSize.Level0)
+{
+ ItFsJffs380();
+}
+
+/* *
+ * @tc.name: ItFsJffs381
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs381, TestSize.Level0)
+{
+ ItFsJffs381();
+}
+
+/* *
+ * @tc.name: ItFsJffs382
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs382, TestSize.Level0)
+{
+ ItFsJffs382();
+}
+
+/* *
+ * @tc.name: ItFsJffs383
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs383, TestSize.Level0)
+{
+ ItFsJffs383();
+}
+
+/* *
+ * @tc.name: ItFsJffs384
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs384, TestSize.Level0)
+{
+ ItFsJffs384();
+}
+
+/* *
+ * @tc.name: ItFsJffs385
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs385, TestSize.Level0)
+{
+ ItFsJffs385();
+}
+
+/* *
+ * @tc.name: ItFsJffs386
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs386, TestSize.Level0)
+{
+ ItFsJffs386();
+}
+
+/* *
+ * @tc.name: ItFsJffs387
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs387, TestSize.Level0)
+{
+ ItFsJffs387();
+}
+
+/* *
+ * @tc.name: ItFsJffs388
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs388, TestSize.Level0)
+{
+ ItFsJffs388();
+}
+
+/* *
+ * @tc.name: ItFsJffs389
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs389, TestSize.Level0)
+{
+ ItFsJffs389();
+}
+
+/* *
+ * @tc.name: ItFsJffs390
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs390, TestSize.Level0)
+{
+ ItFsJffs390();
+}
+
+/* *
+ * @tc.name: ItFsJffs391
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs391, TestSize.Level0)
+{
+ ItFsJffs391();
+}
+
+/* *
+ * @tc.name: ItFsJffs392
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs392, TestSize.Level0)
+{
+ ItFsJffs392();
+}
+
+/* *
+ * @tc.name: ItFsJffs393
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs393, TestSize.Level0)
+{
+ ItFsJffs393();
+}
+
+/* *
+ * @tc.name: ItFsJffs394
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs394, TestSize.Level0)
+{
+ ItFsJffs394();
+}
+
+/* *
+ * @tc.name: ItFsJffs395
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs395, TestSize.Level0)
+{
+ ItFsJffs395();
+}
+
+/* *
+ * @tc.name: ItFsJffs396
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs396, TestSize.Level0)
+{
+ ItFsJffs396();
+}
+
+/* *
+ * @tc.name: ItFsJffs397
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs397, TestSize.Level0)
+{
+ ItFsJffs397();
+}
+
+/* *
+ * @tc.name: ItFsJffs398
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs398, TestSize.Level0)
+{
+ ItFsJffs398();
+}
+
+/* *
+ * @tc.name: ItFsJffs399
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs399, TestSize.Level0)
+{
+ ItFsJffs399();
+}
+
+/* *
+ * @tc.name: ItFsJffs400
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs400, TestSize.Level0)
+{
+ ItFsJffs400();
+}
+
+/* *
+ * @tc.name: ItFsJffs401
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs401, TestSize.Level0)
+{
+ ItFsJffs401();
+}
+
+/* *
+ * @tc.name: ItFsJffs402
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs402, TestSize.Level0)
+{
+ ItFsJffs402();
+}
+
+/* *
+ * @tc.name: ItFsJffs403
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs403, TestSize.Level0)
+{
+ ItFsJffs403();
+}
+
+/* *
+ * @tc.name: ItFsJffs404
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs404, TestSize.Level0)
+{
+ ItFsJffs404();
+}
+
+/* *
+ * @tc.name: ItFsJffs405
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs405, TestSize.Level0)
+{
+ ItFsJffs405();
+}
+
+/* *
+ * @tc.name: ItFsJffs406
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs406, TestSize.Level0)
+{
+ ItFsJffs406();
+}
+
+/* *
+ * @tc.name: ItFsJffs407
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs407, TestSize.Level0)
+{
+ ItFsJffs407();
+}
+
+/* *
+ * @tc.name: ItFsJffs408
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs408, TestSize.Level0)
+{
+ ItFsJffs408();
+}
+
+/* *
+ * @tc.name: ItFsJffs409
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs409, TestSize.Level0)
+{
+ ItFsJffs409();
+}
+
+/* *
+ * @tc.name: ItFsJffs410
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs410, TestSize.Level0)
+{
+ ItFsJffs410();
+}
+
+/* *
+ * @tc.name: ItFsJffs411
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs411, TestSize.Level0)
+{
+ ItFsJffs411();
+}
+
+/* *
+ * @tc.name: ItFsJffs412
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs412, TestSize.Level0)
+{
+ ItFsJffs412();
+}
+
+/* *
+ * @tc.name: ItFsJffs413
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs413, TestSize.Level0)
+{
+ ItFsJffs413();
+}
+
+/* *
+ * @tc.name: ItFsJffs414
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs414, TestSize.Level0)
+{
+ ItFsJffs414();
+}
+
+/* *
+ * @tc.name: ItFsJffs415
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs415, TestSize.Level0)
+{
+ ItFsJffs415();
+}
+
+/* *
+ * @tc.name: ItFsJffs416
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs416, TestSize.Level0)
+{
+ ItFsJffs416();
+}
+
+/* *
+ * @tc.name: ItFsJffs417
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs417, TestSize.Level0)
+{
+ ItFsJffs417();
+}
+
+/* *
+ * @tc.name: ItFsJffs418
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs418, TestSize.Level0)
+{
+ ItFsJffs418();
+}
+
+/* *
+ * @tc.name: ItFsJffs419
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs419, TestSize.Level0)
+{
+ ItFsJffs419();
+}
+
+/* *
+ * @tc.name: ItFsJffs420
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs420, TestSize.Level0)
+{
+ ItFsJffs420();
+}
+
+/* *
+ * @tc.name: ItFsJffs421
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs421, TestSize.Level0)
+{
+ ItFsJffs421();
+}
+
+/* *
+ * @tc.name: ItFsJffs422
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs422, TestSize.Level0)
+{
+ ItFsJffs422();
+}
+
+/* *
+ * @tc.name: ItFsJffs423
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs423, TestSize.Level0)
+{
+ ItFsJffs423();
+}
+
+/* *
+ * @tc.name: ItFsJffs424
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs424, TestSize.Level0)
+{
+ ItFsJffs424();
+}
+
+/* *
+ * @tc.name: ItFsJffs425
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs425, TestSize.Level0)
+{
+ ItFsJffs425();
+}
+
+/* *
+ * @tc.name: ItFsJffs426
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs426, TestSize.Level0)
+{
+ ItFsJffs426();
+}
+
+/* *
+ * @tc.name: ItFsJffs427
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs427, TestSize.Level0)
+{
+ ItFsJffs427();
+}
+
+/* *
+ * @tc.name: ItFsJffs428
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs428, TestSize.Level0)
+{
+ ItFsJffs428();
+}
+
+/* *
+ * @tc.name: ItFsJffs429
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs429, TestSize.Level0)
+{
+ ItFsJffs429();
+}
+
+/* *
+ * @tc.name: ItFsJffs430
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs430, TestSize.Level0)
+{
+ ItFsJffs430();
+}
+
+/* *
+ * @tc.name: ItFsJffs431
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs431, TestSize.Level0)
+{
+ ItFsJffs431();
+}
+
+/* *
+ * @tc.name: ItFsJffs432
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs432, TestSize.Level0)
+{
+ ItFsJffs432();
+}
+
+/* *
+ * @tc.name: ItFsJffs433
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs433, TestSize.Level0)
+{
+ ItFsJffs433();
+}
+
+/* *
+ * @tc.name: ItFsJffs434
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs434, TestSize.Level0)
+{
+ ItFsJffs434();
+}
+
+/* *
+ * @tc.name: ItFsJffs435
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs435, TestSize.Level0)
+{
+ ItFsJffs435();
+}
+
+/* *
+ * @tc.name: ItFsJffs454
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs454, TestSize.Level0)
+{
+ ItFsJffs454();
+}
+
+/* *
+ * @tc.name: ItFsJffs455
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs455, TestSize.Level0)
+{
+ ItFsJffs455();
+}
+
+/* *
+ * @tc.name: ItFsJffs456
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs456, TestSize.Level0)
+{
+ ItFsJffs456();
+}
+
+/* *
+ * @tc.name: ItFsJffs457
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs457, TestSize.Level0)
+{
+ ItFsJffs457();
+}
+
+/* *
+ * @tc.name: ItFsJffs458
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs458, TestSize.Level0)
+{
+ ItFsJffs458();
+}
+
+/* *
+ * @tc.name: ItFsJffs459
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs459, TestSize.Level0)
+{
+ ItFsJffs459();
+}
+
+/* *
+ * @tc.name: ItFsJffs460
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs460, TestSize.Level0)
+{
+ ItFsJffs460();
+}
+
+/* *
+ * @tc.name: ItFsJffs461
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs461, TestSize.Level0)
+{
+ ItFsJffs461();
+}
+
+/* *
+ * @tc.name: ItFsJffs462
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs462, TestSize.Level0)
+{
+ ItFsJffs462();
+}
+
+/* *
+ * @tc.name: ItFsJffs487
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs487, TestSize.Level0)
+{
+ ItFsJffs487();
+}
+
+/* *
+ * @tc.name: ItFsJffs488
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs488, TestSize.Level0)
+{
+ ItFsJffs488();
+}
+
+/* *
+ * @tc.name: ItFsJffs489
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs489, TestSize.Level0)
+{
+ ItFsJffs489();
+}
+
+/* *
+ * @tc.name: ItFsJffs490
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs490, TestSize.Level0)
+{
+ ItFsJffs490();
+}
+
+/* *
+ * @tc.name: ItFsJffs491
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs491, TestSize.Level0)
+{
+ ItFsJffs491();
+}
+
+/* *
+ * @tc.name: ItFsJffs492
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs492, TestSize.Level0)
+{
+ ItFsJffs492();
+}
+
+/* *
+ * @tc.name: ItFsJffs493
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs493, TestSize.Level0)
+{
+ ItFsJffs493();
+}
+
+/* *
+ * @tc.name: ItFsJffs494
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs494, TestSize.Level0)
+{
+ ItFsJffs494();
+}
+
+/* *
+ * @tc.name: ItFsJffs496
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs496, TestSize.Level0)
+{
+ ItFsJffs496();
+}
+
+/* *
+ * @tc.name: ItFsJffs497
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs497, TestSize.Level0)
+{
+ ItFsJffs497();
+}
+
+/* *
+ * @tc.name: ItFsJffs498
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs498, TestSize.Level0)
+{
+ ItFsJffs498();
+}
+
+/* *
+ * @tc.name: ItFsJffs499
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs499, TestSize.Level0)
+{
+ ItFsJffs499();
+}
+
+/* *
+ * @tc.name: ItFsJffs500
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs500, TestSize.Level0)
+{
+ ItFsJffs500();
+}
+
+/* *
+ * @tc.name: ItFsJffs501
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs501, TestSize.Level0)
+{
+ ItFsJffs501();
+}
+
+/* *
+ * @tc.name: ItFsJffs502
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs502, TestSize.Level0)
+{
+ ItFsJffs502();
+}
+
+/* *
+ * @tc.name: ItFsJffs503
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs503, TestSize.Level0)
+{
+ ItFsJffs503();
+}
+
+/* *
+ * @tc.name: ItFsJffs504
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs504, TestSize.Level0)
+{
+ ItFsJffs504();
+}
+
+/* *
+ * @tc.name: ItFsJffs505
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs505, TestSize.Level0)
+{
+ ItFsJffs505();
+}
+
+/* *
+ * @tc.name: ItFsJffs506
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs506, TestSize.Level0)
+{
+ ItFsJffs506();
+}
+
+/* *
+ * @tc.name: ItFsJffs507
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs507, TestSize.Level0)
+{
+ ItFsJffs507();
+}
+
+/* *
+ * @tc.name: ItFsJffs508
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs508, TestSize.Level0)
+{
+ ItFsJffs508();
+}
+
+/* *
+ * @tc.name: ItFsJffs509
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs509, TestSize.Level0)
+{
+ ItFsJffs509();
+}
+
+/* *
+ * @tc.name: ItFsJffs510
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs510, TestSize.Level0)
+{
+ ItFsJffs510();
+}
+
+/* *
+ * @tc.name: ItFsJffs511
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs511, TestSize.Level0)
+{
+ ItFsJffs511();
+}
+
+/* *
+ * @tc.name: ItFsJffs512
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs512, TestSize.Level0)
+{
+ ItFsJffs512();
+}
+
+/* *
+ * @tc.name: ItFsJffs513
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs513, TestSize.Level0)
+{
+ ItFsJffs513();
+}
+
+/* *
+ * @tc.name: ItFsJffs514
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs514, TestSize.Level0)
+{
+ ItFsJffs514();
+}
+
+/* *
+ * @tc.name: ItFsJffs515
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs515, TestSize.Level0)
+{
+ ItFsJffs515();
+}
+
+/* *
+ * @tc.name: ItFsJffs516
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs516, TestSize.Level0)
+{
+ ItFsJffs516();
+}
+
+/* *
+ * @tc.name: ItFsJffs517
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs517, TestSize.Level0)
+{
+ ItFsJffs517();
+}
+
+/* *
+ * @tc.name: ItFsJffs518
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs518, TestSize.Level0)
+{
+ ItFsJffs518();
+}
+
+/* *
+ * @tc.name: ItFsJffs519
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs519, TestSize.Level0)
+{
+ ItFsJffs519();
+}
+
+/* *
+ * @tc.name: ItFsJffs520
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs520, TestSize.Level0)
+{
+ ItFsJffs520();
+}
+
+/* *
+ * @tc.name: ItFsJffs521
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs521, TestSize.Level0)
+{
+ ItFsJffs521();
+}
+
+/* *
+ * @tc.name: ItFsJffs522
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs522, TestSize.Level0)
+{
+ ItFsJffs522();
+}
+
+/* *
+ * @tc.name: ItFsJffs523
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs523, TestSize.Level0)
+{
+ ItFsJffs523();
+}
+
+/* *
+ * @tc.name: ItFsJffs524
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs524, TestSize.Level0)
+{
+ ItFsJffs524();
+}
+
+/* *
+ * @tc.name: ItFsJffs526
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs526, TestSize.Level0)
+{
+ ItFsJffs526();
+}
+
+/* *
+ * @tc.name: ItFsJffs528
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs528, TestSize.Level0)
+{
+ ItFsJffs528();
+}
+
+/* *
+ * @tc.name: ItFsJffs529
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs529, TestSize.Level0)
+{
+ ItFsJffs529();
+}
+
+/* *
+ * @tc.name: ItFsJffs530
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs530, TestSize.Level0)
+{
+ ItFsJffs530();
+}
+
+/* *
+ * @tc.name: ItFsJffs531
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs531, TestSize.Level0)
+{
+ ItFsJffs531();
+}
+
+/* *
+ * @tc.name: ItFsJffs532
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs532, TestSize.Level0)
+{
+ ItFsJffs532();
+}
+
+/* *
+ * @tc.name: ItFsJffs533
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs533, TestSize.Level0)
+{
+ ItFsJffs533();
+}
+
+/* *
+ * @tc.name: ItFsJffs534
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs534, TestSize.Level0)
+{
+ ItFsJffs534();
+}
+
+/* *
+ * @tc.name: ItFsJffs541
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs541, TestSize.Level0)
+{
+ ItFsJffs541();
+}
+
+/* *
+ * @tc.name: ItFsJffs542
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs542, TestSize.Level0)
+{
+ ItFsJffs542();
+}
+
+/* *
+ * @tc.name: ItFsJffs543
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs543, TestSize.Level0)
+{
+ ItFsJffs543();
+}
+
+/* *
+ * @tc.name: ItFsJffs544
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs544, TestSize.Level0)
+{
+ ItFsJffs544();
+}
+
+/* *
+ * @tc.name: ItFsJffs545
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs545, TestSize.Level0)
+{
+ ItFsJffs545();
+}
+
+/* *
+ * @tc.name: ItFsJffs546
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs546, TestSize.Level0)
+{
+ ItFsJffs546();
+}
+
+/* *
+ * @tc.name: ItFsJffs547
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs547, TestSize.Level0)
+{
+ ItFsJffs547();
+}
+
+/* *
+ * @tc.name: ItFsJffs548
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs548, TestSize.Level0)
+{
+ ItFsJffs548();
+}
+
+/* *
+ * @tc.name: ItFsJffs549
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs549, TestSize.Level0)
+{
+ ItFsJffs549();
+}
+
+/* *
+ * @tc.name: ItFsJffs550
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs550, TestSize.Level0)
+{
+ ItFsJffs550();
+}
+
+/* *
+ * @tc.name: ItFsJffs551
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs551, TestSize.Level0)
+{
+ ItFsJffs551();
+}
+
+/* *
+ * @tc.name: ItFsJffs552
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs552, TestSize.Level0)
+{
+ ItFsJffs552();
+}
+
+/* *
+ * @tc.name: ItFsJffs553
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs553, TestSize.Level0)
+{
+ ItFsJffs553();
+}
+
+/* *
+ * @tc.name: ItFsJffs554
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs554, TestSize.Level0)
+{
+ ItFsJffs554();
+}
+
+/* *
+ * @tc.name: ItFsJffs555
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs555, TestSize.Level0)
+{
+ ItFsJffs555();
+}
+
+/* *
+ * @tc.name: ItFsJffs556
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs556, TestSize.Level0)
+{
+ ItFsJffs556();
+}
+
+/* *
+ * @tc.name: ItFsJffs557
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs557, TestSize.Level0)
+{
+ ItFsJffs557();
+}
+
+/* *
+ * @tc.name: ItFsJffs560
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs560, TestSize.Level0)
+{
+ ItFsJffs560();
+}
+
+/* *
+ * @tc.name: ItFsJffs562
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs562, TestSize.Level0)
+{
+ ItFsJffs562();
+}
+
+/* *
+ * @tc.name: ItFsJffs563
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs563, TestSize.Level0)
+{
+ ItFsJffs563();
+}
+
+/* *
+ * @tc.name: ItFsJffs564
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs564, TestSize.Level0)
+{
+ ItFsJffs564();
+}
+
+/* *
+ * @tc.name: ItFsJffs565
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs565, TestSize.Level0)
+{
+ ItFsJffs565();
+}
+
+/* *
+ * @tc.name: ItFsJffs566
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs566, TestSize.Level0)
+{
+ ItFsJffs566();
+}
+
+/* *
+ * @tc.name: ItFsJffs567
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs567, TestSize.Level0)
+{
+ ItFsJffs567();
+}
+
+/* *
+ * @tc.name: ItFsJffs568
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs568, TestSize.Level0)
+{
+ ItFsJffs568();
+}
+
+/* *
+ * @tc.name: ItFsJffs569
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs569, TestSize.Level0)
+{
+ ItFsJffs569(); // the second param in stat64 is NULL
+}
+
+/* *
+ * @tc.name: ItFsJffs570
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs570, TestSize.Level0)
+{
+ ItFsJffs570(); // the second param in stat64 is NULL
+}
+
+/* *
+ * @tc.name: ItFsJffs571
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs571, TestSize.Level0)
+{
+ ItFsJffs571();
+}
+
+/* *
+ * @tc.name: ItFsJffs572
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs572, TestSize.Level0)
+{
+ ItFsJffs572(); // the second param in fstat64 is NULL
+}
+
+/* *
+ * @tc.name: ItFsJffs573
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs573, TestSize.Level0)
+{
+ ItFsJffs573(); // the second param in fstat64 is NULL
+}
+
+/* *
+ * @tc.name: ItFsJffs574
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs574, TestSize.Level0)
+{
+ ItFsJffs574();
+}
+
+/* *
+ * @tc.name: ItFsJffs124
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs124, TestSize.Level0)
+{
+ ItFsJffs124();
+}
+
+/* *
+ * @tc.name: ItFsJffs125
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs125, TestSize.Level0)
+{
+ ItFsJffs125();
+}
+
+/* *
+ * @tc.name: ItFsJffs583
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs583, TestSize.Level0)
+{
+ ItFsJffs583();
+}
+
+/* *
+ * @tc.name: ItFsJffs584
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs584, TestSize.Level0)
+{
+ ItFsJffs584();
+}
+
+/* *
+ * @tc.name: ItFsJffs586
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs586, TestSize.Level0)
+{
+ ItFsJffs586();
+}
+
+/* *
+ * @tc.name: ItFsJffs589
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs589, TestSize.Level0)
+{
+ ItFsJffs589();
+}
+
+/* *
+ * @tc.name: ItFsJffs591
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs591, TestSize.Level0)
+{
+ ItFsJffs591();
+}
+
+/* *
+ * @tc.name: ItFsJffs592
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs592, TestSize.Level0)
+{
+ ItFsJffs592();
+}
+
+/* *
+ * @tc.name: ItFsJffs593
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs593, TestSize.Level0)
+{
+ ItFsJffs593();
+}
+
+/* *
+ * @tc.name: ItFsJffs594
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs594, TestSize.Level0)
+{
+ ItFsJffs594();
+}
+
+/* *
+ * @tc.name: ItFsJffs595
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs595, TestSize.Level0)
+{
+ ItFsJffs595();
+}
+
+/* *
+ * @tc.name: ItFsJffs596
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs596, TestSize.Level0)
+{
+ ItFsJffs596();
+}
+
+/* *
+ * @tc.name: ItFsJffs603
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs603, TestSize.Level0)
+{
+ ItFsJffs603();
+}
+
+/* *
+ * @tc.name: ItFsJffs636
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs636, TestSize.Level0)
+{
+ ItFsJffs636();
+}
+
+/* *
+ * @tc.name: ItFsJffs643
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs643, TestSize.Level0)
+{
+ ItFsJffs643();
+}
+
+/* *
+ * @tc.name: ItFsJffs644
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs644, TestSize.Level0)
+{
+ ItFsJffs644();
+}
+
+/* *
+ * @tc.name: ItFsJffs645
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs645, TestSize.Level0)
+{
+ ItFsJffs645();
+}
+
+/* *
+ * @tc.name: ItFsJffs646
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs646, TestSize.Level0)
+{
+ ItFsJffs646();
+}
+
+/* *
+ * @tc.name: ItFsJffs648
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs648, TestSize.Level0)
+{
+ ItFsJffs648();
+}
+
+/* *
+ * @tc.name: ItFsJffs649
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs649, TestSize.Level0)
+{
+ ItFsJffs649();
+}
+
+/* *
+ * @tc.name: ItFsJffs650
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs650, TestSize.Level0)
+{
+ ItFsJffs650();
+}
+
+/* *
+ * @tc.name: ItFsJffs651
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs651, TestSize.Level0)
+{
+ ItFsJffs651();
+}
+
+/* *
+ * @tc.name: ItFsJffs652
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs652, TestSize.Level0)
+{
+ ItFsJffs652();
+}
+
+/* *
+ * @tc.name: ItFsJffs653
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs653, TestSize.Level0)
+{
+ ItFsJffs653();
+}
+
+/* *
+ * @tc.name: ItFsJffs654
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs654, TestSize.Level0)
+{
+ ItFsJffs654();
+}
+
+/* *
+ * @tc.name: ItFsJffs655
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs655, TestSize.Level0)
+{
+ ItFsJffs655();
+}
+
+/* *
+ * @tc.name: ItFsJffs656
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs656, TestSize.Level0)
+{
+ ItFsJffs656();
+}
+
+/* *
+ * @tc.name: ItFsJffs663
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs663, TestSize.Level0)
+{
+ ItFsJffs663();
+}
+
+/* *
+ * @tc.name: ItFsJffs664
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs664, TestSize.Level0)
+{
+ ItFsJffs664();
+}
+
+/* *
+ * @tc.name: ItFsJffs665
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs665, TestSize.Level0)
+{
+ ItFsJffs665();
+}
+
+/* *
+ * @tc.name: ItFsJffs666
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs666, TestSize.Level0)
+{
+ ItFsJffs666();
+}
+
+/* *
+ * @tc.name: ItFsJffs668
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs668, TestSize.Level0)
+{
+ ItFsJffs668();
+}
+
+/* *
+ * @tc.name: ItFsJffs669
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs669, TestSize.Level0)
+{
+ ItFsJffs669();
+}
+
+/* *
+ * @tc.name: ItFsJffs670
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs670, TestSize.Level0)
+{
+ ItFsJffs670();
+}
+
+/* *
+ * @tc.name: ItFsJffs671
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs671, TestSize.Level0)
+{
+ ItFsJffs671();
+}
+
+/* *
+ * @tc.name: ItFsJffs672
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs672, TestSize.Level0)
+{
+ ItFsJffs672();
+}
+
+/* *
+ * @tc.name: ItFsJffs673
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs673, TestSize.Level0)
+{
+ ItFsJffs673();
+}
+
+/* *
+ * @tc.name: ItFsJffs674
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs674, TestSize.Level0)
+{
+ ItFsJffs674();
+}
+
+/* *
+ * @tc.name: ItFsJffs675
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs675, TestSize.Level0)
+{
+ ItFsJffs675();
+}
+
+/* *
+ * @tc.name: ItFsJffs676
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs676, TestSize.Level0)
+{
+ ItFsJffs676();
+}
+
+/* *
+ * @tc.name: ItFsJffs690
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs690, TestSize.Level0)
+{
+ ItFsJffs690();
+}
+
+/* *
+ * @tc.name: ItFsJffs694
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs694, TestSize.Level0)
+{
+ ItFsJffs694();
+}
+
+/* *
+ * @tc.name: ItFsJffs696
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs696, TestSize.Level0)
+{
+ ItFsJffs696();
+}
+
+/* *
+ * @tc.name: ItFsJffs697
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs697, TestSize.Level0)
+{
+ ItFsJffs697();
+}
+
+/* *
+ * @tc.name: ItFsJffs700
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs700, TestSize.Level0)
+{
+ ItFsJffs700();
+}
+
+/* *
+ * @tc.name: ItFsJffs701
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs701, TestSize.Level0)
+{
+ ItFsJffs701();
+}
+
+/* *
+ * @tc.name: ItFsJffs807
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs807, TestSize.Level0)
+{
+ ItFsJffs807(); // jffs dir1 rename dir2,dir2 have more than two files,rename failed
+}
+
+/* *
+ * @tc.name: ItFsJffs808
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs808, TestSize.Level0)
+{
+ ItFsJffs808();
+}
+
+#endif
+#if defined(LOSCFG_USER_TEST_SMOKE)
+/* *
+ * @tc.name: It_Test_Dac_001
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItTestDac001, TestSize.Level0)
+{
+ ItTestDac001();
+}
+
+/* *
+ * @tc.name: ItFsJffs001
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs001, TestSize.Level0)
+{
+ ItFsJffs001();
+}
+
+/* *
+ * @tc.name: ItFsJffs002
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs002, TestSize.Level0)
+{
+ ItFsJffs002();
+}
+
+/* *
+ * @tc.name: ItFsJffs003
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs003, TestSize.Level0)
+{
+ ItFsJffs003();
+}
+
+/* *
+ * @tc.name: ItFsJffs005
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs005, TestSize.Level0)
+{
+ ItFsJffs005();
+}
+
+/* *
+ * @tc.name: ItFsJffs021
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs021, TestSize.Level0)
+{
+ ItFsJffs021();
+}
+
+/* *
+ * @tc.name: ItFsJffs022
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs022, TestSize.Level0)
+{
+ ItFsJffs022();
+}
+
+/* *
+ * @tc.name: ItFsJffs026
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs026, TestSize.Level0)
+{
+ ItFsJffs026();
+}
+
+/* *
+ * @tc.name: ItFsJffs027
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs027, TestSize.Level0)
+{
+ ItFsJffs027();
+}
+
+/* *
+ * @tc.name: ItFsJffs095
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs095, TestSize.Level0)
+{
+ ItFsJffs095();
+}
+
+/* *
+ * @tc.name: ItFsJffs535
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffs535, TestSize.Level0)
+{
+ ItFsJffs535();
+}
+
+#endif
+
+#if defined(LOSCFG_USER_TEST_PRESSURE)
+pthreadMutexattrT mutex;
+PthreadMutexattrSettype(&mutex, PTHREAD_MUTEX_NORMAL);
+PthreadMutexInit(&g_jffs2GlobalLock1, &mutex);
+PthreadMutexInit(&g_jffs2GlobalLock2, &mutex);
+/* *
+ * @tc.name: ItFsJffsPRESSURE_001
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure001, TestSize.Level0)
+{
+ ItFsJffsPressure001();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_002
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure002, TestSize.Level0)
+{
+ ItFsJffsPressure002();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_003
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure003, TestSize.Level0)
+{
+ ItFsJffsPressure003();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_004
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure004, TestSize.Level0)
+{
+ ItFsJffsPressure004();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_005
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure005, TestSize.Level0)
+{
+ ItFsJffsPressure005();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_006
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure006, TestSize.Level0)
+{
+ ItFsJffsPressure006();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_007
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure007, TestSize.Level0)
+{
+ ItFsJffsPressure007();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_008
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure008, TestSize.Level0)
+{
+ ItFsJffsPressure008();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_009
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure009, TestSize.Level0)
+{
+ ItFsJffsPressure009();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_010
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure010, TestSize.Level0)
+{
+ ItFsJffsPressure010();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_011
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure011, TestSize.Level0)
+{
+ ItFsJffsPressure011();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_012
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure012, TestSize.Level0)
+{
+ ItFsJffsPressure012();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_014
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure014, TestSize.Level0)
+{
+ ItFsJffsPressure014();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_015
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure015, TestSize.Level0)
+{
+ ItFsJffsPressure015();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_016
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure016, TestSize.Level0)
+{
+ ItFsJffsPressure016();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_017
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure017, TestSize.Level0)
+{
+ ItFsJffsPressure017();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_018
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure018, TestSize.Level0)
+{
+ ItFsJffsPressure018();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_019
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure019, TestSize.Level0)
+{
+ ItFsJffsPressure019();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_020
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure020, TestSize.Level0)
+{
+ ItFsJffsPressure020();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_021
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure021, TestSize.Level0)
+{
+ ItFsJffsPressure021();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_022
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure022, TestSize.Level0)
+{
+ ItFsJffsPressure022();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_023
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure023, TestSize.Level0)
+{
+ ItFsJffsPressure023();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_025
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure025, TestSize.Level0)
+{
+ ItFsJffsPressure025();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_026
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure026, TestSize.Level0)
+{
+ ItFsJffsPressure026();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_027
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure027, TestSize.Level0)
+{
+ ItFsJffsPressure027();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_028
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure028, TestSize.Level0)
+{
+ ItFsJffsPressure028();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_030
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure030, TestSize.Level0)
+{
+ ItFsJffsPressure030();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_031
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure031, TestSize.Level0)
+{
+ ItFsJffsPressure031();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_032
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure032, TestSize.Level0)
+{
+ ItFsJffsPressure032();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_033
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure033, TestSize.Level0)
+{
+ ItFsJffsPressure033();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_034
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure034, TestSize.Level0)
+{
+ ItFsJffsPressure034();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_035
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure035, TestSize.Level0)
+{
+ ItFsJffsPressure035();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_036
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure036, TestSize.Level0)
+{
+ ItFsJffsPressure036();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_037
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure037, TestSize.Level0)
+{
+ ItFsJffsPressure037();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_038
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure038, TestSize.Level0)
+{
+ ItFsJffsPressure038();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_039
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure039, TestSize.Level0)
+{
+ ItFsJffsPressure039();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_040
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure040, TestSize.Level0)
+{
+ ItFsJffsPressure040();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_041
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure041, TestSize.Level0)
+{
+ ItFsJffsPressure041();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_042
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure042, TestSize.Level0)
+{
+ ItFsJffsPressure042();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_043
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure043, TestSize.Level0)
+{
+ ItFsJffsPressure043();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_044
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure044, TestSize.Level0)
+{
+ ItFsJffsPressure044();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_045
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure045, TestSize.Level0)
+{
+ ItFsJffsPressure045();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_046
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure046, TestSize.Level0)
+{
+ ItFsJffsPressure046();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_047
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure047, TestSize.Level0)
+{
+ ItFsJffsPressure047();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_048
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure048, TestSize.Level0)
+{
+ ItFsJffsPressure048(); // Time-consuming
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_049
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure049, TestSize.Level0)
+{
+ ItFsJffsPressure049(); // Time-consuming
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_051
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure051, TestSize.Level0)
+{
+ ItFsJffsPressure051();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_052
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure052, TestSize.Level0)
+{
+ ItFsJffsPressure052();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_053
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure053, TestSize.Level0)
+{
+ ItFsJffsPressure053();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_301
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure301, TestSize.Level0)
+{
+ ItFsJffsPressure301();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_302
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure302, TestSize.Level0)
+{
+ ItFsJffsPressure302();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_303
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure303, TestSize.Level0)
+{
+ ItFsJffsPressure303();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_304
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure304, TestSize.Level0)
+{
+ ItFsJffsPressure304();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_305
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure305, TestSize.Level0)
+{
+ ItFsJffsPressure305();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_306
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure306, TestSize.Level0)
+{
+ ItFsJffsPressure306();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_307
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure307, TestSize.Level0)
+{
+ ItFsJffsPressure307();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_308
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure308, TestSize.Level0)
+{
+ ItFsJffsPressure308();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_309
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure309, TestSize.Level0)
+{
+ ItFsJffsPressure309();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_310
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure310, TestSize.Level0)
+{
+ ItFsJffsPressure310();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_311
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure311, TestSize.Level0)
+{
+ ItFsJffsPressure311();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_312
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure312, TestSize.Level0)
+{
+ ItFsJffsPressure312();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_313
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure313, TestSize.Level0)
+{
+ ItFsJffsPressure313();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_314
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure314, TestSize.Level0)
+{
+ ItFsJffsPressure314();
+}
+
+/* *
+ * @tc.name: ItFsJffsPRESSURE_315
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPressure315, TestSize.Level0)
+{
+ ItFsJffsPressure315();
+}
+
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_001
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread001, TestSize.Level0)
+{
+ ItFsJffsMultipthread001();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_002
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread002, TestSize.Level0)
+{
+ ItFsJffsMultipthread002();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_003
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread003, TestSize.Level0)
+{
+ ItFsJffsMultipthread003();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_004
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread004, TestSize.Level0)
+{
+ ItFsJffsMultipthread004();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_005
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread005, TestSize.Level0)
+{
+ ItFsJffsMultipthread005();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_006
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread006, TestSize.Level0)
+{
+ ItFsJffsMultipthread006();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_007
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread007, TestSize.Level0)
+{
+ ItFsJffsMultipthread007();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_008
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread008, TestSize.Level0)
+{
+ ItFsJffsMultipthread008();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_009
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread009, TestSize.Level0)
+{
+ ItFsJffsMultipthread009();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_010
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread010, TestSize.Level0)
+{
+ ItFsJffsMultipthread010();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_011
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread011, TestSize.Level0)
+{
+ ItFsJffsMultipthread011();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_012
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread012, TestSize.Level0)
+{
+ ItFsJffsMultipthread012();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_013
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread013, TestSize.Level0)
+{
+ ItFsJffsMultipthread013();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_014
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread014, TestSize.Level0)
+{
+ ItFsJffsMultipthread014();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_015
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread015, TestSize.Level0)
+{
+ ItFsJffsMultipthread015();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_016
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread016, TestSize.Level0)
+{
+ ItFsJffsMultipthread016();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_017
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread017, TestSize.Level0)
+{
+ ItFsJffsMultipthread017();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_018
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread018, TestSize.Level0)
+{
+ ItFsJffsMultipthread018();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_019
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread019, TestSize.Level0)
+{
+ ItFsJffsMultipthread019();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_020
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread020, TestSize.Level0)
+{
+ ItFsJffsMultipthread020();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_021
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread021, TestSize.Level0)
+{
+ ItFsJffsMultipthread021();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_022
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread022, TestSize.Level0)
+{
+ ItFsJffsMultipthread022();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_023
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread023, TestSize.Level0)
+{
+ ItFsJffsMultipthread023();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_024
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread024, TestSize.Level0)
+{
+ ItFsJffsMultipthread024();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_025
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread025, TestSize.Level0)
+{
+ ItFsJffsMultipthread025();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_026
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread026, TestSize.Level0)
+{
+ ItFsJffsMultipthread026();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_027
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread027, TestSize.Level0)
+{
+ ItFsJffsMultipthread027();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_028
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread028, TestSize.Level0)
+{
+ ItFsJffsMultipthread028();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_029
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread029, TestSize.Level0)
+{
+ ItFsJffsMultipthread029();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_030
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread030, TestSize.Level0)
+{
+ ItFsJffsMultipthread030();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_031
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread031, TestSize.Level0)
+{
+ ItFsJffsMultipthread031();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_032
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread032, TestSize.Level0)
+{
+ ItFsJffsMultipthread032();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_033
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread033, TestSize.Level0)
+{
+ ItFsJffsMultipthread033();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_034
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread034, TestSize.Level0)
+{
+ ItFsJffsMultipthread034();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_035
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread035, TestSize.Level0)
+{
+ ItFsJffsMultipthread035();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_036
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread036, TestSize.Level0)
+{
+ ItFsJffsMultipthread036();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_037
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread037, TestSize.Level0)
+{
+ ItFsJffsMultipthread037();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_038
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread038, TestSize.Level0)
+{
+ ItFsJffsMultipthread038();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_039
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread039, TestSize.Level0)
+{
+ ItFsJffsMultipthread039();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_040
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread040, TestSize.Level0)
+{
+ ItFsJffsMultipthread040();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_041
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread041, TestSize.Level0)
+{
+ ItFsJffsMultipthread041();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_042
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread042, TestSize.Level0)
+{
+ ItFsJffsMultipthread042();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_043
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread043, TestSize.Level0)
+{
+ ItFsJffsMultipthread043();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_044
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread044, TestSize.Level0)
+{
+ ItFsJffsMultipthread044();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_045
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread045, TestSize.Level0)
+{
+ ItFsJffsMultipthread045();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_046
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread046, TestSize.Level0)
+{
+ ItFsJffsMultipthread046();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_047
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread047, TestSize.Level0)
+{
+ ItFsJffsMultipthread047();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_048
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread048, TestSize.Level0)
+{
+ ItFsJffsMultipthread048();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_049
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread049, TestSize.Level0)
+{
+ ItFsJffsMultipthread049();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_050
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread050, TestSize.Level0)
+{
+ ItFsJffsMultipthread050();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_051
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread051, TestSize.Level0)
+{
+ ItFsJffsMultipthread051();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_052
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread052, TestSize.Level0)
+{
+ ItFsJffsMultipthread052();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_053
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread053, TestSize.Level0)
+{
+ ItFsJffsMultipthread053();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_054
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread054, TestSize.Level0)
+{
+ ItFsJffsMultipthread054();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_055
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread055, TestSize.Level0)
+{
+ ItFsJffsMultipthread055();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_056
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread056, TestSize.Level0)
+{
+ ItFsJffsMultipthread056();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_057
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread057, TestSize.Level0)
+{
+ ItFsJffsMultipthread057();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_058
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread058, TestSize.Level0)
+{
+ ItFsJffsMultipthread058();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_059
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread059, TestSize.Level0)
+{
+ ItFsJffsMultipthread059();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_060
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread060, TestSize.Level0)
+{
+ ItFsJffsMultipthread060();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_061
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread061, TestSize.Level0)
+{
+ ItFsJffsMultipthread061();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_062
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread062, TestSize.Level0)
+{
+ ItFsJffsMultipthread062();
+}
+
+/* *
+ * @tc.name: ItFsJffsMULTIPTHREAD_063
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsMultipthread063, TestSize.Level0)
+{
+ ItFsJffsMultipthread063();
+}
+
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_013
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance013, TestSize.Level0)
+{
+ ItFsJffsPerformance013();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_001
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance001, TestSize.Level0)
+{
+ ItFsJffsPerformance001();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_002
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance002, TestSize.Level0)
+{
+ ItFsJffsPerformance002();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_003
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance003, TestSize.Level0)
+{
+ ItFsJffsPerformance003();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_004
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance004, TestSize.Level0)
+{
+ ItFsJffsPerformance004();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_005
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance005, TestSize.Level0)
+{
+ ItFsJffsPerformance005();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_006
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance006, TestSize.Level0)
+{
+ ItFsJffsPerformance006();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_007
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance007, TestSize.Level0)
+{
+ ItFsJffsPerformance007();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_008
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance008, TestSize.Level0)
+{
+ ItFsJffsPerformance008();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_009
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance009, TestSize.Level0)
+{
+ ItFsJffsPerformance009();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_010
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance010, TestSize.Level0)
+{
+ ItFsJffsPerformance010();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_011
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance011, TestSize.Level0)
+{
+ ItFsJffsPerformance011();
+}
+
+/* *
+ * @tc.name: ItFsJffsPERFORMANCE_012
+ * @tc.desc: function for VfsJffsTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(VfsJffsTest, ItFsJffsPerformance012, TestSize.Level0)
+{
+ ItFsJffsPerformance012();
+}
+
+#endif
+}
diff --git a/testsuites/unittest/fs/proc/BUILD.gn b/testsuites/unittest/fs/proc/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..af413536dd46ab1af2dc29643883cb935023e27b
--- /dev/null
+++ b/testsuites/unittest/fs/proc/BUILD.gn
@@ -0,0 +1,58 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../../config.gni")
+
+unittest("liteos_a_fs_procfs_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "//kernel/liteos_a/test/unittest/common/include",
+ "//kernel/liteos_a/test/unittest/fs/proc",
+ ]
+ sources = [
+ "//kernel/liteos_a/test/unittest/common/osTest.cpp",
+ "It_vfs_proc.cpp",
+ ]
+ if (LOSCFG_USER_TEST_FULL == true) {
+ sources_full = [
+ "full/It_vfs_proc_001.cpp",
+ "full/It_vfs_proc_002.cpp",
+ "full/It_vfs_proc_003.cpp",
+ "full/It_vfs_proc_004.cpp",
+ "full/It_vfs_proc_005.cpp",
+ "full/It_vfs_proc_006.cpp",
+ ]
+ sources += sources_full
+ }
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+ configs = [ "//kernel/liteos_a/test/unittest:public_config" ]
+ deps += [ "//kernel/liteos_a:kernel" ]
+}
diff --git a/drivers/char/quickstart/include/los_quick_start_pri.h b/testsuites/unittest/fs/proc/It_vfs_proc.cpp
similarity index 81%
rename from drivers/char/quickstart/include/los_quick_start_pri.h
rename to testsuites/unittest/fs/proc/It_vfs_proc.cpp
index 012b548e4db602e8331ebb2b4260e740c7812d53..df08e332567bd4404bba2ab5488d124580be1d72 100644
--- a/drivers/char/quickstart/include/los_quick_start_pri.h
+++ b/testsuites/unittest/fs/proc/It_vfs_proc.cpp
@@ -28,25 +28,27 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "It_vfs_proc.h"
-#ifndef __LOS_QUICK_START_PRI_H__
-#define __LOS_QUICK_START_PRI_H__
+VOID ItSuiteVfsProc(VOID)
+{
+#if defined(LOSCFG_USER_TEST_SMOKE)
+#endif
-#include "los_typedef.h"
+#if defined(LOSCFG_USER_TEST_FULL)
+ ItFsProc001();
+ ItFsProc002();
+ ItFsProc003();
+ ItFsProc004();
+ ItFsProc005();
+ ItFsProc006();
+#endif
-#ifdef __cplusplus
-#if __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-#endif /* __cplusplus */
+#if defined(LOSCFG_USER_TEST_LLT)
+#endif
-unsigned int OsSystemInitStep2(void);
-extern VOID SystemInit2(VOID);
-
-#ifdef __cplusplus
-#if __cplusplus
+#if defined(LOSCFG_USER_TEST_PRESSURE)
+#if(LOSCFG_KERNEL_SMP != YES)
+#endif
+#endif
}
-#endif /* __cplusplus */
-#endif /* __cplusplus */
-
-#endif /* __LOS_QUICK_START_PRI_H__ */
\ No newline at end of file
diff --git a/testsuites/unittest/fs/proc/It_vfs_proc.h b/testsuites/unittest/fs/proc/It_vfs_proc.h
new file mode 100644
index 0000000000000000000000000000000000000000..0b58bdfdd54bfcafe9f99bc54459cf92b5c9b04c
--- /dev/null
+++ b/testsuites/unittest/fs/proc/It_vfs_proc.h
@@ -0,0 +1,80 @@
+/*
+ * 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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define PROC_PATH_NAME "/proc/test"
+#define PROC_MAIN_DIR "/proc"
+#define PROC_MOUNT_DIR "/proc"
+#define MOUNT_DIR_PATH "/proc/mounts"
+#define UPTIME_DIR_PATH "/proc/uptime"
+#define VMM_DIR_PATH "/proc/vmm"
+#define PROCESS_DIR_PATH "/proc/process"
+#define PROC_DEV_PATH NULL
+#define PROC_CHINESE_NAME1 "è¿™æ˜¯ä¸€ä¸ªä¸æ–‡å"
+#define PROC_FILESYS_TYPE "procfs"
+
+#define PROC_NAME_LIMITTED_SIZE 300
+#define PROC_NO_ERROR 0
+#define PROC_IS_ERROR -1
+
+#if defined(LOSCFG_USER_TEST_SMOKE)
+#endif
+
+#if defined(LOSCFG_USER_TEST_FULL)
+VOID ItFsProc001(VOID);
+VOID ItFsProc002(VOID);
+VOID ItFsProc003(VOID);
+VOID ItFsProc004(VOID);
+VOID ItFsProc005(VOID);
+VOID ItFsProc006(VOID);
+#endif
+
+#if defined(LOSCFG_USER_TEST_LLT)
+#endif
+
+#if defined(LOSCFG_USER_TEST_PRESSURE)
+#endif
+
+
diff --git a/testsuites/unittest/fs/proc/Makefile b/testsuites/unittest/fs/proc/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..17b845f1615b7b49a6f05344e393a02494411b8a
--- /dev/null
+++ b/testsuites/unittest/fs/proc/Makefile
@@ -0,0 +1,36 @@
+
+include $(LITEOSTOPDIR)/config.mk
+
+MODULE_NAME := $(notdir $(shell pwd))test
+
+LOCAL_INCLUDE := \
+ -I $(LITEOSTOPDIR)/test/kernel/include \
+ -I $(LITEOSTOPDIR)/fs/proc/include \
+ -I $(LITEOSTOPDIR)/fs/include \
+ -I $(LITEOSTOPDIR)/test/kernel/sample/fs/proc
+
+SRC_MODULES := .
+
+ifeq ($(LOSCFG_USER_TEST_LLT), y)
+LLT_MODULES := llt
+endif
+
+ifeq ($(LOSCFG_USER_TEST_PRESSURE), y)
+PRESSURE_MODULES := pressure
+endif
+
+ifeq ($(LOSCFG_USER_TEST_SMOKE), y)
+SMOKE_MODULES := smoke
+endif
+
+ifeq ($(LOSCFG_USER_TEST_FULL), y)
+FULL_MODULES := full
+endif
+
+LOCAL_MODULES := $(SRC_MODULES) $(LLT_MODULES) $(PRESSURE_MODULES) $(SMOKE_MODULES) $(FULL_MODULES)
+LOCAL_SRCS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.c))
+LOCAL_CHS := $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.h))
+
+LOCAL_FLAGS := $(LOCAL_INCLUDE) -Wno-error
+
+include $(MODULE)
diff --git a/testsuites/unittest/fs/proc/full/It_vfs_proc_001.cpp b/testsuites/unittest/fs/proc/full/It_vfs_proc_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6139ab41cafd6408f5db79c8d053e0da83bf0bf2
--- /dev/null
+++ b/testsuites/unittest/fs/proc/full/It_vfs_proc_001.cpp
@@ -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 "It_vfs_proc.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR readbuf[PROC_NAME_LIMITTED_SIZE] = "";
+
+ fd = open(MOUNT_DIR_PATH, O_RDONLY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = memset_s(readbuf, PROC_NAME_LIMITTED_SIZE, 0, PROC_NAME_LIMITTED_SIZE);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, ret, EXIT1);
+
+ len = read(fd, readbuf, PROC_NAME_LIMITTED_SIZE - 1);
+ ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, fd, EXIT1);
+
+ fd = open(VMM_DIR_PATH, O_RDONLY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = memset_s(readbuf, PROC_NAME_LIMITTED_SIZE, 0, PROC_NAME_LIMITTED_SIZE);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, ret, EXIT1);
+ len = read(fd, readbuf, PROC_NAME_LIMITTED_SIZE - 1);
+ ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, fd, EXIT1);
+
+ fd = open(PROCESS_DIR_PATH, O_RDONLY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = memset_s(readbuf, PROC_NAME_LIMITTED_SIZE, 0, PROC_NAME_LIMITTED_SIZE);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, ret, EXIT1);
+ len = read(fd, readbuf, PROC_NAME_LIMITTED_SIZE - 1);
+ ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, fd, EXIT1);
+
+ return PROC_NO_ERROR;
+
+EXIT1:
+ close(fd);
+
+ return PROC_NO_ERROR;
+}
+
+VOID ItFsProc001(VOID)
+{
+ TEST_ADD_CASE("ItFsProc001", TestCase, TEST_VFS, TEST_PROC, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/proc/full/It_vfs_proc_002.cpp b/testsuites/unittest/fs/proc/full/It_vfs_proc_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c186e7925c295424666ceaf37d1a4ce9ab641035
--- /dev/null
+++ b/testsuites/unittest/fs/proc/full/It_vfs_proc_002.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_proc.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+ CHAR readbuf[PROC_NAME_LIMITTED_SIZE] = "";
+
+ fd = open(UPTIME_DIR_PATH, O_RDONLY);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ ret = memset_s(readbuf, PROC_NAME_LIMITTED_SIZE, 0, PROC_NAME_LIMITTED_SIZE);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, ret, EXIT1);
+ len = read(fd, readbuf, PROC_NAME_LIMITTED_SIZE - 1);
+ ICUNIT_GOTO_NOT_EQUAL(len, -1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, fd, EXIT1);
+
+ return PROC_NO_ERROR;
+
+EXIT1:
+ close(fd);
+
+ return PROC_NO_ERROR;
+}
+
+VOID ItFsProc002(VOID)
+{
+ TEST_ADD_CASE("ItFsProc002", TestCase, TEST_VFS, TEST_PROC, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/proc/full/It_vfs_proc_003.cpp b/testsuites/unittest/fs/proc/full/It_vfs_proc_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9852a0c2ff38f07574c059ee5414b880bd9bb1ed
--- /dev/null
+++ b/testsuites/unittest/fs/proc/full/It_vfs_proc_003.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_proc.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+
+ fd = open(MOUNT_DIR_PATH, O_RDWR);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, "test", strlen("test"));
+ ICUNIT_GOTO_EQUAL(len, -EPERM, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, fd, EXIT1);
+
+ return PROC_NO_ERROR;
+
+EXIT1:
+ close(fd);
+
+ return PROC_NO_ERROR;
+}
+
+VOID ItFsProc003(VOID)
+{
+ TEST_ADD_CASE("ItFsProc003", TestCase, TEST_VFS, TEST_PROC, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/proc/full/It_vfs_proc_004.cpp b/testsuites/unittest/fs/proc/full/It_vfs_proc_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c7733a3204ce4ab9fe00915ee2f643b14ea4734f
--- /dev/null
+++ b/testsuites/unittest/fs/proc/full/It_vfs_proc_004.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_proc.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+
+ fd = open(UPTIME_DIR_PATH, O_RDWR);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, "test", strlen("test"));
+ ICUNIT_GOTO_EQUAL(len, -EPERM, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, fd, EXIT1);
+
+ return PROC_NO_ERROR;
+
+EXIT1:
+ close(fd);
+
+ return PROC_NO_ERROR;
+}
+
+VOID ItFsProc004(VOID)
+{
+ TEST_ADD_CASE("ItFsProc004", TestCase, TEST_VFS, TEST_PROC, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/proc/full/It_vfs_proc_005.cpp b/testsuites/unittest/fs/proc/full/It_vfs_proc_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8a71e13829a316a466b0fd667f95a421b5e92b26
--- /dev/null
+++ b/testsuites/unittest/fs/proc/full/It_vfs_proc_005.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_proc.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+
+ fd = open(UPTIME_DIR_PATH, O_RDWR);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, "test", strlen("test"));
+ ICUNIT_GOTO_EQUAL(len, -EPERM, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, fd, EXIT1);
+
+ return PROC_NO_ERROR;
+
+EXIT1:
+ close(fd);
+
+ return PROC_NO_ERROR;
+}
+
+VOID ItFsProc005(VOID)
+{
+ TEST_ADD_CASE("ItFsProc005", TestCase, TEST_VFS, TEST_PROC, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/proc/full/It_vfs_proc_006.cpp b/testsuites/unittest/fs/proc/full/It_vfs_proc_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7c43a90359cd6fac6466722d5342cbf96ca17345
--- /dev/null
+++ b/testsuites/unittest/fs/proc/full/It_vfs_proc_006.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_proc.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd, ret, len;
+
+ fd = open(PROCESS_DIR_PATH, O_RDWR);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT1);
+
+ len = write(fd, "test", strlen("test"));
+ ICUNIT_GOTO_EQUAL(len, -EPERM, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, PROC_NO_ERROR, fd, EXIT1);
+
+ return PROC_NO_ERROR;
+
+EXIT1:
+ close(fd);
+
+ return PROC_NO_ERROR;
+}
+
+VOID ItFsProc006(VOID)
+{
+ TEST_ADD_CASE("ItFsProc006", TestCase, TEST_VFS, TEST_PROC, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/proc/proc.mk b/testsuites/unittest/fs/proc/proc.mk
new file mode 100644
index 0000000000000000000000000000000000000000..9e43eaf45ff1baefec7fde7795c57466641acf50
--- /dev/null
+++ b/testsuites/unittest/fs/proc/proc.mk
@@ -0,0 +1,25 @@
+
+SRC_MODULES := fs/proc
+
+ifeq ($(LOSCFG_USER_TEST_LLT), y)
+LLT_MODULES := fs/proc/llt
+endif
+
+ifeq ($(LOSCFG_USER_TEST_SMOKE), y)
+SMOKE_MODULES := fs/proc/smoke
+endif
+
+ifeq ($(LOSCFG_USER_TEST_FULL), y)
+FULL_MODULES := fs/proc/full
+endif
+
+ifeq ($(LOSCFG_USER_TEST_PRESSURE), y)
+PRESSURE_MODULES := fs/proc/pressure
+endif
+
+LOCAL_MODULES := $(SRC_MODULES) $(LLT_MODULES) $(PRESSURE_MODULES) $(SMOKE_MODULES) $(FULL_MODULES)
+
+LOCAL_SRCS += $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.c))
+LOCAL_CHS += $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.h))
+
+LOCAL_FLAGS += -I./fs/proc
diff --git a/testsuites/unittest/fs/vfat2/BUILD.gn b/testsuites/unittest/fs/vfat2/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..88d9be2143bcf4761ba627e853c6bbe2b39852a1
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/BUILD.gn
@@ -0,0 +1,194 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../../config.gni")
+
+unittest("liteos_a_fs_vfat_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "//kernel/liteos_a/testsuites/unittest/common/include",
+ "//kernel/liteos_a/testsuites/unittest/fs/vfs",
+ "//kernel/liteos_a/testsuites/unittest/fs/vfat2",
+ ]
+ sources = [
+ "//kernel/liteos_a/testsuites/unittest/common/osTest.cpp",
+ "VfsFatTest.cpp",
+ ]
+ if (LOSCFG_USER_TEST_PRESSURE == true) {
+ sources_pressure = [
+ "pressure/It_fs_fat_performance_001.cpp",
+ "pressure/It_fs_fat_performance_002.cpp",
+ "pressure/It_fs_fat_performance_003.cpp",
+ "pressure/It_fs_fat_performance_004.cpp",
+ "pressure/It_fs_fat_performance_005.cpp",
+ "pressure/It_fs_fat_performance_006.cpp",
+ "pressure/It_fs_fat_performance_007.cpp",
+ "pressure/It_fs_fat_performance_008.cpp",
+ "pressure/It_fs_fat_performance_013.cpp",
+ "pressure/It_fs_fat_performance_014.cpp",
+ "pressure/It_fs_fat_performance_015.cpp",
+ "pressure/It_fs_fat_performance_016.cpp",
+
+ "pressure/It_fs_fat_pressure_029.cpp",
+ "pressure/It_fs_fat_pressure_030.cpp",
+ "pressure/It_fs_fat_pressure_031.cpp",
+ "pressure/It_fs_fat_pressure_038.cpp",
+ "pressure/It_fs_fat_pressure_040.cpp",
+ "pressure/It_fs_fat_pressure_041.cpp",
+ "pressure/It_fs_fat_pressure_042.cpp",
+ "pressure/It_fs_fat_pressure_301.cpp",
+ "pressure/It_fs_fat_pressure_302.cpp",
+ "pressure/It_fs_fat_pressure_303.cpp",
+ "pressure/It_fs_fat_pressure_305.cpp",
+ "pressure/It_fs_fat_pressure_306.cpp",
+ "pressure/It_fs_fat_pressure_309.cpp",
+
+ "pressure/It_vfs_fat_mutipthread_003.cpp",
+ "pressure/It_vfs_fat_mutipthread_004.cpp",
+ "pressure/It_vfs_fat_mutipthread_005.cpp",
+ "pressure/It_vfs_fat_mutipthread_006.cpp",
+ "pressure/It_vfs_fat_mutipthread_008.cpp",
+ "pressure/It_vfs_fat_mutipthread_009.cpp",
+ "pressure/It_vfs_fat_mutipthread_010.cpp",
+ "pressure/It_vfs_fat_mutipthread_012.cpp",
+ "pressure/It_vfs_fat_mutipthread_014.cpp",
+ "pressure/It_vfs_fat_mutipthread_016.cpp",
+ "pressure/It_vfs_fat_mutipthread_017.cpp",
+ "pressure/It_vfs_fat_mutipthread_018.cpp",
+ "pressure/It_vfs_fat_mutipthread_019.cpp",
+ "pressure/It_vfs_fat_mutipthread_020.cpp",
+ "pressure/It_vfs_fat_mutipthread_021.cpp",
+ "pressure/It_vfs_fat_mutipthread_022.cpp",
+ "pressure/It_vfs_fat_mutipthread_023.cpp",
+ "pressure/It_vfs_fat_mutipthread_024.cpp",
+ "pressure/It_vfs_fat_mutipthread_027.cpp",
+ "pressure/It_vfs_fat_mutipthread_029.cpp",
+ "pressure/It_vfs_fat_mutipthread_030.cpp",
+ "pressure/It_vfs_fat_mutipthread_032.cpp",
+ "pressure/It_vfs_fat_mutipthread_033.cpp",
+ "pressure/It_vfs_fat_mutipthread_035.cpp",
+ "pressure/It_vfs_fat_mutipthread_036.cpp",
+ "pressure/It_vfs_fat_mutipthread_038.cpp",
+ "pressure/It_vfs_fat_mutipthread_039.cpp",
+ "pressure/It_vfs_fat_mutipthread_040.cpp",
+ "pressure/It_vfs_fat_mutipthread_041.cpp",
+ "pressure/It_vfs_fat_mutipthread_042.cpp",
+ "pressure/It_vfs_fat_mutipthread_043.cpp",
+ "pressure/It_vfs_fat_mutipthread_044.cpp",
+ "pressure/It_vfs_fat_mutipthread_045.cpp",
+ "pressure/It_vfs_fat_mutipthread_046.cpp",
+ "pressure/It_vfs_fat_mutipthread_047.cpp",
+ "pressure/It_vfs_fat_mutipthread_048.cpp",
+ "pressure/It_vfs_fat_mutipthread_049.cpp",
+ "pressure/It_vfs_fat_mutipthread_050.cpp",
+ ]
+ sources += sources_pressure
+ }
+ if (LOSCFG_USER_TEST_SMOKE == true) {
+ sources_smoke = [
+ "smoke/It_vfs_fat_026.cpp",
+ ]
+ sources += sources_smoke
+ }
+ if (LOSCFG_USER_TEST_FULL == true) {
+ sources_full = [
+ "full/It_vfs_fat_066.cpp",
+ "full/It_vfs_fat_068.cpp",
+ "full/It_vfs_fat_072.cpp",
+ "full/It_vfs_fat_073.cpp",
+ "full/It_vfs_fat_074.cpp",
+ "full/It_vfs_fat_496.cpp",
+ "full/It_vfs_fat_497.cpp",
+ "full/It_vfs_fat_498.cpp",
+ "full/It_vfs_fat_499.cpp",
+ "full/It_vfs_fat_500.cpp",
+ "full/It_vfs_fat_501.cpp",
+ "full/It_vfs_fat_502.cpp",
+ "full/It_vfs_fat_503.cpp",
+ "full/It_vfs_fat_504.cpp",
+ "full/It_vfs_fat_506.cpp",
+ "full/It_vfs_fat_507.cpp",
+ "full/It_vfs_fat_508.cpp",
+ "full/It_vfs_fat_509.cpp",
+ "full/It_vfs_fat_510.cpp",
+ "full/It_vfs_fat_511.cpp",
+ "full/It_vfs_fat_512.cpp",
+ "full/It_vfs_fat_513.cpp",
+ "full/It_vfs_fat_514.cpp",
+ "full/It_vfs_fat_515.cpp",
+ "full/It_vfs_fat_516.cpp",
+ "full/It_vfs_fat_517.cpp",
+ "full/It_vfs_fat_518.cpp",
+ "full/It_vfs_fat_519.cpp",
+ "full/It_vfs_fat_662.cpp",
+ "full/It_vfs_fat_663.cpp",
+ "full/It_vfs_fat_664.cpp",
+ "full/It_vfs_fat_665.cpp",
+ "full/It_vfs_fat_666.cpp",
+ "full/It_vfs_fat_667.cpp",
+ "full/It_vfs_fat_668.cpp",
+ "full/It_vfs_fat_669.cpp",
+ "full/It_vfs_fat_670.cpp",
+ "full/It_vfs_fat_671.cpp",
+ "full/It_vfs_fat_672.cpp",
+ "full/It_vfs_fat_673.cpp",
+ "full/It_vfs_fat_674.cpp",
+ "full/It_vfs_fat_675.cpp",
+ "full/It_vfs_fat_676.cpp",
+ "full/It_vfs_fat_677.cpp",
+ "full/It_vfs_fat_678.cpp",
+ "full/It_vfs_fat_679.cpp",
+ "full/It_vfs_fat_680.cpp",
+ "full/It_vfs_fat_681.cpp",
+ "full/It_vfs_fat_682.cpp",
+ "full/It_vfs_fat_683.cpp",
+ "full/It_vfs_fat_684.cpp",
+ "full/It_vfs_fat_685.cpp",
+ "full/It_vfs_fat_686.cpp",
+ "full/It_vfs_fat_687.cpp",
+ "full/It_vfs_fat_692.cpp",
+ "full/It_vfs_fat_693.cpp",
+ "full/It_vfs_fat_694.cpp",
+ "full/It_vfs_fat_870.cpp",
+ "full/It_vfs_fat_872.cpp",
+ "full/It_vfs_fat_873.cpp",
+ "full/It_vfs_fat_874.cpp",
+ "full/It_vfs_fat_875.cpp",
+ "full/It_vfs_fat_902.cpp",
+ "full/It_vfs_fat_903.cpp",
+ "full/It_vfs_fat_904.cpp",
+ "full/It_vfs_fat_909.cpp",
+ ]
+ sources += sources_full
+ }
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+ configs = [ "//kernel/liteos_a/testsuites/unittest:public_config" ]
+}
diff --git a/testsuites/unittest/fs/vfat2/It_vfs_fat.h b/testsuites/unittest/fs/vfat2/It_vfs_fat.h
new file mode 100644
index 0000000000000000000000000000000000000000..a2e0c125ba140623692b68d283f3ee231bd2840b
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/It_vfs_fat.h
@@ -0,0 +1,338 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IT_VFS_FAT_H
+#define IT_VFS_FAT_H
+
+#include "osTest.h"
+#include "syslog.h"
+#include "sys/uio.h"
+#include "utime.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifndef _GNU_SOURCE
+struct timeval {
+ time_t tv_sec;
+ suseconds_t tv_usec;
+};
+#endif
+#define F_RDO 0x01 /* Read only */
+#define F_HID 0x02 /* Hidden */
+#define F_SYS 0x04 /* System */
+#define F_ARC 0x20 /* Archive */
+#define NAME_MAX 255
+
+extern int Chattr(const char *path, mode_t mode); //
+using off_t = off64_t;
+
+#define SD_MOUNT_DIR "/vs/sd"
+#define FAT_MOUNT_DIR SD_MOUNT_DIR
+#define FAT_MAIN_DIR SD_MOUNT_DIR
+#define FAT_PATH_NAME "/vs/sd/test"
+#define FAT_PATH_NAME0 "/vs/sd/test0"
+#define FAT_PATH_NAME1 "/vs/sd/test1"
+#define FAT_PATH_NAME2 "/vs/sd/test2"
+#define FAT_PATH_NAME00 "/vs/sd/test0/test00"
+#define FAT_PATH_NAME11 "/vs/sd/test1/test11"
+#define FAT_PATH_NAME22 "/vs/sd/test2/test22"
+#define FAT_PATH_NAME_0 "/vs/sd/test/test0"
+#define FAT_PATH_NAME_01 "/vs/sd/test/test0/test1"
+#define FAT_DEV_PATH "/dev/mmcblk0"
+#define FAT_DEV_PATH1 "/dev/mmcblk0p0"
+#define FAT_FILESYS_TYPE "vfat"
+#define FAT_CHINESE_NAME1 "úÃ"
+
+#define FAT_FALLOCATE_KEEP_SIZE 0x1 // FALLOC_FL_KEEP_SIZE
+#define FAT_FALLOCATE_NO_KEEP_SIZE 0
+
+#define FAT_NAME_LIMITTED_SIZE 300
+#define FAT_FILE_LIMITTED_NUM 200
+#define FAT_STANDARD_NAME_LENGTH 50
+#define FAT_SHORT_ARRAY_LENGTH 10
+#define FAT_LONG_ARRAY_LENGTH 100
+#define MAX_DEF_BUF_NUM 21
+#define FIX_DATA_LEN 524288
+#define MAX_BUFFER_LEN FIX_DATA_LEN // 9000000 //the mem is not enough
+#define CAL_THRESHOLD_VALUE 0x1900000
+#define FAT_WR_CAP_SIZE_TEST 0x1900000 // the size is 25MB for each speed calculation
+#define MAX_THREAD_NUM 10
+#define FAT_PTHREAD_PRIORITY_TEST1 4
+#define CONFIG_NFILE_DESCRIPTORS 512
+
+#define PRINTF_OUT dprintf
+#define PRINTF_HELP() \
+ do { \
+ PRINTF_OUT(" usage: testfile [rand/fix/quit] [file size] [file num] [write/fwrite]\n"); \
+ } while (0);
+
+#define FILE_SIZE (500 * BYTES_PER_MBYTES)
+#define FAT_PERFORMANCE_FILE_SIZE (500 * BYTES_PER_MBYTES)
+#define INTERFACE_TYPE 0 // 0:use fwrite and fread for test
+#define FAT_WR_TYPE_TEST1 0 // 0:use fwrite and fread for test
+#define FAT_WR_TYPE_TEST2 1 // 0:use fwrite and fread for test
+#define FAT_FILE_FIX_WRITE_SIZE 5 * BYTES_PER_MBYTES
+
+/* These are same as the value in the fs/vfat/include/ff.h */
+#define FAT_FILE_SYSTEMTYPE_FAT 0x01 // FM_FAT
+#define FAT_FILE_SYSTEMTYPE_FAT32 0x02 // FM_FAT32
+#define FAT_FILE_SYSTEMTYPE_EXFAT 0x04 // FM_EXFAT
+#define FAT_FILE_SYSTEMTYPE_ANY 0x07 // FM_ANY
+#define FAT_FILE_SYSTEMTYPE_SFD 0x08 // FM_SFD
+
+/* For the different test scenes:FAT32 and EXFAT */
+#define FAT_FILE_SYSTEMTYPE_AUTO g_fatFilesystem
+
+#define FAT_MAX_NUM_TEST 1000
+#define FAT_MOUNT_CYCLES_TEST 10000
+#define FAT_PRESSURE_CYCLES 10
+#define FAT_MAXIMUM_OPERATIONS 10
+#define FAT_MAXIMUM_SIZES 10
+#define FAT_FILEMUM_NUM 100
+#define FAT_MAX_THREADS 3
+#define FAT_NO_ERROR 0
+#define FAT_IS_ERROR -1
+#define FAT_TO_NULL NULL
+#define FAT_LONG_FILESIZE 5
+#define FAT_CREATFILE_NUM 5
+#define FAT_MIDDLE_CYCLES 10
+#define FAT_MAX_CYCLES 100
+
+#define BYTES_PER_KBYTES 1024
+#define BYTES_PER_MBYTES (1024 * 1024)
+#define US_PER_SEC 1000000
+
+#endif
+
+extern INT32 g_fatFilesMax;
+extern INT32 g_fatFlag;
+extern INT32 g_fatFlagF01;
+extern INT32 g_fatFlagF02;
+extern INT32 g_fatFd;
+extern FILE *g_fatFfd;
+
+extern DIR *g_fatDir;
+
+extern INT32 g_fatFd11[FAT_MAXIMUM_SIZES];
+extern INT32 g_fatFd12[FAT_MAXIMUM_SIZES][FAT_MAXIMUM_SIZES];
+
+extern CHAR g_fatPathname1[FAT_STANDARD_NAME_LENGTH];
+extern CHAR g_fatPathname2[FAT_STANDARD_NAME_LENGTH];
+extern CHAR g_fatPathname3[FAT_STANDARD_NAME_LENGTH];
+
+extern CHAR g_fatPathname6[FAT_NAME_LIMITTED_SIZE];
+extern CHAR g_fatPathname7[FAT_NAME_LIMITTED_SIZE];
+extern CHAR g_fatPathname8[FAT_NAME_LIMITTED_SIZE];
+
+extern CHAR g_fatPathname11[FAT_MAXIMUM_SIZES][FAT_NAME_LIMITTED_SIZE];
+extern CHAR g_fatPathname12[FAT_MAXIMUM_SIZES][FAT_NAME_LIMITTED_SIZE];
+extern CHAR g_fatPathname13[FAT_MAXIMUM_SIZES][FAT_NAME_LIMITTED_SIZE];
+
+extern UINT32 g_fatMuxHandle1;
+extern UINT32 g_fatMuxHandle2;
+
+extern pthread_mutex_t g_vfatGlobalLock1;
+extern pthread_mutex_t g_vfatGlobalLock2;
+
+VOID FatStrcat2(char *pathname, char *str, int len);
+INT32 FatScandirFree(struct dirent **namelist, int n);
+VOID FatStatPrintf(struct stat sb);
+VOID FatStatfsPrintf(struct statfs buf);
+
+INT32 FixWrite(CHAR *path, INT64 file_size, INT32 write_size, INT32 interface_type);
+INT32 FixRead(CHAR *path, INT64 file_size, INT32 read_size, INT32 interface_type);
+INT32 RandWrite(CHAR *path, INT64 file_size, INT32 interface_type);
+INT32 RandRead(CHAR *path, INT64 file_size, INT32 interface_type);
+
+extern INT32 g_grandSize[MAX_DEF_BUF_NUM];
+extern struct iovec g_fatIov[FAT_SHORT_ARRAY_LENGTH];
+
+extern UINT32 g_testTaskId01;
+extern UINT32 g_testTaskId02;
+extern UINT32 g_fatFilesystem;
+
+extern const INT32 CAL_THRESHOLD;
+extern INT32 FatDeleteFile(int fd, char *pathname);
+
+#if defined(LOSCFG_USER_TEST_SMOKE)
+VOID ItFsFat026(VOID);
+#endif
+
+#if defined(LOSCFG_USER_TEST_FULL)
+VOID ItFsFat066(VOID);
+VOID ItFsFat068(VOID);
+VOID ItFsFat072(VOID);
+VOID ItFsFat073(VOID);
+VOID ItFsFat074(VOID);
+VOID ItFsFat496(VOID);
+VOID ItFsFat497(VOID);
+VOID ItFsFat498(VOID);
+VOID ItFsFat499(VOID);
+VOID ItFsFat500(VOID);
+VOID ItFsFat501(VOID);
+VOID ItFsFat502(VOID);
+VOID ItFsFat503(VOID);
+VOID ItFsFat504(VOID);
+VOID ItFsFat506(VOID);
+VOID ItFsFat507(VOID);
+VOID ItFsFat508(VOID);
+VOID ItFsFat509(VOID);
+VOID ItFsFat510(VOID);
+VOID ItFsFat511(VOID);
+VOID ItFsFat512(VOID);
+VOID ItFsFat513(VOID);
+VOID ItFsFat514(VOID);
+VOID ItFsFat515(VOID);
+VOID ItFsFat516(VOID);
+VOID ItFsFat517(VOID);
+VOID ItFsFat518(VOID);
+VOID ItFsFat519(VOID);
+VOID ItFsFat662(VOID);
+VOID ItFsFat663(VOID);
+VOID ItFsFat664(VOID);
+VOID ItFsFat665(VOID);
+VOID ItFsFat666(VOID);
+VOID ItFsFat667(VOID);
+VOID ItFsFat668(VOID);
+VOID ItFsFat669(VOID);
+VOID ItFsFat670(VOID);
+VOID ItFsFat671(VOID);
+VOID ItFsFat672(VOID);
+VOID ItFsFat673(VOID);
+VOID ItFsFat674(VOID);
+VOID ItFsFat675(VOID);
+VOID ItFsFat676(VOID);
+VOID ItFsFat677(VOID);
+VOID ItFsFat678(VOID);
+VOID ItFsFat679(VOID);
+VOID ItFsFat680(VOID);
+VOID ItFsFat681(VOID);
+VOID ItFsFat682(VOID);
+VOID ItFsFat683(VOID);
+VOID ItFsFat684(VOID);
+VOID ItFsFat685(VOID);
+VOID ItFsFat686(VOID);
+VOID ItFsFat687(VOID);
+VOID ItFsFat692(VOID);
+VOID ItFsFat693(VOID);
+VOID ItFsFat694(VOID);
+VOID ItFsFat870(VOID);
+VOID ItFsFat872(VOID);
+VOID ItFsFat873(VOID);
+VOID ItFsFat874(VOID);
+VOID ItFsFat875(VOID);
+VOID ItFsFat902(VOID);
+VOID ItFsFat903(VOID);
+VOID ItFsFat904(VOID);
+VOID ItFsFat909(VOID);
+
+#if defined(LOSCFG_USER_TEST_PRESSURE)
+VOID ItFsFatMutipthread003(VOID);
+VOID ItFsFatMutipthread004(VOID);
+VOID ItFsFatMutipthread005(VOID);
+VOID ItFsFatMutipthread006(VOID);
+VOID ItFsFatMutipthread008(VOID);
+VOID ItFsFatMutipthread009(VOID);
+VOID ItFsFatMutipthread010(VOID);
+VOID ItFsFatMutipthread012(VOID);
+VOID ItFsFatMutipthread014(VOID);
+VOID ItFsFatMutipthread016(VOID);
+VOID ItFsFatMutipthread017(VOID);
+VOID ItFsFatMutipthread018(VOID);
+VOID ItFsFatMutipthread019(VOID);
+VOID ItFsFatMutipthread020(VOID);
+VOID ItFsFatMutipthread021(VOID);
+VOID ItFsFatMutipthread022(VOID);
+VOID ItFsFatMutipthread023(VOID);
+VOID ItFsFatMutipthread024(VOID);
+VOID ItFsFatMutipthread027(VOID);
+VOID ItFsFatMutipthread029(VOID);
+VOID ItFsFatMutipthread030(VOID);
+VOID ItFsFatMutipthread032(VOID);
+VOID ItFsFatMutipthread033(VOID);
+VOID ItFsFatMutipthread035(VOID);
+VOID ItFsFatMutipthread036(VOID);
+VOID ItFsFatMutipthread038(VOID);
+VOID ItFsFatMutipthread039(VOID);
+VOID ItFsFatMutipthread040(VOID);
+VOID ItFsFatMutipthread041(VOID);
+VOID ItFsFatMutipthread042(VOID);
+VOID ItFsFatMutipthread043(VOID);
+VOID ItFsFatMutipthread044(VOID);
+VOID ItFsFatMutipthread045(VOID);
+VOID ItFsFatMutipthread046(VOID);
+VOID ItFsFatMutipthread047(VOID);
+VOID ItFsFatMutipthread048(VOID);
+VOID ItFsFatMutipthread049(VOID);
+VOID ItFsFatMutipthread050(VOID);
+
+VOID ItFsFatPressure029(VOID);
+VOID ItFsFatPressure030(VOID);
+VOID ItFsFatPressure031(VOID);
+VOID ItFsFatPressure038(VOID);
+VOID ItFsFatPressure040(VOID);
+VOID ItFsFatPressure041(VOID);
+VOID ItFsFatPressure042(VOID);
+
+VOID ItFsFatPressure301(VOID);
+VOID ItFsFatPressure302(VOID);
+VOID ItFsFatPressure303(VOID);
+VOID ItFsFatPressure305(VOID);
+VOID ItFsFatPressure306(VOID);
+VOID ItFsFatPressure309(VOID);
+
+VOID ItFsFatPerformance013(VOID);
+VOID ItFsFatPerformance014(VOID);
+VOID ItFsFatPerformance015(VOID);
+VOID ItFsFatPerformance016(VOID);
+VOID ItFsFatPerformance001(VOID);
+VOID ItFsFatPerformance002(VOID);
+VOID ItFsFatPerformance003(VOID);
+VOID ItFsFatPerformance004(VOID);
+VOID ItFsFatPerformance005(VOID);
+VOID ItFsFatPerformance006(VOID);
+VOID ItFsFatPerformance007(VOID);
+VOID ItFsFatPerformance008(VOID);
+
+#endif
+
+#endif
\ No newline at end of file
diff --git a/testsuites/unittest/fs/vfat2/VfsFatTest.cpp b/testsuites/unittest/fs/vfat2/VfsFatTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ba226ec423d965c13f75d863082bac18fa66d1ec
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/VfsFatTest.cpp
@@ -0,0 +1,1470 @@
+/*
+ * 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 "stdio.h"
+#include
+#include
+
+#include "It_vfs_fat.h"
+
+#define MS_PER_SEC 1000
+
+struct iovec g_fatIov[FAT_SHORT_ARRAY_LENGTH];
+
+const INT32 CAL_THRESHOLD = CAL_THRESHOLD_VALUE;
+INT32 g_grandSize[MAX_DEF_BUF_NUM] = {
+ 29, 30290, 3435, 235, 12345, 80, 9845,
+ 564, 34862, 123, 267890, 36, 6788, 86,
+ 234567, 1232, 514, 50, 678, 9864, 333333
+};
+
+INT32 g_fatFilesMax = 10;
+INT32 g_fatFlag = 0;
+INT32 g_fatFlagF01 = 0;
+INT32 g_fatFlagF02 = 0;
+INT32 g_fatFd = 0;
+DIR *g_fatDir = nullptr;
+UINT32 g_fatMuxHandle1 = 0;
+UINT32 g_fatMuxHandle2 = 0;
+pthread_mutex_t g_vfatGlobalLock1;
+pthread_mutex_t g_vfatGlobalLock2;
+
+INT32 g_fatFd11[FAT_MAXIMUM_SIZES];
+INT32 g_fatFd12[FAT_MAXIMUM_SIZES][FAT_MAXIMUM_SIZES];
+
+CHAR g_fatPathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+CHAR g_fatPathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+CHAR g_fatPathname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+CHAR g_fatPathname6[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME;
+CHAR g_fatPathname7[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME;
+CHAR g_fatPathname8[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME;
+
+CHAR g_fatPathname11[FAT_MAXIMUM_SIZES][FAT_NAME_LIMITTED_SIZE] = { 0 };
+CHAR g_fatPathname12[FAT_MAXIMUM_SIZES][FAT_NAME_LIMITTED_SIZE] = { 0 };
+CHAR g_fatPathname13[FAT_MAXIMUM_SIZES][FAT_NAME_LIMITTED_SIZE] = { 0 };
+
+FILE *g_fatFfd;
+
+INT32 FatDeleteFile(int fd, char *pathname)
+{
+ int ret;
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+INT32 FixWrite(CHAR *path, INT64 file_size, INT32 write_size, INT32 interface_type)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ INT64 total = 0;
+ INT64 perTime;
+ INT64 totalSize = 0;
+ INT64 totalTime = 0;
+ INT32 cycleCount = 0;
+ INT32 taskId;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ DOUBLE testSpeed;
+ CHAR *pid = NULL;
+ CHAR *writeBuf = NULL;
+ FILE *file = NULL;
+
+ taskId = strlen(path);
+ pid = path + taskId - 1;
+ taskId = atoi(pid);
+
+ writeBuf = (CHAR *)malloc(write_size);
+ ICUNIT_GOTO_NOT_EQUAL(writeBuf, nullptr, writeBuf, EXIT);
+
+ gettimeofday(&testTime1, 0);
+ if (interface_type == 1) {
+ fd = open(path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ printf("Task_%d fail to open %s,\n", taskId, path);
+ goto EXIT1;
+ }
+ } else {
+ file = fopen(path, "w+b");
+ if (file == nullptr) {
+ printf("Task_%d fail to fopen %s,\n", taskId, path);
+ goto EXIT2;
+ }
+ }
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+ printf("fix_Write TaskID:%3d,open %s ,task %lld ms ,\n", taskId, path, perTime / MS_PER_SEC);
+
+ gettimeofday(&testTime1, 0);
+
+ while (1) {
+ if (interface_type == 1) {
+ ret = write(fd, writeBuf, write_size);
+ if (ret <= 0) {
+ if (errno == ENOSPC) {
+ printf("No space !! %s,\n", strerror(errno));
+ goto EXIT1;
+ }
+ printf("fix_write fail,path = %s,ret=:%d ,errno=:%d!\n", path, ret, errno);
+ goto EXIT1;
+ }
+ } else {
+ ret = fwrite(writeBuf, 1, write_size, file);
+ if (ret <= 0 || ret != write_size) {
+ if (errno == ENOSPC) {
+ printf("No space !! %s,\n", strerror(errno));
+ }
+ printf("fix_fwrite error! %s ,path=:%s, ret = %d,\n", strerror(errno), path, ret);
+
+ goto EXIT2;
+ }
+ }
+ total += ret;
+ totalSize += ret;
+ if (total >= CAL_THRESHOLD) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * US_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_KBYTES / BYTES_PER_KBYTES;
+
+ if (interface_type == 1) {
+ printf("fix_Write TaskID:%3d,%d time write, write %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n",
+ taskId, cycleCount++, total, perTime, testSpeed);
+ } else {
+ printf("fix_fwrite TaskID:%3d,%d time write, write %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n",
+ taskId, cycleCount++, total, perTime, testSpeed);
+ }
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+
+ if (file_size <= totalSize) {
+ break;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * US_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_KBYTES / BYTES_PER_KBYTES;
+
+ printf("\nfix_Write TaskID:%3d,total write=%lld , time=%lld,arv speed =%0.3lfMB/s ,\n", taskId, totalSize,
+ totalTime, testSpeed);
+ gettimeofday(&testTime1, 0);
+ if (interface_type == 1) {
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ } else {
+ ret = fclose(file);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ printf("fix_Write TaskID:%3d,sucess to fclose the %s ,task:%lld ms,\n", taskId, path, perTime / MS_PER_SEC);
+
+ free(writeBuf);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ fclose(file);
+ goto EXIT;
+EXIT1:
+ close(fd);
+EXIT:
+ free(writeBuf);
+ return FAT_NO_ERROR;
+}
+
+INT32 FixRead(CHAR *path, INT64 file_size, INT32 read_size, INT32 interface_type)
+{
+ INT32 fd, taskId, ret;
+ INT32 cycleCount = 0;
+ INT64 total = 0;
+ INT64 totalSize = 0;
+ INT64 perTime;
+ INT64 totalTime = 0;
+ FILE *file = NULL;
+ CHAR *readBuf = NULL;
+ CHAR *pid = NULL;
+ DOUBLE testSpeed;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ taskId = strlen(path);
+ pid = path + taskId - 1;
+ taskId = atoi(pid);
+
+ readBuf = (CHAR *)malloc(read_size);
+ ICUNIT_ASSERT_NOT_EQUAL(readBuf, nullptr, readBuf);
+
+ gettimeofday(&testTime1, 0);
+
+ if (interface_type == 1) {
+ fd = open(path, O_RDWR, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ printf("Task_%d fail to open %s,\n", taskId, path);
+ goto EXIT1;
+ }
+ } else {
+ file = fopen(path, "rb");
+ if (file == nullptr) {
+ printf("Task_%d fail to fopen %s,\n", taskId, path);
+ goto EXIT2;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ printf("fix_Read TaskID:%3d,open %s , task:%lld ms,\n", taskId, path, perTime / MS_PER_SEC);
+
+ gettimeofday(&testTime1, 0);
+
+ while (1) {
+ if (interface_type == 1) {
+ ret = read(fd, readBuf, read_size);
+ if (ret < 0) {
+ printf("ret = %d,%s read fail!-->(X),\n", ret, path);
+ goto EXIT1;
+ }
+ if (!ret) {
+ printf("warning: read ret = 0,\n");
+ goto EXIT1;
+ }
+ } else {
+ ret = fread(readBuf, 1, read_size, file);
+ if (ret <= 0) {
+ if (feof(file) == 1) {
+ printf("feof of %s,\n", path);
+ } else {
+ printf("fread error!,\n");
+ goto EXIT2;
+ }
+ }
+ }
+ total += ret;
+ totalSize += ret;
+
+ if (total >= CAL_THRESHOLD) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * US_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_KBYTES / BYTES_PER_KBYTES;
+
+ printf("fix_Read TaskID:%3d,times %d, read %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n", taskId,
+ cycleCount++, total, perTime, testSpeed);
+
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+
+ if (file_size <= totalSize) {
+ break;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * US_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_KBYTES / BYTES_PER_KBYTES;
+
+ printf("\nfix_Read TaskID:%3d,total read=%lld , time=%lld,arv speed =%0.3lfMB/s ,\n", taskId, totalSize, totalTime,
+ testSpeed);
+
+ gettimeofday(&testTime1, 0);
+ if (interface_type == 1) {
+ ret = close(fd);
+ if (ret < 0) {
+ printf("fail to close %s!\n", strerror(errno));
+ }
+ } else {
+ ret = fclose(file);
+ if (ret < 0) {
+ printf("fail to fclose %s!\n", strerror(errno));
+ }
+ }
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ printf("fix_Read TaskID:%3d, fclose %s!,task:%lld ms,\n", taskId, path, perTime / MS_PER_SEC);
+
+ ret = remove(path);
+ if (ret < 0) {
+ printf("fail to remove %s!\n", strerror(errno));
+ }
+
+ printf("Read TaskID:%3d,sucess to fread the %s,\n", taskId, path);
+ free(readBuf);
+ return 0;
+EXIT2:
+ fclose(file);
+EXIT1:
+ close(fd);
+
+ free(readBuf);
+ return FAT_NO_ERROR;
+}
+
+INT32 RandWrite(CHAR *path, INT64 file_size, INT32 interface_type)
+{
+ INT32 ret, i, fd;
+ INT32 cycleCount = 0;
+ INT32 taskId;
+ INT64 total = 0;
+ INT64 totalSize = 0;
+ INT64 perTime;
+ INT64 totalTime = 0;
+ CHAR *writeBuf = NULL;
+ CHAR *pid = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ DOUBLE testSpeed;
+ FILE *file = NULL;
+
+ taskId = strlen(path);
+ pid = path + taskId - 1;
+ taskId = atoi(pid);
+
+ writeBuf = (CHAR *)malloc(MAX_BUFFER_LEN);
+ ICUNIT_GOTO_NOT_EQUAL(writeBuf, nullptr, writeBuf, EXIT);
+
+ gettimeofday(&testTime1, 0);
+ if (interface_type == 1) {
+ fd = open(path, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ if (fd < 0) {
+ printf("Task_%d fail to open %s,\n", taskId, path);
+ goto EXIT1;
+ }
+ } else {
+ file = fopen(path, "w+b");
+ if (file == nullptr) {
+ printf("Task_%d fail to fopen %s,\n", taskId, path);
+ goto EXIT2;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+ printf("RandWrite TaskID:%3d,open %s , cost:%lld ms,\n", taskId, path, perTime / MS_PER_SEC);
+
+ gettimeofday(&testTime1, 0);
+
+ i = 0;
+
+ while (1) {
+ if (interface_type == 1) {
+ ret = write(fd, writeBuf, g_grandSize[i]);
+ if (ret <= 0) {
+ printf("ret = %d,%s write fail!-->(X),\n", ret, path);
+ if (errno == ENOSPC) {
+ printf("No space !! %s,\n", strerror(errno));
+ goto EXIT1;
+ }
+ goto EXIT1;
+ }
+ } else {
+ ret = fwrite(writeBuf, 1, g_grandSize[i], file);
+ if (ret <= 0 || ret != g_grandSize[i]) {
+ if (errno == ENOSPC) {
+ printf("No space !! %s,\n", strerror(errno));
+ }
+ printf("rand_Write TaskID:%3d,fwrite error! %s , ret = %d,\n", taskId, strerror(errno), ret);
+ goto EXIT2;
+ }
+ }
+
+ total += ret;
+ totalSize += ret;
+ if (total >= CAL_THRESHOLD) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * US_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_KBYTES / BYTES_PER_KBYTES;
+
+ printf("rand_Write TaskID:%3d,%d time write, write %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n",
+ taskId, cycleCount++, total, perTime, testSpeed);
+
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+
+ if (file_size <= totalSize) {
+ break;
+ }
+ if (++i >= MAX_DEF_BUF_NUM)
+ i = 0;
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * US_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_KBYTES / BYTES_PER_KBYTES;
+ printf("--------------------------------\n");
+ printf("rand_Write TaskID:%3d,total write=%lld , time=%lld,arv speed =%0.3lfMB/s ,\n", taskId, totalSize, totalTime,
+ testSpeed);
+
+ gettimeofday(&testTime1, 0);
+ if (interface_type == 1) {
+ ret = close(fd);
+ if (ret < 0) {
+ printf("rand_Write TaskID:%3d,fail to close %s!\n", taskId, strerror(errno));
+ goto EXIT1;
+ }
+ } else {
+ ret = fclose(file);
+ if (ret < 0) {
+ printf("rand_Write TaskID:%3d,fail to fclose %s!\n", taskId, strerror(errno));
+ goto EXIT2;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ printf("rand_Write TaskID:%3d,sucess to fclose the %s ,task %lld,\n", taskId, path, perTime / MS_PER_SEC);
+
+ free(writeBuf);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ fclose(file);
+ goto EXIT;
+EXIT1:
+ close(fd);
+EXIT:
+ free(writeBuf);
+ return FAT_NO_ERROR;
+}
+
+INT32 RandRead(CHAR *path, INT64 file_size, INT32 interface_type)
+{
+ INT32 ret, fd, i;
+ INT32 cycleCount = 0;
+ INT32 taskId;
+ INT64 total = 0;
+ INT64 totalSize = 0;
+ INT64 perTime;
+ INT64 totalTime = 0;
+ struct timeval testTime1;
+ struct timeval testTime2;
+ DOUBLE testSpeed;
+ CHAR *pid = NULL;
+ CHAR *readBuf = NULL;
+ FILE *file = NULL;
+
+ taskId = strlen(path);
+ pid = path + taskId - 1;
+ taskId = atoi(pid);
+
+ readBuf = (CHAR *)malloc(MAX_BUFFER_LEN);
+ ICUNIT_GOTO_NOT_EQUAL(readBuf, nullptr, readBuf, EXIT);
+
+ gettimeofday(&testTime1, 0);
+ if (interface_type == 1) {
+ fd = open(path, O_RDWR, S_IRUSR | S_IWUSR);
+ if (-1 == fd) {
+ printf("fail to open %s\n", path);
+ goto EXIT1;
+ }
+ } else {
+ file = fopen(path, "rb");
+ if (file == nullptr) {
+ printf("fail to fopen %s\n", path);
+ goto EXIT2;
+ }
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+ printf("RandRead, open %s , task:%lld ms,\n", path, perTime / MS_PER_SEC);
+
+ i = 0;
+ gettimeofday(&testTime1, 0);
+
+ while (1) {
+ if (interface_type == 1) {
+ ret = read(fd, readBuf, g_grandSize[i]);
+ if (ret < 0) {
+ printf("ret = %d,%s read fail!-->(X)\n", ret, path);
+ goto EXIT1;
+ }
+ if (!ret) {
+ printf("warning: read ret = 0,\n");
+ }
+ } else {
+ ret = fread(readBuf, 1, g_grandSize[i], file);
+ if (ret <= 0) {
+ if (feof(file) == 1) {
+ printf("feof of %s\n", path);
+ } else {
+ printf("fread error!\n");
+ goto EXIT2;
+ }
+ }
+ }
+ total += ret;
+ totalSize += ret;
+
+ if (total >= CAL_THRESHOLD) {
+ gettimeofday(&testTime2, 0);
+
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = total * 1.0;
+ testSpeed = testSpeed * US_PER_SEC / perTime;
+ testSpeed = testSpeed / BYTES_PER_KBYTES / BYTES_PER_KBYTES;
+
+ printf("rand_Read TaskID:%3d, times %d, read %lldbytes, cost %lld usecs, speed: %0.3lfMB/s,\n", taskId,
+ cycleCount++, total, perTime, testSpeed);
+
+ total = 0;
+ gettimeofday(&testTime1, 0);
+ }
+
+ if (file_size <= totalSize) {
+ break;
+ }
+ if (++i >= MAX_DEF_BUF_NUM)
+ i = 0;
+ }
+
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ totalTime += perTime;
+
+ testSpeed = totalSize * 1.0;
+ testSpeed = testSpeed * US_PER_SEC / totalTime;
+ testSpeed = testSpeed / BYTES_PER_KBYTES / BYTES_PER_KBYTES;
+ printf("--------------------------------\n");
+ printf("rand_Read TaskID:%3d ,total read=%lld , time=%lld,arv speed =%0.3lfMB/s ,\n", taskId, totalSize, totalTime,
+ testSpeed);
+
+ gettimeofday(&testTime1, 0);
+ if (interface_type == 1) {
+ ret = close(fd);
+ if (ret < 0) {
+ printf("fail to close %s!\n", strerror(errno));
+ }
+ } else {
+ ret = fclose(file);
+ if (ret < 0) {
+ printf("fail to fclose %s!\n", strerror(errno));
+ }
+ }
+ gettimeofday(&testTime2, 0);
+ perTime = (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
+
+ printf(" rand_Read TaskID:%3d,fclose %s!,task:%lld ms,\n", taskId, path, perTime / MS_PER_SEC);
+
+ ret = remove(path);
+ if (ret < 0) {
+ printf("fail to fclose %s!\n", strerror(errno));
+ }
+
+ printf("rand_Read TaskID:%3d,sucess to fread the %s,\n", taskId, path);
+
+ free(readBuf);
+ return FAT_NO_ERROR;
+
+EXIT2:
+ fclose(file);
+ goto EXIT1;
+EXIT1:
+ close(fd);
+EXIT:
+ free(readBuf);
+ return FAT_NO_ERROR;
+}
+
+VOID FatStrcat2(char *pathname, char *str, int len)
+{
+ (void)memset_s(pathname, len, 0, len);
+ (void)strcpy_s(pathname, len, FAT_PATH_NAME);
+ (void)strcat_s(pathname, len, str);
+}
+
+INT32 FatScandirFree(struct dirent **namelist, int n)
+{
+ if (n < 0 || namelist == nullptr) {
+ return -1;
+ } else if (n == 0) {
+ free(namelist);
+ namelist = nullptr;
+ return 0;
+ }
+ while (n--) {
+ free(namelist[n]);
+ }
+ free(namelist);
+ namelist = nullptr;
+
+ return 0;
+}
+
+VOID FatStatPrintf(struct stat sb)
+{
+#if VFS_STAT_PRINTF == 1
+
+ printf("File type: ");
+
+ switch (sb.st_mode & S_IFMT) {
+ case S_IFBLK:
+ printf("block device\n");
+ break;
+ case S_IFCHR:
+ printf("character device\n");
+ break;
+ case S_IFDIR:
+ printf("directory\n");
+ break;
+ case S_IFIFO:
+ printf("FIFO/pipe\n");
+ break;
+ case S_IFLNK:
+ printf("symlink\n");
+ break;
+ case S_IFREG:
+ printf("regular file\n");
+ break;
+ case S_IFSOCK:
+ printf("socket\n");
+ break;
+ default:
+ printf("unknown?\n");
+ break;
+ }
+
+ switch (sb.st_mode & S_IRWXU) {
+ case S_IRUSR:
+ printf("Owners have read permission\n");
+ break;
+ case S_IWUSR:
+ printf("Owners have write permission\n");
+ break;
+ case S_IXUSR:
+ printf("Owners have execute permissions\n");
+ break;
+ default:
+ break;
+ }
+
+ switch (sb.st_mode & S_IRWXG) {
+ case S_IRGRP:
+ printf("Group has read permission\n");
+ break;
+ case S_IWGRP:
+ printf("Group has write permission\n");
+ break;
+ case S_IXGRP:
+ printf("Group has execute permission\n");
+ break;
+ default:
+ break;
+ }
+
+ switch (sb.st_mode & S_IRWXO) {
+ case S_IROTH:
+ printf("Other have read permission\n");
+ break;
+ case S_IWOTH:
+ printf("Other has write permission\n");
+ break;
+ case S_IXOTH:
+ printf("Other has execute permission\n");
+ break;
+ default:
+ break;
+ }
+
+ printf("I-node number: %ld\n", (long)sb.st_ino);
+ printf("Mode: %lo (octal)\n", (unsigned long)sb.st_mode);
+ printf("Link count: %ld\n", (long)sb.st_nlink);
+ printf("Ownership: UID=%ld GID=%ld\n", (long)sb.st_uid, (long)sb.st_gid);
+
+ printf("Preferred I/O block size: %ld bytes\n", (long)sb.st_blksize);
+ printf("File size: %lld bytes\n", (long long)sb.st_size);
+ printf("Blocks allocated: %lld\n", (long long)sb.st_blocks);
+
+ printf("Last status change: %s", ctime(&sb.st_ctime));
+ printf("Last file access: %s", ctime(&sb.st_atime));
+ printf("Last file modification: %s\n\n", ctime(&sb.st_mtime));
+
+#endif
+ return;
+}
+
+VOID FatStatfsPrintf(struct statfs buf)
+{
+#if VFS_STATFS_PRINTF == 1
+ printf("type of file system : 0x%x\n", buf.f_type);
+ printf("optimal transfer block size : %ld\n", (long)buf.f_bsize);
+ printf("total data blocks in file system : %ld\n", (long)buf.f_blocks);
+ printf("free blocks in fs : %ld\n", (long)buf.f_bfree);
+ printf("free blocks available to unprivileged user : %ld\n", (long)buf.f_bavail);
+ printf("total file nodes in file system : %ld\n", (long)buf.f_files);
+
+ printf("free file nodes in fs : %ld\n", (long)buf.f_ffree);
+ printf("file system id : %d\n", buf.f_fsid.__val[0]);
+ printf("maximum length of filenames : 0x%x\n", buf.f_namelen);
+ printf("fragment size: %d\n\n", buf.f_frsize);
+
+#endif
+
+ return;
+}
+
+using namespace testing::ext;
+namespace OHOS {
+class VfsFatTest : public testing::Test {
+public:
+ static void SetUpTestCase(void)
+ {
+ INT32 ret = 0;
+ sleep(3); // 3s
+ if (ret != 0)
+ perror("format sd card");
+ return;
+ ret = mkdir("/vs/", S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret != 0) {
+ perror("mkdir mount dir");
+ return;
+
+ ret = mkdir(FAT_MOUNT_DIR, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret != 0) {
+ perror("mkdir mount dir");
+ return;
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, nullptr);
+ if (ret != 0) {
+ perror("mount sd card");
+ return;
+ }
+ }
+ }
+ }
+ static void TearDownTestCase(void)
+ {
+ umount(FAT_MOUNT_DIR);
+ }
+};
+
+#if defined(LOSCFG_USER_TEST_FULL)
+HWTEST_F(VfsFatTest, ItFsFat066, TestSize.Level0)
+{
+ ItFsFat066();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat068, TestSize.Level0)
+{
+ ItFsFat068();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat072, TestSize.Level0)
+{
+ ItFsFat072();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat073, TestSize.Level0)
+{
+ ItFsFat073();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat074, TestSize.Level0)
+{
+ ItFsFat074();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat496, TestSize.Level0)
+{
+ ItFsFat496();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat497, TestSize.Level0)
+{
+ ItFsFat497();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat498, TestSize.Level0)
+{
+ ItFsFat498();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat499, TestSize.Level0)
+{
+ ItFsFat499();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat500, TestSize.Level0)
+{
+ ItFsFat500();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat501, TestSize.Level0)
+{
+ ItFsFat501();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat502, TestSize.Level0)
+{
+ ItFsFat502();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat503, TestSize.Level0)
+{
+ ItFsFat503();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat504, TestSize.Level0)
+{
+ ItFsFat504();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat506, TestSize.Level0)
+{
+ ItFsFat506();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat507, TestSize.Level0)
+{
+ ItFsFat507();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat508, TestSize.Level0)
+{
+ ItFsFat508();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat509, TestSize.Level0)
+{
+ ItFsFat509();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat510, TestSize.Level0)
+{
+ ItFsFat510();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat511, TestSize.Level0)
+{
+ ItFsFat511();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat512, TestSize.Level0)
+{
+ ItFsFat512();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat513, TestSize.Level0)
+{
+ ItFsFat513();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat514, TestSize.Level0)
+{
+ ItFsFat514();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat515, TestSize.Level0)
+{
+ ItFsFat515();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat516, TestSize.Level0)
+{
+ ItFsFat516();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat517, TestSize.Level0)
+{
+ ItFsFat517();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat518, TestSize.Level0)
+{
+ ItFsFat518();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat519, TestSize.Level0)
+{
+ ItFsFat519();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat662, TestSize.Level0)
+{
+ ItFsFat662();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat663, TestSize.Level0)
+{
+ ItFsFat663();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat664, TestSize.Level0)
+{
+ ItFsFat664();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat665, TestSize.Level0)
+{
+ ItFsFat665();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat666, TestSize.Level0)
+{
+ ItFsFat666();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat667, TestSize.Level0)
+{
+ ItFsFat667();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat668, TestSize.Level0)
+{
+ ItFsFat668();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat669, TestSize.Level0)
+{
+ ItFsFat669();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat670, TestSize.Level0)
+{
+ ItFsFat670();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat671, TestSize.Level0)
+{
+ ItFsFat671();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat672, TestSize.Level0)
+{
+ ItFsFat672();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat673, TestSize.Level0)
+{
+ ItFsFat673();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat674, TestSize.Level0)
+{
+ ItFsFat674();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat675, TestSize.Level0)
+{
+ ItFsFat675();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat676, TestSize.Level0)
+{
+ ItFsFat676();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat677, TestSize.Level0)
+{
+ ItFsFat677();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat678, TestSize.Level0)
+{
+ ItFsFat678();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat679, TestSize.Level0)
+{
+ ItFsFat679();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat680, TestSize.Level0)
+{
+ ItFsFat680();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat681, TestSize.Level0)
+{
+ ItFsFat681();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat682, TestSize.Level0)
+{
+ ItFsFat682();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat683, TestSize.Level0)
+{
+ ItFsFat683();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat684, TestSize.Level0)
+{
+ ItFsFat684();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat685, TestSize.Level0)
+{
+ ItFsFat685();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat686, TestSize.Level0)
+{
+ ItFsFat686();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat687, TestSize.Level0)
+{
+ ItFsFat687();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat692, TestSize.Level0)
+{
+ ItFsFat692();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat693, TestSize.Level0)
+{
+ ItFsFat693();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat694, TestSize.Level0)
+{
+ ItFsFat694();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat870, TestSize.Level0)
+{
+ ItFsFat870();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat872, TestSize.Level0)
+{
+ ItFsFat872();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat873, TestSize.Level0)
+{
+ ItFsFat873();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat874, TestSize.Level0)
+{
+ ItFsFat874();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat875, TestSize.Level0)
+{
+ ItFsFat875();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat902, TestSize.Level0)
+{
+ ItFsFat902();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat903, TestSize.Level0)
+{
+ ItFsFat903();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat904, TestSize.Level0)
+{
+ ItFsFat904();
+}
+
+HWTEST_F(VfsFatTest, ItFsFat909, TestSize.Level0)
+{
+ ItFsFat909(); // plug and unplug during writing or reading
+}
+
+#endif
+#if defined(LOSCFG_USER_TEST_PRESSURE)
+HWTEST_F(VfsFatTest, ItFsFatPressure040, TestSize.Level0)
+{
+ ItFsFatPressure040();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread046, TestSize.Level0)
+{
+ ItFsFatMutipthread046();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread047, TestSize.Level0)
+{
+ ItFsFatMutipthread047();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPressure030, TestSize.Level0)
+{
+ ItFsFatPressure030(); // time too long
+}
+
+#if (FAT_FILE_SYSTEMTYPE_AUTO == FAT_FILE_SYSTEMTYPE_FAT32)
+HWTEST_F(VfsFatTest, ItFsFatPressure031, TestSize.Level0)
+{
+ ItFsFatPressure031();
+}
+#endif
+
+HWTEST_F(VfsFatTest, ItFsFatPressure038, TestSize.Level0)
+{
+ ItFsFatPressure038();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPressure041, TestSize.Level0)
+{
+ ItFsFatPressure041();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPressure042, TestSize.Level0)
+{
+ ItFsFatPressure042();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPressure301, TestSize.Level0)
+{
+ ItFsFatPressure301();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPressure302, TestSize.Level0)
+{
+ ItFsFatPressure302();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPressure303, TestSize.Level0)
+{
+ ItFsFatPressure303();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPressure305, TestSize.Level0)
+{
+ ItFsFatPressure305();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPressure306, TestSize.Level0)
+{
+ ItFsFatPressure306();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPressure309, TestSize.Level0)
+{
+ ItFsFatPressure309();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread003, TestSize.Level0)
+{
+ ItFsFatMutipthread003();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread004, TestSize.Level0)
+{
+ ItFsFatMutipthread004();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread005, TestSize.Level0)
+{
+ ItFsFatMutipthread005();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread006, TestSize.Level0)
+{
+ ItFsFatMutipthread006();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread008, TestSize.Level0)
+{
+ ItFsFatMutipthread008();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread009, TestSize.Level0)
+{
+ ItFsFatMutipthread009();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread010, TestSize.Level0)
+{
+ ItFsFatMutipthread010();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread012, TestSize.Level0)
+{
+ ItFsFatMutipthread012();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread014, TestSize.Level0)
+{
+ ItFsFatMutipthread014();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread016, TestSize.Level0)
+{
+ ItFsFatMutipthread016();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread017, TestSize.Level0)
+{
+ ItFsFatMutipthread017();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread018, TestSize.Level0)
+{
+ ItFsFatMutipthread018();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread019, TestSize.Level0)
+{
+ ItFsFatMutipthread019();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread020, TestSize.Level0)
+{
+ ItFsFatMutipthread020();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread021, TestSize.Level0)
+{
+ ItFsFatMutipthread021();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread022, TestSize.Level0)
+{
+ ItFsFatMutipthread022();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread023, TestSize.Level0)
+{
+ ItFsFatMutipthread023();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread024, TestSize.Level0)
+{
+ ItFsFatMutipthread024();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread027, TestSize.Level0)
+{
+ ItFsFatMutipthread027();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread029, TestSize.Level0)
+{
+ ItFsFatMutipthread029();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread030, TestSize.Level0)
+{
+ ItFsFatMutipthread030();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread032, TestSize.Level0)
+{
+ ItFsFatMutipthread032();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread033, TestSize.Level0)
+{
+ ItFsFatMutipthread033();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread035, TestSize.Level0)
+{
+ ItFsFatMutipthread035();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread036, TestSize.Level0)
+{
+ ItFsFatMutipthread036();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread038, TestSize.Level0)
+{
+ ItFsFatMutipthread038();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread039, TestSize.Level0)
+{
+ ItFsFatMutipthread039();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread040, TestSize.Level0)
+{
+ ItFsFatMutipthread040();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread041, TestSize.Level0)
+{
+ ItFsFatMutipthread041();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread042, TestSize.Level0)
+{
+ ItFsFatMutipthread042();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread043, TestSize.Level0)
+{
+ ItFsFatMutipthread043();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread044, TestSize.Level0)
+{
+ ItFsFatMutipthread044();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread045, TestSize.Level0)
+{
+ ItFsFatMutipthread045();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread048, TestSize.Level0)
+{
+ ItFsFatMutipthread048();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread049, TestSize.Level0)
+{
+ ItFsFatMutipthread049();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatMutipthread050, TestSize.Level0)
+{
+ ItFsFatMutipthread050();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance013, TestSize.Level0)
+{
+ ItFsFatPerformance013();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance014, TestSize.Level0)
+{
+ ItFsFatPerformance014();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance015, TestSize.Level0)
+{
+ ItFsFatPerformance015();
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance016, TestSize.Level0)
+{
+ ItFsFatPerformance016(); // Multi-threaded takes time to delete directory files When the fourth
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance001, TestSize.Level0)
+{
+ ItFsFatPerformance001(); // rand fwrite and fread for one pthread
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance006, TestSize.Level0)
+{
+ ItFsFatPerformance006(); // rand fwrite and fread for three pthread
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance002, TestSize.Level0)
+{
+ ItFsFatPerformance002(); // fix fwrite and fread for one pthread
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance005, TestSize.Level0)
+{
+ ItFsFatPerformance005(); // fix fwrite and fread for three pthread
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance003, TestSize.Level0)
+{
+ ItFsFatPerformance003(); // rand write and read for one pthread
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance004, TestSize.Level0)
+{
+ ItFsFatPerformance004(); // fix write and read for one pthread
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance007, TestSize.Level0)
+{
+ ItFsFatPerformance007(); // rand write and read for three pthread
+}
+
+HWTEST_F(VfsFatTest, ItFsFatPerformance008, TestSize.Level0)
+{
+ ItFsFatPerformance008(); // fix write and read for three pthread
+}
+
+#endif
+#if defined(LOSCFG_USER_TEST_SMOKE)
+HWTEST_F(VfsFatTest, ItFsFat026, TestSize.Level0)
+{
+ ItFsFat026(); // statfs Unsupport
+}
+#endif
+} // namespace OHOS
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_066.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_066.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..13c6071087691f04449a49ca50ae832e69f3ca99
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_066.cpp
@@ -0,0 +1,346 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static const int CLUSTER_SIZE4 = 4;
+static const int CLUSTER_SIZE8 = 8;
+static const int CLUSTER_SIZE16 = 16;
+static const int CLUSTER_SIZE32 = 32;
+static const int CLUSTER_SIZE64 = 64;
+static const int CLUSTER_SIZE128 = 128;
+static const int CLUSTER_SIZE255 = 255;
+static const int CLUSTER_SIZE256 = 256;
+static const int SECTOR_SIZE = 128;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ struct stat buf = { 0 };
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(NULL, CLUSTER_SIZE8, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE8, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mkdir(FAT_PATH_NAME, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mkdir(FAT_PATH_NAME, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(FAT_PATH_NAME, &buf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ if (g_fatFilesystem != FAT_FILE_SYSTEMTYPE_EXFAT)
+ ICUNIT_GOTO_EQUAL(buf.st_blksize, CLUSTER_SIZE64 * SECTOR_SIZE, buf.st_blksize, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE16, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mkdir(FAT_PATH_NAME, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(FAT_PATH_NAME, &buf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_GOTO_EQUAL(buf.st_blksize, CLUSTER_SIZE16 * SECTOR_SIZE, buf.st_blksize, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE32, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mkdir(FAT_PATH_NAME, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(FAT_PATH_NAME, &buf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf.st_blksize, CLUSTER_SIZE32 * SECTOR_SIZE, buf.st_blksize, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE64, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mkdir(FAT_PATH_NAME, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(FAT_PATH_NAME, &buf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf.st_blksize, CLUSTER_SIZE64 * SECTOR_SIZE, buf.st_blksize, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE128, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mkdir(FAT_PATH_NAME, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(FAT_PATH_NAME, &buf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf.st_blksize, CLUSTER_SIZE128 * SECTOR_SIZE, buf.st_blksize, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE4, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mkdir(FAT_PATH_NAME, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(FAT_PATH_NAME, &buf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_GOTO_EQUAL(buf.st_blksize, CLUSTER_SIZE4 * SECTOR_SIZE, buf.st_blksize, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, 1, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = mkdir(FAT_PATH_NAME, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(FAT_PATH_NAME, &buf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_GOTO_EQUAL(buf.st_blksize, SECTOR_SIZE, buf.st_blksize, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE255, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE256, FAT_FILE_SYSTEMTYPE_AUTO);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT)
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+ }
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = remove(FAT_PATH_NAME);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = mkdir(FAT_PATH_NAME, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(FAT_PATH_NAME, &buf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE8, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = mkdir(FAT_PATH_NAME, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = access(FAT_PATH_NAME, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(FAT_PATH_NAME, &buf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_GOTO_EQUAL(buf.st_blksize, CLUSTER_SIZE8 * SECTOR_SIZE, buf.st_blksize, EXIT1);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+EXIT1:
+ rmdir(FAT_PATH_NAME);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_066
+* -@tspec The function test for filesystem
+* -@ttitle Format the SD card with some different parameters
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a directory;
+2. use access to check the directory whether is existed
+3. format the SD card with different parameters;
+4. repeat the above process several times.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat066(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_066", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_068.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_068.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..81cd43e223cd98d59d7bf582fde3fa8ae71d72b3
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_068.cpp
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static const int CLUSTER_SIZE = 8;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 i;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_MAIN_DIR;
+ DIR *dir = NULL;
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < FAT_PRESSURE_CYCLES; i++) {
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ goto EXIT;
+EXIT1:
+ closedir(dir);
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_068
+* -@ttitle Repeat mount, format, umount, format the same SD card 20 times
+* -@ttitle Repeat mount, format, umount, format the same SD card 20 times
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create a directory;
+2. mount, format, umount, format the same SD;
+3. repeat the above processre 20 times;
+4. format the SD card once more.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat068(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_068", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_072.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_072.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..38cd5c019a7ffe2de3d7018909b04dff08c5be35
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_072.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static const INT32 CLUSTER_SIZE8 = 8;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ DIR *dir = NULL;
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE8, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ dir = opendir(FAT_MAIN_DIR);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE8, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ goto EXIT;
+EXIT1:
+ closedir(dir);
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_072
+* -@tspec The function test for filesystem
+* -@ttitle Repeat mount the the file system to the same directory
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. check the filesysterm is existed or not;
+2. umount the filesystem;
+3. mount the filesystem;
+4. repeat mount the the file system to the same directory.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Failed operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat072(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_072", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_073.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_073.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f4b74ce053ea30378a637603d4861e415cb9a5bd
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_073.cpp
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static const INT32 CLUSTER_SIZE8 = 8;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ DIR *dir = NULL;
+
+ dir = opendir(FAT_MAIN_DIR);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ ret = format(FAT_DEV_PATH, CLUSTER_SIZE8, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ goto EXIT;
+EXIT1:
+ closedir(dir);
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_073
+* -@tspec The function test for filesystem
+* -@ttitle Repeat umount the the same file system
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. check the filesysterm is existed or not;
+2. umount the filesystem;
+3. repeat umount the filesystem;
+4. mount the the file system normally.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return failed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat073(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_073", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_074.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_074.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..01eb3f8f29ba78a9f69d57385d7eb695d50f0f59
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_074.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 fd1 = 0;
+ INT32 i = 0;
+ INT32 len;
+ CHAR filebuf[FAT_STANDARD_NAME_LENGTH] = "abcdeabcde";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/test");
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, FAT_IS_ERROR, fd1, EXIT1);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, FAT_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < FAT_MOUNT_CYCLES_TEST; i++) {
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, i, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, i, EXIT2);
+ }
+
+ fd1 = open(pathname1, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, FAT_IS_ERROR, fd1, EXIT1);
+
+ len = read(fd1, readbuf, FAT_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, FAT_SHORT_ARRAY_LENGTH, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, filebuf, readbuf, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+EXIT1:
+ close(fd1);
+ remove(pathname1);
+EXIT:
+ remove(FAT_PATH_NAME);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_074
+* -@tspec The function test for filesystem
+* -@ttitle Mount/umount the file system several times
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create one file and write some data into it;
+2. mount/umount the file system several times;
+3. open the file and check the file`s content;
+4. close and delete the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat074(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_074", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_496.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_496.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d285f3eea8a44b0df594494087c601bac42f2622
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_496.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/589.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = ioctl(fd, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ remove(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat496(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_496", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_497.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_497.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..821959e16327fdcf2c248eb8e350e0fe3f13fc85
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_497.cpp
@@ -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 "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/590.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT2);
+
+ ret = ioctl(fd, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ return FAT_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ remove(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat497(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_497", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_498.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_498.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9596e7a94e388e230400d2d17d55a7448ade5492
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_498.cpp
@@ -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 "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/591.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT2);
+
+ ret = ioctl(fd, 1, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ return FAT_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ remove(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat498(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_498", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_499.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_499.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7688f7b141f9a77502b3b239471ed07e18074928
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_499.cpp
@@ -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 "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/591.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT2);
+
+ ret = ioctl(fd, 0xffff, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ return FAT_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ remove(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat499(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_499", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_500.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_500.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..917c9738f5983799891fbd1032f89a82acfdb72e
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_500.cpp
@@ -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 "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/591.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT2);
+
+ ret = ioctl(fd, -1, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ return FAT_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ remove(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat500(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_500", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_501.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_501.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1dac4bdcbe2b5d54b3fdf8ec688ec24fd1697696
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_501.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static const int IOCTL_CMD = 10;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/594.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT2);
+
+ ret = ioctl(fd, IOCTL_CMD, 0);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ return FAT_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ remove(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat501(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_501", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_502.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_502.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0388eff871e61b282dd10a3459c7b82b11aaeb92
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_502.cpp
@@ -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 "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/595.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT2);
+
+ ret = ioctl(fd, 0, 1);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ return FAT_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ remove(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat502(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_502", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_503.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_503.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ea3a0016404ebf6f5b4a6d1113351cea8e1fc8a3
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_503.cpp
@@ -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 "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/596.c");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT2);
+
+ ret = ioctl(fd, 0, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOSYS, errno, EXIT2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ return FAT_NO_ERROR;
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname1);
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ remove(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat503(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_503", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_504.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_504.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8cbdcbb79cf78c812928d4dfc81840af90ba7381
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_504.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "/dev/mmcblk0p0";
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = format(pathname, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat504(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_504", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_506.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_506.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..361e89416fff123f146da67b7d38f28cd8142491
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_506.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "//";
+
+ ret = umount(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret = format(pathname, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, SD_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ mount(FAT_DEV_PATH1, SD_MOUNT_DIR, "vfat", 0, NULL);
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat506(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_506", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_507.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_507.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7e0315e05d6dae54ac38b50c3839537acbf776ad
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_507.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "/";
+
+ ret = format(pathname, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat507(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_507", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_508.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_508.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3e907bc8d94b20504af0b4a0b1525c028dae6e4d
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_508.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[302] =
+ "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij"
+ "9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789"
+ "abcedfghij9876543210abcdeabcde0123456789abcedfghij987654321011111111112222222222";
+
+ ret = format(pathname, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, ENAMETOOLONG, errno, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat508(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_508", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_509.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_509.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8f8f1839f1fead4d2cd31192c55f6f2adf2013ab
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_509.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "+-/*%^@";
+
+ ret = format(pathname, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat509(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_509", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_510.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_510.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..766f0cd6c5646c29b065e06a43544ba3e0e78f92
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_510.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+
+ ret = format(pathname, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat510(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_510", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_511.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_511.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..db4e7f6d24adbf89cdecc8c2fb6caf5ee71fd765
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_511.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "..";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = format(pathname1, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ rmdir(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat511(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_511", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_512.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_512.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..af1654e9c91440705f7bd027ea74a28acc9a62d4
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_512.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = ".";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = format(pathname1, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ rmdir(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat512(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_512", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_513.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_513.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7074ffe2c178091d7ddb679bf0dbcd053752cb9e
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_513.cpp
@@ -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.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = ""
+ "";
+
+ ret = format(pathname, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat513(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_513", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_514.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_514.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fb87cdcefe05dbe05de57886414e5f85cde3ae98
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_514.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = format(pathname1, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ rmdir(pathname1);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat514(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_514", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_515.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_515.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b1931dff75e117e797b7b34958894d25b5737ace
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_515.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 fd = 0;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = format(pathname1, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat515(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_515", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_516.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_516.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5c0e1b1d45c5b18fb31c1891af70dd74a3451298
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_516.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 err;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "/dev/nandblk0";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "/dev/spinor";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "/dev/uartdev-0";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "/dev/mmcblk";
+
+ ret = format(pathname1, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ printf("errno = %d\n", errno);
+ err = errno;
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(err, ENODEV, err, EXIT);
+
+ ret = format(pathname2, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ err = errno;
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(err, ENODEV, err, EXIT);
+
+ ret = format(pathname3, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ err = errno;
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(err, ENODEV, err, EXIT);
+
+ ret = format(pathname4, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ err = errno;
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(err, ENODEV, err, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat516(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_516", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_517.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_517.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b35ca4d3f9cd723f6e645a8b0ed516d0a3011a26
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_517.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_DEV_PATH;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = format(pathname1, -1, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = access(pathname2, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ rmdir(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat517(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_517", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_518.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_518.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f70dec379a741acf0f71f8c8e87c711ee753ce4d
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_518.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_DEV_PATH;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = format(pathname1, 0XFFFC, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ ret = access(pathname2, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ rmdir(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat518(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_518", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_519.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_519.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a2637044fd5781982feaf048aabcc9c597508afc
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_519.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_DEV_PATH;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = format(pathname1, 0, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
+
+ ret = access(pathname2, F_OK);
+ ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+EXIT:
+ rmdir(pathname2);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat519(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_519", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_662.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_662.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8538029e419644656b2e1a2c152ce63173620966
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_662.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static const off_t LEN = 20971520;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate(fd, 1, 0, LEN);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_662
+* -@tspec The function test for fallocate and fallocate64
+* -@ttitle The function test for fallocate and fallocate64 with the fd has been closed for the first parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the close to close the file;
+3. use the fallocate and fallocate64 to apply the space;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Failed operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat662(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_662", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_663.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_663.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..421450da7915445db29a8a103f19b2e0ff9fc0db
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_663.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret < 0 && errno != EEXIST) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_DIRECTORY, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_663
+* -@tspec The function test for fallocate and fallocate64
+* -@ttitle The function test for fallocate and fallocate64 that the fd open wth the directory
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open a directory;
+2. use the fallocate and fallocate64 to apply the space;
+3. delete the directory;
+4. N/A.
+* -@texpect
+1. Return successed
+2. Return failed
+3. Sucessful operation
+4. N/A
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat663(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_663", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_664.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_664.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..154c6cfa4abb26621428356bdf7a2e3b365a9419
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_664.cpp
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ struct statfs buf1 = { 0 };
+ struct statfs buf2 = { 0 };
+ struct statfs buf3 = { 0 };
+ struct statfs buf4 = { 0 };
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = fallocate(fd, -1, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, -1, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ret = fallocate(fd, FAT_FALLOCATE_NO_KEEP_SIZE, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_NO_KEEP_SIZE, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = statfs(pathname1, &buf4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf4);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_664
+* -@tspec The API test for fallocate and fallocate64
+* -@ttitle The API test for fallocate and fallocate64 with -1 and 0 for the second parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate and fallocate64 to apply the space with -1 and 0 for the second parameter;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return failed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat664(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_664", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_665.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_665.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f086cf20cccd78484aaf2e7458c5c19ace3ed907
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_665.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static const int WRONG_MODE = 10;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, WRONG_MODE, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, WRONG_MODE, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_665
+* -@tspec The API test for fallocate fallocate64
+* -@ttitle The API test for fallocate fallocate64 with 10 for the second parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with 10 for the second parameter;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return failed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat665(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_665", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_666.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_666.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..af6abc47efd0608afde78c3386356fed0e1d44bd
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_666.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, 0xffff, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, 0xffff, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_666
+* -@tspec The API test for fallocate fallocate64
+* -@ttitle The API test for fallocate fallocate64 with 0xffff for the second parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with 0xffff for the second parameter;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return failed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat666(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_666", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_667.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_667.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5190c6cabd3f1b657bc5b0b410f3499279c831ae
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_667.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, -1, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, -1, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_667
+* -@tspec The API test for fallocate fallocate64
+* -@ttitle The API test for fallocate fallocate64 with -1 for the third parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with -1 for the third parameter;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return failed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat667(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_667", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_668.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_668.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..87634c8c36265acd3cee4ca54d592ce407f9d2d1
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_668.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static const off_t OFFSET = 10;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, OFFSET, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, OFFSET, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_668
+* -@tspec The API test for fallocate fallocate64
+* -@ttitle The API test for fallocate fallocate64 with 10 for the third parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with 10 for the third parameter;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return failed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat668(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_668", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_669.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_669.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6c7af9ff4d690566be13fbeb092360899bc9ecd7
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_669.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0xffff, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0xffff, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_669
+* -@tspec The API test for fallocate fallocate64
+* -@ttitle The API test for fallocate fallocate64 with 0xffff for the third parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with 0xffff for the third parameter;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return failed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat669(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_669", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_670.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_670.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b6643b1b378895d0dcbdaad7d5b1e3116d398eda
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_670.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_670
+* -@tspec The API test for fallocate fallocate64
+* -@ttitle The API test for fallocate fallocate64 with 0 for the fourth parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with 0 for the fourth parameter;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return failed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat670(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_670", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_671.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_671.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9932bb1f615e064fa31b4b0d88fc764963b7ba9f
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_671.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, -1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, -1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_671
+* -@tspec The API test for fallocate fallocate64
+* -@ttitle The API test for fallocate fallocate64 with -1 for the fourth parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with -1 for the fourth parameter;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return failed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat671(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_671", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_672.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_672.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..94229dc6d568cd3b991cd09090bb6aef16a0f749
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_672.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR const writebuf[FAT_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, 0xffff);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, 0xffff);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_672
+* -@tspec The API test for fallocate
+* -@ttitle The API test for fallocate with 50 for the fourth parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate to apply the space with 50 for the fourth parameter;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat672(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_672", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_673.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_673.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4edd7a3eaade4222397e138f8de2c813ec32939f
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_673.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret = 0;
+ INT32 len = 0;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR const writebuf[FAT_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, 0xffffffff);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, 0xffffffffffffffff);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, 0xffff);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_673
+* -@tspec The API test for fallocate fallocate64
+* -@ttitle The API test for fallocate fallocate64 with 0xffff for the fourth parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with 0xffff for the fourth parameter;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat673(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_673", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_674.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_674.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7d4972df4897c8912461ac7dd3ece18dcdacf6fb
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_674.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ INT32 size = 0xffff;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR *writebuf = NULL;
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ writebuf = (CHAR *)malloc(size);
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT);
+ (void)memset_s(writebuf, size, 0x61, size);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, (size - 1));
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, (size - 1));
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ free(writebuf);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ free(writebuf);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_674
+* -@tspec The function test for fallocate fallocate64
+* -@ttitle The function test for fallocate fallocate64 with the lenth smaller than write
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with the lenth smaller than write;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat674(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_674", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_675.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_675.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8ee77b8c4a0e5f6c391617645edd07a60b96a4e5
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_675.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ INT32 size = 0xffff;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR *writebuf = NULL;
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ writebuf = (CHAR *)malloc(size);
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT);
+ (void)memset_s(writebuf, size, 0x61, size);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ free(writebuf);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ free(writebuf);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_675
+* -@tspec The function test for fallocate fallocate64
+* -@ttitle The function test for fallocate fallocate64 with the lenth equals to write
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with the lenth equals to write;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat675(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_675", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_676.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_676.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8f25af0aa72f53435fe9ba31faa5be00dadd35c0
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_676.cpp
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR const writebuf[FAT_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ struct statfs buf1 = { 0 };
+ struct statfs buf2 = { 0 };
+ off_t off;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bavail, buf2.f_bavail, buf1.f_bavail, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bfree, buf2.f_bfree, buf1.f_bfree, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT1);
+ }
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_676
+* -@tspec The function test for fallocate fallocate64
+* -@ttitle The function test for fallocate fallocate64 with the lenth is 2GB
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with the lenth is 2GB;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat676(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_676", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_677.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_677.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f9ac20f527f6974d40be2d5b2f924b2b5e65c034
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_677.cpp
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR const writebuf[FAT_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ struct statfs buf1 = { 0 };
+ struct statfs buf2 = { 0 };
+ off_t off;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bavail, buf2.f_bavail, buf1.f_bavail, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bfree, buf2.f_bfree, buf1.f_bfree, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT1);
+ }
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bavail, buf2.f_bavail, buf1.f_bavail, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bfree, buf2.f_bfree, buf1.f_bfree, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT1);
+
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bavail, buf2.f_bavail, buf1.f_bavail, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bfree, buf2.f_bfree, buf1.f_bfree, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT1);
+ }
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_677
+* -@tspec The function test for fallocate fallocate64
+* -@ttitle The function test for fallocate fallocate64 with the lenth is 2GB+1
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with the lenth is 2GB+1;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat677(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_677", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_678.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_678.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2c5196463e049daaaea462a7bf6fbdbf39da5fab
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_678.cpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR const writebuf[FAT_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ struct statfs buf1 = { 0 };
+ struct statfs buf2 = { 0 };
+ off_t off;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, 0x7FFFFFFF); // 2GB-1
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT1);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_678
+* -@tspec The function test for fallocate fallocate64
+* -@ttitle The function test for fallocate fallocate64 with the lenth is 2GB-1
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the function fallocate fallocate64 to apply the space with the lenth is 2GB-1;
+3. close the file;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat678(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_678", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_679.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_679.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fbfdd9094a2cf8d2e6ac2287505dbecb957c0125
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_679.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ INT32 size = 0xffff;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR *writebuf = NULL;
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ writebuf = (CHAR *)malloc(size);
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT);
+ (void)memset_s(writebuf, size, 0x61, size);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, -size, size);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, -size, size);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ off = lseek(fd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, size, off, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ free(writebuf);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ free(writebuf);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_679
+* -@tspec The function test for fallocate fallocate64
+* -@ttitle Fallocate allocates space while the offset + length is equal to the size of the file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one non-empty file;
+2. use the function fallocate fallocate64 to allocates space while the offset + length is equal to the size of the file
+;
+3. compare the file size before and after fallocate fallocate64;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat679(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_679", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_680.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_680.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5ed883b9d8d8a42c9b635fb3995d0e01e42919f9
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_680.cpp
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ INT32 size = 0xffff;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR *writebuf = NULL;
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ struct statfs buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct stat buf3 = { 0 };
+ off_t off;
+
+ writebuf = (CHAR *)malloc(size);
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT);
+ (void)memset_s(writebuf, size, 0x61, size);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf3);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size + FAT_STANDARD_NAME_LENGTH);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, -size, FAT_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf3.st_size, size, buf3.st_size, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf3);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size + FAT_STANDARD_NAME_LENGTH);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, -size, FAT_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf3.st_size, size, buf3.st_size, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ free(writebuf);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ free(writebuf);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_680
+* -@tspec The function test for fallocate fallocate64
+* -@ttitle Fallocate allocates space while the offset + length is more than the size of the file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one non-empty file;
+2. use the function fallocate fallocate64 to allocates space while the offset + length is more than the size of the file
+;
+3. compare the file size before and after fallocate fallocate64;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat680(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_680", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_681.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_681.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8b751ad12ed192cfeae1e265ca57fe952c71edd7
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_681.cpp
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ INT32 size = 0xffff;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "lala";
+ struct statfs buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct statfs buf3 = { 0 };
+ struct stat buf4 = { 0 };
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "lala", readbuf, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf4);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf3);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf2);
+ ICUNIT_GOTO_EQUAL(buf4.st_size, 0, buf4.st_size, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "lala", readbuf, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf4);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = statfs(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf3);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf2);
+ ICUNIT_GOTO_EQUAL(buf4.st_size, 0, buf4.st_size, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_681
+* -@tspec The function test for fallocate fallocate64
+* -@ttitle Read the file then use the fallocate fallocate64
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. write something in the file and then read it;
+3. compare the file size before and after fallocate fallocate64;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat681(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_681", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_682.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_682.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e6e58ba600044cbebe60c43d529745e59b6c212f
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_682.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ INT32 size = 0xffff;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ struct statfs buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct stat buf3 = { 0 };
+ off_t off;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf3);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf3.st_size, 10, buf3.st_size, EXIT1); // file size 10 bytes
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, writebuf, readbuf, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_682
+* -@tspec The function test for fallocate
+* -@ttitle Fallocate the read_only file then check whether the file size is changed
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one read_only file;
+2. use the function fallocate to apply the space ;
+3. compare the file size before and after fallocate;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat682(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_682", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_683.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_683.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..81fdbceeeb0964c638bb440586b85c48365ba340
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_683.cpp
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ INT32 size = 0xffff;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR const writebuf[FAT_STANDARD_NAME_LENGTH] = "0123456789";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ struct statfs buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct stat buf3 = { 0 };
+ off_t off;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf3);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf2);
+ ICUNIT_GOTO_EQUAL(buf3.st_size, 10, buf3.st_size, EXIT1); // file size 10 bytes
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf3);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf2);
+ ICUNIT_GOTO_EQUAL(buf3.st_size, 10, buf3.st_size, EXIT1); // file size 10 bytes
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, -1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_683
+* -@tspec The function test for fallocate
+* -@ttitle Fallocate the write_only file then check whether the file size is changed
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one write_only file;
+2. use the function fallocate to apply the space ;
+3. compare the file size before and after fallocate;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat683(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_683", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_684.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_684.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..567440330977c1bb9647496dda4740efd9833401
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_684.cpp
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static const off_t LEN = 10;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 i = 0;
+ INT32 size = 0x4000000;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ struct statfs buf1 = { 0 };
+ struct statfs buf3 = { 0 };
+ struct stat buf5 = { 0 };
+ struct stat buf6 = { 0 };
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf5);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, LEN);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = statfs(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf3);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < FAT_SHORT_ARRAY_LENGTH; i++) {
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = ftruncate(fd, 0x400);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = ftruncate64(fd, size);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = ftruncate64(fd, 0x400);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname1, &buf6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf6);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT)
+ ICUNIT_GOTO_EQUAL(buf6.st_size, 0, buf6.st_size, EXIT1);
+ else
+ ICUNIT_GOTO_EQUAL(buf6.st_size, 0x400, buf6.st_size, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, LEN, size);
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_VFAT_684
+* -@tspec The function test for fallocate
+* -@ttitle Fallocate apply space for the same file fd multiple times
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one file;
+2. use the function fallocate to apply the space for the same file fd multiple times;
+3. compare the file size before and after fallocate;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat684(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_684", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_685.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_685.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fddaa3789b5fdc3cdcb4ab7390ccbdd2441169c9
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_685.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ INT32 size = 0xffff;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR *writebuf = NULL;
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ struct statfs buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ struct stat buf3 = { 0 };
+ off_t off;
+
+ writebuf = (CHAR *)malloc(size);
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT);
+ (void)memset_s(writebuf, size, 0x61, size);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf3);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size - 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size - 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf2);
+ ICUNIT_GOTO_EQUAL(buf3.st_size, size, buf3.st_size, EXIT1);
+
+ len = write(fd, writebuf, size);
+ ICUNIT_GOTO_EQUAL(len, size, len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ free(writebuf);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ free(writebuf);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_685
+* -@tspec The function test for fallocate
+* -@ttitle Fallocate allocates space while the offset + length is smaller than the size of the file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one non-empty file;
+2. use the function fallocate to allocates space while the offset + length is smaller than the size of the file ;
+3. compare the file size before and after fallocate;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat685(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_685", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_686.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_686.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cc5e1cf11bf569ccb3b96073a109c9af082aa459
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_686.cpp
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static const int SIZE_DIVIDER = 2;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ INT32 size = 0xffff;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR *writebuf = NULL;
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ writebuf = (CHAR *)malloc(size + 1);
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT);
+ (void)memset_s(writebuf, size + 1, 0, size + 1);
+ ret = memset_s(writebuf, size + 1, 0x61, size);
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, (strlen(writebuf) / SIZE_DIVIDER),
+ (strlen(writebuf) - (strlen(writebuf) / SIZE_DIVIDER)));
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, (strlen(writebuf) / SIZE_DIVIDER), strlen(writebuf));
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, (strlen(writebuf) / SIZE_DIVIDER), 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, (strlen(writebuf) / SIZE_DIVIDER),
+ (strlen(writebuf) - (strlen(writebuf) / 2))); // divid the size by 2, get half size
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, (strlen(writebuf) / SIZE_DIVIDER), strlen(writebuf));
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, (strlen(writebuf) / SIZE_DIVIDER), 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ free(writebuf);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ free(writebuf);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_686
+* -@tspec The function test for fallocate
+* -@ttitle Fallocate allocates space while the postion is in the file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one non-empty file;
+2. use the function fallocate to allocates space while the postion is in the file ;
+3. compare the file size before and after fallocate;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat686(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_686", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_687.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_687.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8d5075012be53ce0dbda09d5946f38629dcd18d4
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_687.cpp
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ INT32 size = 0xffff;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR *writebuf = NULL;
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ off_t off;
+
+ writebuf = (CHAR *)malloc(size);
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT);
+ (void)memset_s(writebuf, size, 0x61, size);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, strlen(writebuf), -FAT_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, off, strlen(writebuf));
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, strlen(writebuf), off, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, strlen(writebuf), -FAT_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd, FAT_FALLOCATE_KEEP_SIZE, off, strlen(writebuf));
+ if (g_fatFilesystem == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ len = write(fd, writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(writebuf), len, EXIT1);
+
+ off = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT1);
+
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_STANDARD_NAME_LENGTH - 1, len, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ free(writebuf);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ free(writebuf);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_687
+* -@tspec The function test for fallocate
+* -@ttitle Fallocate allocates space while the postion is end of the file
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one non-empty file;
+2. use the function fallocate to allocates space while the postion is end of the file ;
+3. compare the file size before and after fallocate;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat687(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_687", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_692.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_692.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7e1211a0d65030634f570cec4e62d4e94af1df6b
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_692.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 size = 0x4000000;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ struct statfs buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EACCES, errno, EXIT1);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_692
+* -@tspec The function test for fallocate
+* -@ttitle Fallocate apply space while the file is O_RDONLY
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one file;
+2. use the function fallocate to apply the space while the file is O_RDONLY;
+3. compare the file size before and after fallocate;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat692(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_692", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_693.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_693.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cbee6356b85bc9d0c94482225eaf1b0aee59c66c
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_693.cpp
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 size = 0x4000000;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ struct statfs buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_WRONLY, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = fallocate(fd, FAT_FALLOCATE_KEEP_SIZE, 0, size);
+ if (FAT_FILE_SYSTEMTYPE_AUTO == FAT_FILE_SYSTEMTYPE_EXFAT) {
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EPERM, errno, EXIT1);
+ } else {
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatfsPrintf(buf1);
+
+ ret = stat(pathname1, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf2);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_693
+* -@tspec The function test for fallocate
+* -@ttitle Fallocate apply space while the file is O_WRONLY
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to open one file;
+2. use the function fallocate to apply the space while the file is O_WRONLY;
+3. compare the file size before and after fallocate;
+4. close and remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat693(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_693", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_694.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_694.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3f8d31e0db2afee7555825f71c267cf536212b6b
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_694.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT1);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = ftruncate(fd, 0x400);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
+
+ ret = ftruncate64(fd, 0x400);
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ close(fd);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_VFAT_694
+* -@tspec The API test for truncate
+* -@ttitle The API test for truncate with the fd has been closed for the first parameter
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. use the open to create one file;
+2. use the close to close the file;
+3. use the truncate to recover the space;
+4. remove the file.
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return failed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat694(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_694", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_870.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_870.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cf88c74fbabb1878671a2e38a4a26ce28437c758
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_870.cpp
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufWrite = NULL;
+ CHAR *bufWrite1 = NULL;
+ CHAR *bufWrite2 = NULL;
+ struct stat64 buf1 = { 0 };
+ struct stat64 buf2 = { 0 };
+
+ g_testCount = 0;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ bufWrite = (CHAR *)malloc(8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, 8 * BYTES_PER_MBYTES + 1, 0, 8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ ret = memset_s(bufWrite2, 16 * BYTES_PER_KBYTES, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+ ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT3);
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES, filebuf); // 16 * BYTES_PER_KBYTES = 16kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES, filebuf); // 16 * BYTES_PER_KBYTES = 16kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES, filebuf); // 16 * BYTES_PER_KBYTES = 16kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES, filebuf); // 16 * BYTES_PER_KBYTES = 16kb
+ }
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ }
+
+ for (i = 0; i < 4; i++) { // loop 4 times
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES, bufWrite1); // 8 * BYTES_PER_MBYTES = 8MB
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES, bufWrite1); // 8 * BYTES_PER_MBYTES = 8MB
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ g_testCount++;
+
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, "/031.txt");
+
+ g_fatFd = open64(g_fatPathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd, FAT_IS_ERROR, g_fatFd, EXIT2);
+
+ while (1) {
+ ret = write(g_fatFd, bufWrite, strlen(bufWrite));
+ if (ret <= 0) {
+ if (g_testCount < (4 * BYTES_PER_KBYTES / 8)) { // 4 * BYTES_PER_KBYTES MB/GB, 8MB per write
+ printf("The biggest file size is smaller than the 4GB");
+ goto EXIT2;
+ }
+ printf("The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB\n", g_testCount,
+ g_testCount * 8, // 8MB per write
+ (g_testCount * 8) * 1.0 / BYTES_PER_KBYTES); // BYTES_PER_KBYTES MB/GB, 8MB per write
+ break;
+ }
+ if (g_testCount >= 256 + 1) { // write more than 256 times for 4GB // write more than 256 times for 4GB
+ printf("The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB\n", g_testCount,
+ g_testCount * 8, // 8MB per write
+ (g_testCount * 8) * 1.0 / BYTES_PER_KBYTES); // BYTES_PER_KBYTES MB/GB, 8MB per write
+ break;
+ }
+ g_testCount++;
+ }
+
+ ret = stat64(g_fatPathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = fstat64(g_fatFd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_size, buf2.st_size, buf1.st_size, EXIT2);
+ ICUNIT_GOTO_EQUAL(buf1.st_blksize, buf2.st_blksize, buf1.st_blksize, EXIT2);
+ ICUNIT_GOTO_EQUAL(buf1.st_ino, buf2.st_ino, buf1.st_ino, EXIT2);
+ ICUNIT_GOTO_EQUAL(buf1.st_mode, buf2.st_mode, buf1.st_mode, EXIT2);
+ ICUNIT_GOTO_EQUAL(buf1.st_mtim.tv_nsec, buf2.st_mtim.tv_nsec, buf1.st_mtim.tv_nsec, EXIT2);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_size, (off64_t)g_testCount * 8 * BYTES_PER_MBYTES, // 8 mb per write
+ buf1.st_size, EXIT2);
+
+ free(bufWrite);
+
+ ret = close(g_fatFd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(g_fatPathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = remove(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ close(g_fatFd);
+EXIT0:
+ remove(g_fatPathname1);
+EXIT:
+ remove(pathname);
+ return FAT_NO_ERROR;
+}
+
+/* *
+ * @defgroup los_fsoperationbigfile æ“作超过2G大å°çš„æ–‡ä»¶
+ */
+
+/* *
+ * @ingroup los_fsoperationbigfile
+ * @par type: void
+ * API test
+ * @brief function æ“作超过2G大å°çš„æ–‡ä»¶
+ * @par description:write the file size to 2GB and function it
+ * @par precon: task moudle open
+ * @par step: see decription
+ * create 2GB file \n
+ * function this file
+ * @par expect: nothing
+ * create file successful \n
+ * operator it successful,return successed
+ * @par prior: void
+ */
+
+VOID ItFsFat870(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_870", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_872.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_872.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8aa86e8b5fb062c7c0671c6c461176736aa27020
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_872.cpp
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ off64_t ret1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR *bufWrite1 = nullptr;
+ CHAR *bufWrite2 = nullptr;
+
+ g_testCount = 0;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ bufWrite = (CHAR *)malloc(8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, 8 * BYTES_PER_MBYTES, 0, 8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // 16 * 4 * 256 = 16K
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ }
+
+ for (j = 0; j < 16; j++) { // 16 * 4 * 16K = 1M
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ }
+
+ for (i = 0; i < 4; i++) { // 4 * 2 * 1M = 8M
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES + 1, bufWrite1); // 8 * BYTES_PER_KBYTES = 8KB
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES + 1, bufWrite1); // 8 * BYTES_PER_KBYTES = 8KB
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ g_testCount++;
+
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, "/031.txt");
+
+ g_fatFfd = fopen64(g_fatPathname1, "w+");
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFfd, nullptr, g_fatFfd, EXIT2);
+
+ while (1) {
+ ret = fwrite(bufWrite, strlen(bufWrite), 1, g_fatFfd);
+ if (ret <= 0) {
+ if (g_testCount < (4 * BYTES_PER_KBYTES / 8)) { // 4 * BYTES_PER_KBYTES MB/GB, 8MB per write
+ printf("The biggest file size is smaller than the 4GB");
+ goto EXIT2;
+ }
+ printf("The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB\n", g_testCount,
+ g_testCount * 8, // 8MB per write
+ (g_testCount * 8) * 1.0 / BYTES_PER_KBYTES); // BYTES_PER_KBYTES MB/GB, 8MB per write
+ break;
+ }
+ if (g_testCount >= 256 + 1) { // write more than 256 times for 4GB
+ printf("The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB\n", g_testCount,
+ g_testCount * 8, // 8MB per write
+ (g_testCount * 8) * 1.0 / BYTES_PER_KBYTES); // BYTES_PER_KBYTES MB/GB, 8MB per write
+ break;
+ }
+ g_testCount++;
+ }
+
+ ret = fseeko64(g_fatFfd, -1, SEEK_END);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret1 = ftello64(g_fatFfd);
+ ICUNIT_GOTO_EQUAL(ret1, (off64_t)(g_testCount * 8 * BYTES_PER_MBYTES - 1), ret1, // 8 mb
+ EXIT2); // 8 * BYTES_PER_MBYTES = 8MB
+
+ ret = fseeko64(g_fatFfd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret1 = ftello64(g_fatFfd);
+ ICUNIT_GOTO_EQUAL(ret1, (off64_t)(g_testCount * 8 * BYTES_PER_MBYTES - 1), ret1, // 8 mb
+ EXIT2); // 8 * BYTES_PER_MBYTES = 8MB
+
+ ret = fseeko64(g_fatFfd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ ret1 = ftello64(g_fatFfd);
+ ICUNIT_GOTO_EQUAL(ret1, 0, ret1, EXIT2);
+
+ free(bufWrite);
+
+ ret = fclose(g_fatFfd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(g_fatPathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = remove(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ fclose(g_fatFfd);
+EXIT0:
+ remove(g_fatPathname1);
+EXIT:
+ remove(pathname);
+ return FAT_NO_ERROR;
+}
+
+/* *
+ * @ingroup los_fsoperationbigfile
+ * @par type: void
+ * API test
+ * @brief ftello64 æ“作超过2G大å°çš„æ–‡ä»¶
+ * @par description: write the file size to 2GB and ftello64 it
+ * @par precon: task moudle open
+ * @par step: see below
+ * create 2GB file \n
+ * ftello64 this file
+ * @par expect: see below
+ * create file successful \n
+ * operator it successful,return successed
+ * @par prior: nothing
+ */
+
+VOID ItFsFat872(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_872", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_873.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_873.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9592190e9b3b55ed8961ea3dd8c23ebfea709e6d
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_873.cpp
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR *bufWrite1 = nullptr;
+ CHAR *bufWrite2 = nullptr;
+
+ g_testCount = 0;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ bufWrite = (CHAR *)malloc(8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, 8 * BYTES_PER_MBYTES, 0, 8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // 16 * 4 * 256 = 16K
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ }
+
+ for (j = 0; j < 16; j++) { // 16 * 4 * 16K = 1M
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ }
+
+ for (i = 0; i < 4; i++) { // 4 * 2 * 1M = 8M
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES + 1, bufWrite1); // 8 * BYTES_PER_KBYTES = 8KB
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES + 1, bufWrite1); // 8 * BYTES_PER_KBYTES = 8KB
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ g_testCount++;
+
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, "/031.txt");
+
+ g_fatFfd = fopen64(g_fatPathname1, "w+");
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFfd, nullptr, g_fatFfd, EXIT2);
+
+ while (1) {
+ ret = fwrite(bufWrite, strlen(bufWrite), 1, g_fatFfd);
+ if (ret <= 0) {
+ if (g_testCount < (4 * BYTES_PER_KBYTES / 8)) { // 4 * BYTES_PER_KBYTES MB/GB, 8MB per write
+ printf("The biggest file size is smaller than the 4GB,count = :%d,%d", g_testCount, errno);
+ goto EXIT2;
+ }
+ printf("The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB\n", g_testCount,
+ g_testCount * 8, // 8MB per write
+ (g_testCount * 8) * 1.0 / BYTES_PER_KBYTES); // BYTES_PER_KBYTES MB/GB, 8MB per write
+ break;
+ }
+ if (g_testCount >= 256 + 1) { // write more than 256 times for 4GB
+ printf("The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB\n", g_testCount,
+ g_testCount * 8, // 8MB per write
+ (g_testCount * 8) * 1.0 / BYTES_PER_KBYTES); // BYTES_PER_KBYTES MB/GB, 8MB per write
+ break;
+ }
+ g_testCount++;
+ }
+
+ free(bufWrite);
+
+ ret = fclose(g_fatFfd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ g_fatFfd = fopen64(g_fatPathname1, "w+");
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFfd, nullptr, g_fatFfd, EXIT2);
+
+ ret = fclose(g_fatFfd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(g_fatPathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = remove(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ fclose(g_fatFfd);
+EXIT0:
+ remove(g_fatPathname1);
+EXIT:
+ remove(pathname);
+ return FAT_NO_ERROR;
+}
+
+/* *
+ * @ingroup los_fsoperationbigfile
+ * @par type: void
+ * API test
+ * @brief fopen64 æ“作超过2G大å°çš„æ–‡ä»¶
+ * @par description: write the file size to 2GB and fopen64 it
+ * @par precon: task moudle open
+ * @par step: see below
+ * create 2GB file \n
+ * fopen64 this file
+ * @par expect: see below
+ * create file successful \n
+ * operator it successful,return successed
+ * @par prior: nothing
+ */
+
+VOID ItFsFat873(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_873", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_874.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_874.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..506400a2f390378c571456b33b41c822612865b9
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_874.cpp
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 len;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufWrite = NULL;
+ CHAR *bufWrite1 = NULL;
+ CHAR *bufWrite2 = NULL;
+ CHAR *readbuf = NULL;
+
+ g_testCount = 0;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ bufWrite = (CHAR *)malloc(8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, 8 * BYTES_PER_MBYTES, 0, 8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // 16 * 4 * 256 = 16K
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ }
+
+ for (j = 0; j < 16; j++) { // 16 * 4 * 16K = 1M
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ }
+
+ for (i = 0; i < 4; i++) { // 4 * 2 * 1M = 8M
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES + 1, bufWrite1); // 8 * BYTES_PER_KBYTES = 8KB
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES + 1, bufWrite1); // 8 * BYTES_PER_KBYTES = 8KB
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ g_testCount++;
+
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, "/031.txt");
+
+ g_fatFd = open64(g_fatPathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd, FAT_IS_ERROR, g_fatFd, EXIT2);
+
+ while (1) {
+ ret = write(g_fatFd, bufWrite, strlen(bufWrite));
+ if (ret <= 0) {
+ if (g_testCount < (4 * BYTES_PER_KBYTES / 8)) { // 4 * BYTES_PER_KBYTES MB/GB, 8MB per write
+ printf("The biggest file size is smaller than the 4GB");
+ goto EXIT2;
+ }
+ printf("The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB\n", g_testCount,
+ g_testCount * 8, // 8MB per write
+ (g_testCount * 8) * 1.0 / BYTES_PER_KBYTES); // BYTES_PER_KBYTES MB/GB, 8MB per write
+ break;
+ }
+ if (g_testCount >= 256 + 1) { // write more than 256 times for 4GB
+ printf("The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB\n", g_testCount,
+ g_testCount * 8, // 8MB per write
+ (g_testCount * 8) * 1.0 / BYTES_PER_KBYTES); // BYTES_PER_KBYTES MB/GB, 8MB per write
+ break;
+ }
+ g_testCount++;
+ }
+
+ readbuf = (CHAR *)malloc(0xffff + 1);
+ ICUNIT_GOTO_NOT_EQUAL(readbuf, NULL, readbuf, EXIT2);
+ (void)memset_s(readbuf, 0xffff + 1, 0, 0xffff + 1);
+
+ len = pread64(g_fatFd, readbuf, 0xffff, 0);
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT2);
+
+ (void)memset_s(readbuf, 0xffff + 1, 0, 0xffff + 1);
+
+ len = pread64(g_fatFd, readbuf, 0xffff, 1000); // offset is 1000
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT2);
+
+ (void)memset_s(readbuf, 0xffff + 1, 0, 0xffff + 1);
+
+ len = pread64(g_fatFd, readbuf, 0xffff,
+ (off64_t)(g_testCount * 8 * // 8mb per write
+ BYTES_PER_MBYTES)); // 8M * 8 * BYTES_PER_MBYTES * times = file size, get to file end
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ free(readbuf);
+ free(bufWrite);
+
+ ret = close(g_fatFd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(g_fatPathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = remove(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(readbuf);
+ free(bufWrite);
+EXIT1:
+ close(g_fatFd);
+EXIT0:
+ remove(g_fatPathname1);
+EXIT:
+ remove(pathname);
+ return FAT_NO_ERROR;
+}
+
+/* *
+ * @ingroup los_fsoperationbigfile
+ * @par type: void
+ * API test
+ * @brief pread64 æ“作超过2G大å°çš„æ–‡ä»¶
+ * @par description: write the file size to 2GB and pread64 it
+ * @par precon: task moudle open
+ * @par step: see below
+ * create 2GB file \n
+ * pread64 this file
+ * @par expect: see below
+ * create file successful \n
+ * operator it successful,return successed
+ * @par prior: nothing
+ */
+
+VOID ItFsFat874(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_874", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_875.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_875.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1ebc04885d7a5441cbe3c79c889788d59e68c640
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_875.cpp
@@ -0,0 +1,197 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 len;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufWrite = NULL;
+ CHAR *bufWrite1 = NULL;
+ CHAR *bufWrite2 = NULL;
+ CHAR *writebuf = NULL;
+
+ g_testCount = 0;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ bufWrite = (CHAR *)malloc(8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, 8 * BYTES_PER_MBYTES, 0, 8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // 16 * 4 * 256 = 16K
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb // 16 * BYTES_PER_KBYTES = 16KB
+ }
+
+ for (j = 0; j < 16; j++) { // 16 * 4 * 16K = 1M
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2); // BYTES_PER_MBYTES = 1MB
+ }
+
+ for (i = 0; i < 4; i++) { // 4 * 2 * 1M = 8M
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES + 1, bufWrite1); // 8 * BYTES_PER_KBYTES = 8KB
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES + 1, bufWrite1); // 8 * BYTES_PER_KBYTES = 8KB
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ g_testCount++;
+
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, "/031.txt");
+
+ g_fatFd = open64(g_fatPathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd, FAT_IS_ERROR, g_fatFd, EXIT2);
+
+ while (1) {
+ ret = write(g_fatFd, bufWrite, strlen(bufWrite));
+ if (ret <= 0) {
+ if (g_testCount < (4 * BYTES_PER_KBYTES / 8)) { // 4 * BYTES_PER_KBYTES MB/GB, 8MB per write
+ printf("The biggest file size is smaller than the 4GB");
+ goto EXIT2;
+ }
+ printf("The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB\n", g_testCount,
+ g_testCount * 8, // 8MB per write
+ (g_testCount * 8) * 1.0 / BYTES_PER_KBYTES); // BYTES_PER_KBYTES MB/GB, 8MB per write
+ break;
+ }
+ if (g_testCount >= 256 + 1) { // write more than 256 times for 4GB
+ printf("The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB\n", g_testCount,
+ g_testCount * 8, // 8MB per write
+ (g_testCount * 8) * 1.0 / BYTES_PER_KBYTES); // BYTES_PER_KBYTES MB/GB, 8MB per write
+ break;
+ }
+ g_testCount++;
+ }
+
+ writebuf = (CHAR *)malloc(0xffff + 1);
+ ICUNIT_GOTO_NOT_EQUAL(writebuf, NULL, writebuf, EXIT2);
+ (void)memset_s(writebuf, 0xffff + 1, 0, 0xffff + 1);
+
+ for (i = 0; i < 256; i++) { // loop 256 times
+ (void)strcat_s(writebuf, 0xffff + 1, filebuf);
+ }
+ writebuf[0xffff] = '\0';
+
+ len = pwrite64(g_fatFd, writebuf, 0xffff, 0);
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT2);
+
+ len = pwrite64(g_fatFd, writebuf, 0xffff, 10000); // offset = 10000
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT2);
+
+ len = pwrite64(g_fatFd, writebuf, 0xffff,
+ (off64_t)(g_testCount * 8 * BYTES_PER_MBYTES - 1)); // 8M * 8 * BYTES_PER_MBYTES * times to get to file end
+ ICUNIT_GOTO_EQUAL(len, 0xffff, len, EXIT2);
+
+ free(writebuf);
+ free(bufWrite);
+
+ ret = close(g_fatFd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = remove(g_fatPathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = remove(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(writebuf);
+ free(bufWrite);
+EXIT1:
+ close(g_fatFd);
+EXIT0:
+ remove(g_fatPathname1);
+EXIT:
+ remove(pathname);
+ return FAT_NO_ERROR;
+}
+
+/* *
+ * @ingroup los_fsoperationbigfile
+ * @par type: void
+ * API test
+ * @brief pwrite64 æ“作超过2G大å°çš„æ–‡ä»¶
+ * @par description: write the file size to 2GB and pwrite64 it
+ * @par precon: task moudle open
+ * @par step: see below
+ * create 2GB file \n
+ * pwrite64 this file
+ * @par expect: see below
+ * create file successful \n
+ * operator it successful,return successed
+ * @par prior: nothing
+ */
+
+VOID ItFsFat875(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_875", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_902.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_902.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..407f71b18789e04ec7bd745666d7374c43dd8b6d
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_902.cpp
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ struct stat64 buf1 = { 0 };
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = format(FAT_DEV_PATH, 8, 2); // cluster size 8 fstype is 2 FAT32
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = stat64(pathname1, &buf1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT1);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat64(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/dir");
+
+ ret = stat64(pathname1, &buf1);
+ ICUNIT_GOTO_NOT_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ ICUNIT_GOTO_EQUAL(errno, ENOENT, errno, EXIT2);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ rmdir(pathname1);
+EXIT1:
+ rmdir(FAT_PATH_NAME);
+EXIT:
+ mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+EXIT0:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat902(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_902", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_903.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_903.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c8e2c5505842238aed62ece52268c43f7e53cbd8
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_903.cpp
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR buffile[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ struct stat64 buf1 = { 0 };
+ struct stat64 buf2 = { 0 };
+ struct stat64 buf3 = { 0 };
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/dir");
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(buffile, FAT_STANDARD_NAME_LENGTH, "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT);
+
+ ret = stat64(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = fstat64(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = stat64(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_size, buf2.st_size, buf1.st_size, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_blksize, buf2.st_blksize, buf1.st_blksize, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_ino, buf2.st_ino, buf1.st_ino, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_mode, buf2.st_mode, buf1.st_mode, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_mtim.tv_nsec, buf2.st_mtim.tv_nsec, buf1.st_mtim.tv_nsec, EXIT);
+
+ FatDeleteFile(fd, buffile);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ format(FAT_DEV_PATH, 8, 0); // cluster size 8, 0 for auto
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFat903(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_903", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_904.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_904.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e3cc1716afae1a198bf1bcbe8c58f20531bcb483
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_904.cpp
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = 0;
+ INT32 ret;
+ INT32 len;
+ INT32 fd1 = 0;
+ INT32 fd2 = 0;
+ INT32 fd3 = 0;
+ CHAR filebuf[20] = "abcdeabcde";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ struct stat buf1 = { 0 };
+
+ ret = chdir("/");
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT0);
+
+ ret = format(FAT_DEV_PATH, 0, 2); // cluster size 0, 2 for FAT32, will fail
+ if (ret != 0) {
+ perror("format sd card");
+ }
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "test1");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT);
+
+ ret = fallocate(fd, 1, 0, 1 << 10); // fallocate 1 << 10 for 1KB
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, FAT_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ close(fd);
+
+ fd = open(pathname1, O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT);
+
+ ret = fallocate(fd, 1, 0, 1 << 20); // fallocate 1 << 20 for 1MB
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, FAT_SHORT_ARRAY_LENGTH, len, EXIT);
+
+ ret = ftruncate(fd, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "test2");
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, FAT_IS_ERROR, fd1, EXIT2);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, FAT_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ ret = ftruncate(fd1, 1 << 20); // ftruncate 1 << 20 to 1MB
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf1);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "test3");
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, FAT_IS_ERROR, fd2, EXIT1);
+
+ ret = fallocate(fd2, 1, 0, 10); // fallocate to 10 bytes
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate(fd2, 1, 0, 10); // fallocate to 10 bytes
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate(fd2, 1, 10, 20); // fallocate to 10 + 20 bytes
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "test4");
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, FAT_IS_ERROR, fd1, EXIT3);
+
+ ret = ftruncate(fd3, 1 << 20); // ftruncate 1 << 20 for 1MB
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ FatStatPrintf(buf1);
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT_REMOVE);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT_REMOVE);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT_REMOVE);
+
+ ret = format(FAT_DEV_PATH, 0, 2); // cluster size 0, 2 for FAT32
+ if (ret != 0) {
+ perror("format sd card");
+ }
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT_MOUNT_REMOVE);
+
+ (void)strncpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_PATH_NAME, sizeof(FAT_PATH_NAME));
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "test1");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT);
+
+ ret = fallocate(fd, 1, 0, 1 << 10); // fallocate 1 << 10 for 1KB
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, FAT_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ close(fd);
+
+ fd = open(pathname1, O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT);
+
+ ret = fallocate64(fd, 1, 0, 1 << 20); // fallocate 1 << 20 for 1MB
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, FAT_SHORT_ARRAY_LENGTH, len, EXIT);
+
+ ret = ftruncate64(fd, 0xffff);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "test2");
+ fd1 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, FAT_IS_ERROR, fd1, EXIT2);
+
+ len = write(fd1, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, FAT_SHORT_ARRAY_LENGTH, len, EXIT1);
+
+ ret = ftruncate64(fd1, 1 << 20); // ftruncate 1 << 20 for 1MB
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(buf1);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "test3");
+ fd2 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd2, FAT_IS_ERROR, fd2, EXIT1);
+
+ ret = fallocate64(fd2, 1, 0, 10); // fallocate 10 bytes
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd2, 1, 0, 10); // fallocate 10 bytes
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = fallocate64(fd2, 1, 10, 20); // fallocate 10 + 20 bytes
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "test4");
+ fd3 = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd1, FAT_IS_ERROR, fd1, EXIT3);
+
+ ret = ftruncate64(fd3, 1 << 20); // fallocate 1 << 20 for 1MB
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ FatStatPrintf(buf1);
+ ret = close(fd3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = close(fd2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT_REMOVE);
+
+ ret = remove(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT_REMOVE);
+
+ return FAT_NO_ERROR;
+
+EXIT3:
+ close(fd3);
+EXIT1:
+ close(fd2);
+EXIT2:
+ close(fd1);
+EXIT:
+ close(fd);
+EXIT_REMOVE:
+ remove(pathname1);
+
+ return FAT_NO_ERROR;
+
+EXIT_MOUNT_REMOVE:
+ mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ remove(pathname1);
+EXIT0:
+ return FAT_NO_ERROR;
+}
+VOID ItFsFat904(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_904", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/full/It_vfs_fat_909.cpp b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_909.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bba7944b728b441a7ea2d79e25a9b6793f47d000
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/full/It_vfs_fat_909.cpp
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 i, j, k, ret, len;
+ INT32 fd = -1;
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ off_t off;
+ CHAR readbuf[2000] = "";
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ struct stat buf1 = { 0 };
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT_MOUNT);
+
+ ret = format(FAT_DEV_PATH, 0, 0x02);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT_MOUNT);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT_MOUNT);
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0,
+ BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // 1M * BYTES_PER_KBYTES * 4 = 4GB
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname, FAT_STANDARD_NAME_LENGTH, "testfile.txt");
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT2);
+
+ for (j = 0; j < 100; j++) { // д100M
+ ret = write(fd, bufWrite, strlen(bufWrite));
+ printf("\n write times = : %d\n", j + 1); // j+1µÈÓÚ10×óÓÒʱ£¬²å°ÎSD¿¨
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTES, ret, EXIT2); // not equal to 1M
+
+ off = lseek(fd, 0, SEEK_CUR);
+ ICUNIT_GOTO_EQUAL(off, (BYTES_PER_MBYTES * (j + 1)), off, EXIT2); // from 1M to 4G
+ }
+
+ off = lseek(fd, 64, SEEK_SET); // 64 byte
+ ICUNIT_GOTO_EQUAL(off, 64, off, EXIT2); // 64 byte
+
+ for (k = 0; k < 500; k++) { // ¶Á500´Î
+ len = read(fd, readbuf, BYTES_PER_KBYTES); // read BYTES_PER_KBYTES bytes
+ printf("\n read times = : %d\n", k + 1);
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_KBYTES, len, EXIT2); // make sure BYTES_PER_KBYTES bytes
+ }
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = stat(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ free(bufWrite);
+
+ return FAT_NO_ERROR;
+
+ free(bufWrite);
+EXIT2:
+ close(fd);
+EXIT1:
+ unlink(pathname);
+EXIT:
+ rmdir(pathname1);
+EXIT_MOUNT:
+ mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ free(bufWrite);
+EXIT0:
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_909
+* - @tspec function test
+* - @ttitle Insert and remove SD card during reading and writing
+* - @tbrief
+1. Create a new file and open it
+2. Unplug the SD card when writing 10M
+3. View serial port printing status and file status.
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFat909(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_909", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL2, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_001.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..df39c559e8b18794b3d3068f0641f777666378c5
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_001.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[FAT_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm stTime;
+
+ g_testCount++;
+
+ time(&tTime);
+ localtime_r(&tTime, &stTime);
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ strftime(g_fatPathname1, FAT_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", &stTime);
+ (void)snprintf_s(fileName, FAT_STANDARD_NAME_LENGTH - 1, FAT_STANDARD_NAME_LENGTH - 1, "/vs/sd/%s_#%d",
+ g_fatPathname1, (INT32)arg);
+
+ (void)snprintf_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH - 1, "testfile#%d", (INT32)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_fatPathname1, 0, 0, 0);
+
+ ret = RandWrite(fileName, FILE_SIZE, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = RandRead(fileName, FILE_SIZE, 0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ return FAT_NO_ERROR;
+
+EXIT:
+ return FAT_NO_ERROR;
+ g_testCount = 0;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ pthread_t threadId = 0;
+ pthread_attr_t attr;
+
+ g_testCount = 0;
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadInit(&attr, 4); // level 4
+ ICUNIT_ASSERT_EQUAL(ret, FAT_NO_ERROR, ret);
+
+ ret = pthread_create(&threadId, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, FAT_NO_ERROR, ret);
+
+ while (g_testCount < 2) { // each thread add 2 at g_testCount
+ sleep(1);
+ }
+
+ ret = pthread_join(threadId, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ pthread_join(threadId, NULL);
+ pthread_attr_destroy(&attr);
+EXIT0:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPerformance001(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_001", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_002.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a8e98970b0dc61eeec64bb89214402eb940de0d5
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_002.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[FAT_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm stTime;
+
+ g_testCount++;
+
+ time(&tTime);
+ localtime_r(&tTime, &stTime);
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ strftime(g_fatPathname1, FAT_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", &stTime);
+ (void)snprintf_s(fileName, FAT_STANDARD_NAME_LENGTH - 1, FAT_STANDARD_NAME_LENGTH - 1, "/vs/sd/%s_#%d",
+ g_fatPathname1, (INT32)arg);
+
+ (void)snprintf_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH - 1, "testfile#%d", (INT32)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_fatPathname1, 0, 0, 0);
+
+ ret = FixWrite(fileName, FILE_SIZE, FIX_DATA_LEN, INTERFACE_TYPE);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = FixRead(fileName, FILE_SIZE, FIX_DATA_LEN, INTERFACE_TYPE);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ return FAT_NO_ERROR;
+
+EXIT:
+ return FAT_NO_ERROR;
+ g_testCount = 0;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ pthread_t threadId = 0;
+ pthread_attr_t attr;
+
+ printf("Single-Task frite and fread ,The test for SD is started!\n");
+
+ g_testCount = 0;
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadInit(&attr, 4); // level 4
+ ICUNIT_ASSERT_EQUAL(ret, FAT_NO_ERROR, ret);
+
+ ret = pthread_create(&threadId, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, FAT_NO_ERROR, ret);
+
+ while (g_testCount < 2) { // each thread add 2 at g_testCount
+ sleep(1);
+ }
+
+ ret = pthread_join(threadId, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ pthread_join(threadId, NULL);
+ pthread_attr_destroy(&attr);
+EXIT0:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPerformance002(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_002", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_003.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c76607b66ea7c09f39576ed66622d830c1258b1f
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_003.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[FAT_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm stTime;
+
+ g_testCount++;
+
+ time(&tTime);
+ localtime_r(&tTime, &stTime);
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ strftime(g_fatPathname1, FAT_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", &stTime);
+ (void)snprintf_s(fileName, FAT_STANDARD_NAME_LENGTH - 1, FAT_STANDARD_NAME_LENGTH - 1, "/vs/sd/%s_#%d",
+ g_fatPathname1, (INT32)arg);
+
+ (void)snprintf_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH - 1, "testfile#%d", (INT32)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_fatPathname1, 0, 0, 0);
+
+ ret = RandWrite(fileName, FILE_SIZE, 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = RandRead(fileName, FILE_SIZE, 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ return FAT_NO_ERROR;
+
+EXIT:
+ return FAT_NO_ERROR;
+ g_testCount = 0;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ pthread_t threadId;
+ pthread_attr_t attr;
+
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr, 4); // level 4
+ ICUNIT_ASSERT_EQUAL(ret, FAT_NO_ERROR, ret);
+
+ ret = pthread_create(&threadId, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, FAT_NO_ERROR, ret);
+
+ while (g_testCount < 2) { // each thread add 2 at g_testCount
+ sleep(1);
+ }
+
+ ret = pthread_join(threadId, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ pthread_join(threadId, NULL);
+ pthread_attr_destroy(&attr);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPerformance003(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_003", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_004.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8ff62c2475788108f5912b1c327302b87d2a950d
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_004.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[FAT_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm stTime;
+
+ g_testCount++;
+
+ time(&tTime);
+ localtime_r(&tTime, &stTime);
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ strftime(g_fatPathname1, FAT_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", &stTime);
+ (void)snprintf_s(fileName, FAT_STANDARD_NAME_LENGTH - 1, FAT_STANDARD_NAME_LENGTH - 1, "/vs/sd/%s_#%d",
+ g_fatPathname1, (INT32)arg);
+
+ (void)snprintf_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH - 1, "testfile#%d", (INT32)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_fatPathname1, 0, 0, 0);
+
+ ret = FixWrite(fileName, FILE_SIZE, FIX_DATA_LEN, 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = FixRead(fileName, FILE_SIZE, FIX_DATA_LEN, 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ return FAT_NO_ERROR;
+
+EXIT:
+ return FAT_NO_ERROR;
+ g_testCount = 0;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ pthread_t threadId;
+ pthread_attr_t attr;
+
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr, 4); // level 4
+ ICUNIT_ASSERT_EQUAL(ret, FAT_NO_ERROR, ret);
+
+ ret = pthread_create(&threadId, &attr, PthreadF01, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, FAT_NO_ERROR, ret);
+
+ while (g_testCount < 2) { // each thread add 2 at g_testCount
+ sleep(1);
+ }
+
+ ret = pthread_join(threadId, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ pthread_join(threadId, NULL);
+ pthread_attr_destroy(&attr);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPerformance004(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_004", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_005.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..be41285510f599b4d1903426f42bb89d54b54a69
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_005.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[FAT_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm stTime;
+
+ g_testCount++;
+
+ time(&tTime);
+ localtime_r(&tTime, &stTime);
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ strftime(g_fatPathname1, FAT_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", &stTime);
+ (void)snprintf_s(fileName, FAT_STANDARD_NAME_LENGTH - 1, FAT_STANDARD_NAME_LENGTH - 1, "/vs/sd/%s_#%d",
+ g_fatPathname1, (INT32)arg);
+
+ (void)snprintf_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH - 1, "testfile#%d", (INT32)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_fatPathname1, 0, 0, 0);
+
+ ret = FixWrite(fileName, FILE_SIZE, FIX_DATA_LEN, INTERFACE_TYPE);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = FixRead(fileName, FILE_SIZE, FIX_DATA_LEN, INTERFACE_TYPE);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ return FAT_NO_ERROR;
+
+EXIT:
+ return FAT_NO_ERROR;
+ g_testCount = 0;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_t threadId[FAT_MAX_THREADS];
+ pthread_attr_t attr;
+
+ printf("Multiple-Task frite and fread ,The test for SD is started!\n");
+
+ g_testCount = 0;
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadInit(&attr, 4); // level 4
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_create(&threadId[i], &attr, PthreadF01, (void *)(i + 1));
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ while (g_testCount < FAT_MAX_THREADS * 2) { // each thread add 2 at g_testCount
+ sleep(1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+EXIT:
+ pthread_attr_destroy(&attr);
+EXIT0:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPerformance005(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_005", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_006.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..355897d5970f35e57530ebdf9e5736b1cc8dee8b
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_006.cpp
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[FAT_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm stTime;
+
+ g_testCount++;
+
+ time(&tTime);
+ localtime_r(&tTime, &stTime);
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ strftime(g_fatPathname1, FAT_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", &stTime);
+ (void)snprintf_s(fileName, FAT_STANDARD_NAME_LENGTH - 1, FAT_STANDARD_NAME_LENGTH - 1, "/vs/sd/%s_#%d",
+ g_fatPathname1, (INT32)arg);
+
+ (void)snprintf_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH - 1, "testfile#%d", (INT32)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_fatPathname1, 0, 0, 0);
+
+ ret = RandWrite(fileName, FILE_SIZE, INTERFACE_TYPE);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = RandRead(fileName, FILE_SIZE, INTERFACE_TYPE);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ return FAT_NO_ERROR;
+
+EXIT:
+ return FAT_NO_ERROR;
+ g_testCount = 0;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_t threadId[3];
+ pthread_attr_t attr;
+
+ g_testCount = 0;
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadInit(&attr, 4); // level 4
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < 3; i++) { // creat 3 threads
+ ret = pthread_create(&threadId[i], &attr, PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ while (g_testCount < 6) { // 6 threads each add 2 at g_testCount
+ sleep(1);
+ }
+
+ for (i = 0; i < 3; i++) { // join the 3 child threads
+ pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ for (i = 0; i < 3; i++) { // wait for 3 threads ok
+ pthread_join(threadId[i], NULL);
+ }
+EXIT:
+ pthread_attr_destroy(&attr);
+EXIT0:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPerformance006(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_006", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_007.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2d76c3d7bf80946e25cdfcd7c71a484832869343
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_007.cpp
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[FAT_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm stTime;
+
+ g_testCount++;
+
+ time(&tTime);
+ localtime_r(&tTime, &stTime);
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ strftime(g_fatPathname1, FAT_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", &stTime);
+ (void)snprintf_s(fileName, FAT_STANDARD_NAME_LENGTH - 1, FAT_STANDARD_NAME_LENGTH - 1, "/vs/sd/%s_#%d",
+ g_fatPathname1, (INT32)arg);
+
+ (void)snprintf_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH - 1, "testfile#%d", (INT32)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_fatPathname1, 0, 0, 0);
+
+ ret = RandWrite(fileName, FILE_SIZE, 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = RandRead(fileName, FILE_SIZE, 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ return FAT_NO_ERROR;
+
+EXIT:
+ return FAT_NO_ERROR;
+ g_testCount = 0;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_t threadId[3];
+ pthread_attr_t attr;
+
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr, 4); // level 4
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < 3; i++) { // create 3 child threads
+ ret = pthread_create(&threadId[i], &attr, PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ while (g_testCount < 6) { // 6 threads each add 2 at g_testCount
+ sleep(1);
+ }
+
+ for (i = 0; i < 3; i++) { // join 3 child thread
+ pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ for (i = 0; i < 3; i++) { // join all 3 child thread
+ pthread_join(threadId[i], NULL);
+ }
+EXIT:
+ pthread_attr_destroy(&attr);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPerformance007(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_007", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_008.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e3a7189c6bb66ac0b818331ba6ead98a4b0d5785
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_008.cpp
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ CHAR fileName[FAT_STANDARD_NAME_LENGTH] = "";
+ time_t tTime;
+ struct tm stTime;
+
+ g_testCount++;
+
+ time(&tTime);
+ localtime_r(&tTime, &stTime);
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ strftime(g_fatPathname1, FAT_STANDARD_NAME_LENGTH - 1, "%Y-%m-%d_%H.%M.%S", &stTime);
+ (void)snprintf_s(fileName, FAT_STANDARD_NAME_LENGTH - 1, FAT_STANDARD_NAME_LENGTH - 1, "/vs/sd/%s_#%d",
+ g_fatPathname1, (INT32)arg);
+
+ (void)snprintf_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH - 1, "testfile#%d", (INT32)arg);
+ prctl(PR_SET_NAME, (unsigned long)g_fatPathname1, 0, 0, 0);
+
+ ret = FixWrite(fileName, FILE_SIZE, FIX_DATA_LEN, 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = FixRead(fileName, FILE_SIZE, FIX_DATA_LEN, 1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ return FAT_NO_ERROR;
+
+EXIT:
+ return FAT_NO_ERROR;
+ g_testCount = 0;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_t threadId[3];
+ pthread_attr_t attr;
+
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr, 4); // level 4
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < 3; i++) { // create 3 child threads
+ ret = pthread_create(&threadId[i], &attr, PthreadF01, (void *)i);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ while (g_testCount < 6) { // 6 threads each add 2 at g_testCount
+ sleep(1);
+ }
+
+ for (i = 0; i < 3; i++) { // join all 3 child threads
+ pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ for (i = 0; i < 3; i++) { // join all 3 child threads
+ pthread_join(threadId[i], NULL);
+ }
+EXIT:
+ pthread_attr_destroy(&attr);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPerformance008(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_008", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_013.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_013.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ed82e423343259d9c684acb302db2d5f379e552d
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_013.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i, index, len;
+ INT32 fd[FAT_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR pathname0[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname0[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ DIR *dir = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB // 1M
+ ICUNIT_ASSERT_NOT_EQUAL(bufWrite, NULL, bufWrite);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB // 1M
+
+ for (i = 0; i < 200 * 4; i++) { // append 200 * 4 times to 1M
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ ret = mkdir(pathname0, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(pathname0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ index = 0;
+ for (i = 0; i < FAT_FILE_LIMITTED_NUM; i++) {
+ (void)snprintf_s(bufname0, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt",
+ index);
+ fd[index] = open(bufname0, O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd[index], FAT_IS_ERROR, fd[index], EXIT2);
+
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ index++;
+ }
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(bufname0, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ ret = unlink(bufname0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ }
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ printf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + // US_PER_SEC
+ (testTime2.tv_usec - testTime1.tv_usec));
+
+ free(bufWrite);
+ return FAT_NO_ERROR;
+EXIT3:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(bufname0, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ unlink(bufname0);
+ }
+EXIT2:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT1:
+ closedir(dir);
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ rmdir(FAT_PATH_NAME);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_PERFORMANCE_013
+* -@tspec The function test for filesystem
+* -@ttitle How long does it take to delete a directory
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. Create a directory with 200 files
+2.200Kb per file
+3.delete the file box directory
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFatPerformance013(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_013", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_014.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_014.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2b0276f1d207542777febf51c2b55ee9a0200c66
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_014.cpp
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+#define MS_NOSYNC 2
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i, len;
+ INT32 index = 0;
+ INT32 fd[FAT_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = NULL;
+ DIR *dir = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ umount(FAT_MOUNT_DIR);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, MS_NOSYNC, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT4);
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL(bufWrite, NULL, bufWrite);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < 200 * 4; i++) { // append 200 * 4 times to 1M
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = chdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ index = 0;
+ for (i = 0; i < FAT_FILE_LIMITTED_NUM; i++) {
+ (void)snprintf_s(bufname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt",
+ index);
+ fd[index] = open(bufname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd[index], FAT_IS_ERROR, fd[index], EXIT2);
+
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ index++;
+ }
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ sync();
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(bufname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ ret = unlink(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ }
+
+ ret = chdir(SD_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ printf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + // US_PER_SEC
+ (testTime2.tv_usec - testTime1.tv_usec));
+
+ free(bufWrite);
+ return FAT_NO_ERROR;
+EXIT4:
+ umount(FAT_MOUNT_DIR);
+EXIT3:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(bufname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ unlink(bufname1);
+ }
+EXIT2:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT1:
+ closedir(dir);
+EXIT:
+ chdir(SD_MOUNT_DIR);
+ rmdir(FAT_PATH_NAME);
+EXIT0:
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_PERFORMANCE_014
+* -@tspec The function test for filesystem
+* -@ttitle How long does it take to delete a directory
+* -@tprecon The filesystem module is open
+* -@tbrief
+1.The fourth parameter of mount is changed to MS_NOSYNC
+2.Create a directory with 200 files
+3.200Kb per file
+4.delete the file box directory
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFatPerformance014(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_014", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_015.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_015.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dcdda2d48fa7096fb5093711acc98ed66e0d8ff3
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_015.cpp
@@ -0,0 +1,393 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 fd[FAT_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < 4; i++) { // append 4 times to 1M
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < FAT_FILE_LIMITTED_NUM; i++) { // 200 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_NAME_LIMITTED_SIZE; j++) { // 300K
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ sync();
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ printf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + // US_PER_SEC
+ (testTime2.tv_usec - testTime1.tv_usec));
+
+ g_testCount++;
+ free(bufWrite);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+EXIT:
+ rmdir(bufname);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 fd[FAT_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < 4; i++) { // append 4 times to 1M
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < FAT_FILE_LIMITTED_NUM; i++) { // 200 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_NAME_LIMITTED_SIZE; j++) { // 300K
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f02 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ sync();
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ printf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + // US_PER_SEC
+ (testTime2.tv_usec - testTime1.tv_usec));
+ g_testCount++;
+ free(bufWrite);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+EXIT:
+ rmdir(bufname);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 fd[FAT_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < 4; i++) { // append 4 times to 1M
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < FAT_FILE_LIMITTED_NUM; i++) { // 200 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_NAME_LIMITTED_SIZE; j++) { // 300K
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // 3s
+ printf("pthread_f03 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ sync();
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ printf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + // US_PER_SEC
+ (testTime2.tv_usec - testTime1.tv_usec));
+
+ g_testCount++;
+ free(bufWrite);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+EXIT:
+ rmdir(bufname);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, NULL); // 2nd thread id
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there are 3 child threads
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_PERFORMANCE_015
+* - @tspec function test
+* - @ttitle Multi-threaded takes time to delete directory files
+* - @tbrief
+1. Create 200 files per directory;
+2. The size of each file is 300K;
+3. Call the gettimeofday() to get the time;
+4. Delete files and directories;
+5. Call the gettimeofday() to get the time and View the time of serial port printing.
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatPerformance015(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_015", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_016.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_016.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d47d8d662ed25962f902c346bcfc9894bd1234c5
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_performance_016.cpp
@@ -0,0 +1,383 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 fd[FAT_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < 4; i++) { // append 4 times to 1M
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < FAT_FILE_LIMITTED_NUM; i++) { // 200 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_NAME_LIMITTED_SIZE; j++) { // 300K
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ printf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + // US_PER_SEC
+ (testTime2.tv_usec - testTime1.tv_usec));
+
+ g_testCount++;
+ free(bufWrite);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ unlink(pathname);
+ }
+EXIT:
+ free(bufWrite);
+ rmdir(bufname);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 fd[FAT_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < 4; i++) { // append 4 times to 1M
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < FAT_FILE_LIMITTED_NUM; i++) { // 200 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_NAME_LIMITTED_SIZE; j++) { // 300K
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f02 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ printf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + // US_PER_SEC
+ (testTime2.tv_usec - testTime1.tv_usec));
+
+ g_testCount++;
+ free(bufWrite);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+EXIT:
+ free(bufWrite);
+ rmdir(bufname);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 fd[FAT_FILE_LIMITTED_NUM] = {};
+ INT32 flag = 0;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = NULL;
+ struct timeval testTime1;
+ struct timeval testTime2;
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < 4; i++) { // append 4 times to 1M
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ index = 0;
+ for (i = 0; i < FAT_FILE_LIMITTED_NUM; i++) { // 200 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_NAME_LIMITTED_SIZE; j++) { // 300K
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // 3s
+ printf("pthread_f03 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ gettimeofday(&testTime1, 0);
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ gettimeofday(&testTime2, 0);
+ printf("FF--%s:%d, time: %lld\n", __func__, __LINE__,
+ (testTime2.tv_sec - testTime1.tv_sec) * US_PER_SEC + // US_PER_SEC
+ (testTime2.tv_usec - testTime1.tv_usec));
+
+ g_testCount++;
+ free(bufWrite);
+
+ return NULL;
+EXIT2:
+ close(fd[index]);
+EXIT1:
+ for (; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+EXIT:
+ free(bufWrite);
+ rmdir(bufname);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // 2nd thread id
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // 3 threads
+
+ return FAT_NO_ERROR;
+EXIT3:
+ mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ goto EXIT;
+
+ chdir("/");
+ umount(FAT_MOUNT_DIR);
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_PERFORMANCE_016
+* - @tspec function test
+* - @ttitle Multi-threaded takes time to delete directory files
+* - @tbrief
+1. Create 200 files per directory;
+2. The size of each file is 300K;
+3. Call the gettimeofday() to get the time;
+4. Delete files and directories;
+5. Call the gettimeofday() to get the time and View the time of serial port printing.
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatPerformance016(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PERFORMANCE_016", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PERFORMANCE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_029.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_029.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..499ae86b72a800f2d75a59353ca60e2bff50040c
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_029.cpp
@@ -0,0 +1,305 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ INT32 i = 0;
+ INT32 k;
+ off_t off;
+ CHAR bufname[FAT_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+ g_fatFlagF01++;
+
+ for (i = 0; i < FAT_MAXIMUM_SIZES; i++) {
+ (void)memset_s(g_fatPathname2, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ (void)memset_s(g_fatPathname12[i], FAT_STANDARD_NAME_LENGTH, 0, FAT_NAME_LIMITTED_SIZE);
+
+ (void)snprintf_s(bufname, FAT_SHORT_ARRAY_LENGTH, FAT_SHORT_ARRAY_LENGTH, "/test%d", i);
+ (void)strcat_s(g_fatPathname2, FAT_SHORT_ARRAY_LENGTH, pathname1);
+ (void)strcat_s(g_fatPathname2, FAT_SHORT_ARRAY_LENGTH, bufname);
+ (void)strcat_s(g_fatPathname2, FAT_SHORT_ARRAY_LENGTH, ".txt");
+ (void)strcpy_s(g_fatPathname12[i], FAT_SHORT_ARRAY_LENGTH, g_fatPathname2);
+ g_fatFd11[i] = open(g_fatPathname12[i], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd11[i], -1, g_fatFd11[i], EXIT1);
+
+ if (i % FAT_SHORT_ARRAY_LENGTH == 9) { // meet i = 9 close the fat fd
+ for (k = (i / FAT_SHORT_ARRAY_LENGTH) * FAT_SHORT_ARRAY_LENGTH; k <= i; k++) {
+ ret = close(g_fatFd11[k]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ }
+ }
+
+ ICUNIT_GOTO_NOT_EQUAL((g_testCount % 2), 0, g_testCount, EXIT1); // 2 for even or not
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < FAT_MAXIMUM_SIZES; i++) {
+ g_fatFd11[i] = open(g_fatPathname12[i], O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd11[i], -1, g_fatFd11[i], EXIT1);
+
+ off = lseek(g_fatFd11[i], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 1 * BYTES_PER_MBYTES, off, EXIT1); // 1 * BYTES_PER_MBYTES = 1M
+
+ if (i % FAT_SHORT_ARRAY_LENGTH == 9) { // meet i = 9 close the fat fd
+ for (k = (i / FAT_SHORT_ARRAY_LENGTH) * FAT_SHORT_ARRAY_LENGTH; k <= i; k++) {
+ ret = close(g_fatFd11[k]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+ }
+ }
+
+ for (i = 0; i < FAT_MAXIMUM_SIZES; i++) {
+ ret = unlink(g_fatPathname12[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_fatFlag++;
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ return NULL;
+EXIT1:
+ for (i = 0; i < FAT_MAXIMUM_SIZES; i++) {
+ close(g_fatFd11[i]);
+ }
+EXIT:
+ for (i = 0; i < FAT_MAXIMUM_SIZES; i++) {
+ unlink(g_fatPathname12[i]);
+ }
+ g_testCount = 0;
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret;
+ INT32 len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 k = 0;
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "liteos";
+ CHAR *bufWrite = nullptr;
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ bufWrite = (CHAR *)malloc(1 * BYTES_PER_MBYTES + 1); // 1 * BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < 1 * 32 * 4; i++) { // 4K * 2 * 32 * 4 = 1M
+ for (j = 0; j < 4; j++) { // 256 * 4 * 4 = 4K
+ (void)strcat_s(bufWrite, 1 * BYTES_PER_MBYTES + 1, filebuf);
+ (void)strcat_s(bufWrite, 1 * BYTES_PER_MBYTES + 1, filebuf);
+ (void)strcat_s(bufWrite, 1 * BYTES_PER_MBYTES + 1, filebuf);
+ (void)strcat_s(bufWrite, 1 * BYTES_PER_MBYTES + 1, filebuf);
+ }
+
+ for (j = 0; j < 4; j++) { // 256 * 4 * 4 = 4K
+ (void)strcat_s(bufWrite, 1 * BYTES_PER_MBYTES + 1, filebuf);
+ (void)strcat_s(bufWrite, 1 * BYTES_PER_MBYTES + 1, filebuf);
+ (void)strcat_s(bufWrite, 1 * BYTES_PER_MBYTES + 1, filebuf);
+ (void)strcat_s(bufWrite, 1 * BYTES_PER_MBYTES + 1, filebuf);
+ }
+ }
+
+ for (i = 0; i < FAT_MAXIMUM_SIZES; i++) {
+ g_fatFd11[i] = open(g_fatPathname12[i], O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd11[i], -1, g_fatFd11[i], EXIT2);
+
+ len = read(g_fatFd11[i], readbuf, FAT_STANDARD_NAME_LENGTH);
+ ICUNIT_GOTO_EQUAL(len, 0, len, EXIT2);
+
+ off = lseek(g_fatFd11[i], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT2);
+
+ len = write(g_fatFd11[i], bufWrite, strlen(bufWrite));
+ ICUNIT_GOTO_EQUAL(len, 1 * BYTES_PER_MBYTES, len, EXIT2); // BYTES_PER_MBYTES = 1MB
+
+ if (i % FAT_SHORT_ARRAY_LENGTH == 9) { // meet i = 9 close the fat fd
+ for (k = (i / FAT_SHORT_ARRAY_LENGTH) * FAT_SHORT_ARRAY_LENGTH; k <= i; k++) {
+ ret = close(g_fatFd11[k]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+ }
+ }
+
+ ICUNIT_GOTO_EQUAL((g_testCount % 2), 0, g_testCount, EXIT2); // 2 for even or not
+
+ free(bufWrite);
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(2); // delay 2 s
+
+ return NULL;
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ for (i = 0; i < FAT_MAXIMUM_SIZES; i++) {
+ close(g_fatFd11[i]);
+ }
+EXIT:
+ for (i = 0; i < FAT_MAXIMUM_SIZES; i++) {
+ unlink(g_fatPathname12[i]);
+ }
+ g_testCount = 0;
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ DIR *dir = nullptr;
+ struct dirent *ptr = nullptr;
+ pthread_t newThread1, newThread2;
+ pthread_attr_t attr1, attr2;
+
+ g_fatFlag = 0;
+ g_fatFlagF01 = 0;
+ g_fatFlagF02 = 0;
+
+ g_testCount = 0;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ while ((g_fatFlag < FAT_PRESSURE_CYCLES) && (g_fatFlag == g_fatFlagF01)) {
+ ret = PosixPthreadInit(&attr1, 20); // level 20
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newThread1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, 20); // level 20
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newThread2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(1);
+
+ ret = PosixPthreadDestroy(&attr2, newThread2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newThread1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ printf("\tg_fatFlag=:%d\t", g_fatFlag);
+ }
+ printf("\n");
+ ICUNIT_GOTO_EQUAL(g_fatFlag, FAT_PRESSURE_CYCLES, g_fatFlag, EXIT2);
+
+ dir = opendir(FAT_PATH_NAME);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newThread2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newThread1);
+EXIT:
+ rmdir(FAT_PATH_NAME);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_PRESSURE_029
+* -@tspec The Pressure test
+* -@ttitle Create, read ,write and delete the 1000 files
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create two tasks;
+2. the first task create 1000 files;
+3. the second task read ,write these files;
+4. delete all the directories;
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFatPressure029(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_029", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_030.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_030.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a366f118b34ad607a3d5cdfe6f542caaf4680653
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_030.cpp
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 len;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 fd = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR filebuf[258] = "abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = NULL;
+ CHAR *bufWrite1 = NULL;
+ CHAR *bufWrite2 = NULL;
+ struct stat buf1[FAT_PRESSURE_CYCLES][FAT_SHORT_ARRAY_LENGTH] = { 0 };
+
+ g_fatFlag = 0;
+
+ bufWrite = (CHAR *)malloc(5 * BYTES_PER_MBYTES + 1); // 5 * BYTES_PER_MBYTES = 5MB
+ ICUNIT_ASSERT_NOT_EQUAL(bufWrite, NULL, 0);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, 5 * BYTES_PER_MBYTES + 1); // 5 * BYTES_PER_MBYTES = 5MB
+
+ bufWrite1 = (CHAR *)malloc(256 * BYTES_PER_KBYTES + 1); // 256 * BYTES_PER_KBYTES = 256KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT);
+ (void)memset_s(bufWrite1, 256 * BYTES_PER_KBYTES + 1, 0, // 256 kb
+ 256 * BYTES_PER_KBYTES + 1); // 256 * BYTES_PER_KBYTES = 256KB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES, filebuf); // 16kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES, filebuf); // 16kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES, filebuf); // 16kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES, filebuf); // 16kb
+ }
+
+ for (i = 0; i < 4; i++) { // loop 4 times
+ (void)strcat_s(bufWrite1, 256 * BYTES_PER_KBYTES, bufWrite2); // 256kb
+ (void)strcat_s(bufWrite1, 256 * BYTES_PER_KBYTES, bufWrite2); // 256kb
+ (void)strcat_s(bufWrite1, 256 * BYTES_PER_KBYTES, bufWrite2); // 256kb
+ (void)strcat_s(bufWrite1, 256 * BYTES_PER_KBYTES, bufWrite2); // 256kb
+ }
+ for (i = 0; i < 5; i++) { // loop 5 times
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ }
+ free(bufWrite1);
+ free(bufWrite2);
+
+ for (i = 0; i < FAT_PRESSURE_CYCLES; i++) {
+ printf("Loop %d a\n", i + 1);
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ printf("Loop %d b\n", i + 1);
+
+ for (j = 0; j < 819; j++) { // loop 819 times
+ fd = open(pathname, O_NONBLOCK | O_RDWR | O_APPEND, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ len = write(fd, bufWrite, strlen(bufWrite));
+ ICUNIT_GOTO_EQUAL(len, 5 * BYTES_PER_MBYTES, len, EXIT); // 5 * BYTES_PER_MBYTES = 5MB
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ printf("Loop %d c\n", i + 1);
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ fd = open(pathname, O_NONBLOCK | O_RDWR | O_APPEND, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL(len, 256, len, EXIT); // should write 256 bytes
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ printf("Loop %d d\n", i + 1);
+
+ for (j = 0; j < 10; j++) { // loop 10 times
+ fd = open(pathname, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, -1, fd, EXIT);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = stat(pathname, &buf1[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ ret = remove(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_fatFlag++;
+
+ printf("\tg_fatFlag=:%d\t", g_fatFlag);
+ }
+
+ free(bufWrite);
+
+ return FAT_NO_ERROR;
+EXIT1:
+ free(bufWrite1);
+EXIT:
+ free(bufWrite);
+ close(fd);
+ remove(pathname);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_PRESSURE_030
+* -@tspec The Pressure test
+* -@ttitle write the file to 4GB
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create two tasks;
+2. the first task write the file to 4GB;
+3. the second task write one byte to the file once more;
+4. delete the files;
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return failure
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFatPressure030(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_030", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_031.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_031.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ef6cfbcda62a2160fce245df311e7650261a7079
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_031.cpp
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ INT32 len = 0;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR *bufWrite1 = nullptr;
+ CHAR *bufWrite2 = nullptr;
+ off64_t off64Num1, off64Num2;
+ struct stat64 statbuf1;
+
+ bufWrite = (CHAR *)malloc(8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, 8 * BYTES_PER_MBYTES + 1, 0, // 8 * BYTES_PER_MBYTES = 8MB
+ 8 * BYTES_PER_MBYTES + 1); // 8 * BYTES_PER_MBYTES = 8MB
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, filebuf);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, filebuf);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, filebuf);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, filebuf);
+ }
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ }
+
+ for (i = 0; i < 4; i++) { // loop 4 times
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES, bufWrite1); // 8 * BYTES_PER_MBYTES = 8MB
+ (void)strcat_s(bufWrite, 8 * BYTES_PER_MBYTES, bufWrite1); // 8 * BYTES_PER_MBYTES = 8MB
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ g_testCount++;
+ g_fatFlagF01++;
+
+ (void)memset_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(g_fatPathname1, FAT_STANDARD_NAME_LENGTH, "/031.txt");
+
+ g_fatFd = open64(g_fatPathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd, FAT_IS_ERROR, g_fatFd, EXIT2);
+
+ while (1) {
+ ret = write(g_fatFd, bufWrite, strlen(bufWrite));
+ if (ret <= 0) {
+ if (g_testCount < (4 * BYTES_PER_KBYTES / 8)) { // 8 MB per write, write 4 * BYTES_PER_KBYTES MB size
+ printf("The biggest file size is smaller than the 4GB");
+ goto EXIT;
+ }
+ printf("The cycle count = :%d,the file size = :%dMB,= :%0.3lfGB\n", g_testCount,
+ g_testCount * 8, // 8MB per write
+ (g_testCount * 8) * 1.0 / BYTES_PER_KBYTES); // 8 MB per write, BYTES_PER_KBYTES MB/GB
+ break;
+ }
+ g_testCount++;
+ }
+
+ ret = stat64(g_fatPathname1, &statbuf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ off64Num1 = lseek64(g_fatFd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off64Num1, statbuf1.st_size, off64Num1, EXIT2);
+
+ len = write(g_fatFd, bufWrite, strlen(bufWrite));
+ printf("len=:%d,errno=:%d\t", len, errno);
+
+ free(bufWrite);
+
+ off64Num2 = lseek64(g_fatFd, 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off64Num2, off64Num1, off64Num2, EXIT1);
+
+ ret = close(g_fatFd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ g_fatFlag++;
+
+ return NULL;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ close(g_fatFd);
+EXIT:
+ errno = 0;
+ ret = remove(g_fatPathname1);
+ g_testCount = 0;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, len, fd;
+ off64_t off64;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ DIR *dir = nullptr;
+ struct dirent *ptr = nullptr;
+ pthread_t newThread1;
+ pthread_attr_t attr1;
+ struct stat64 statbuf1;
+
+ g_fatFlag = 0;
+ g_fatFlagF01 = 0;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ while ((g_fatFlag < FAT_PRESSURE_CYCLES) && (g_fatFlag == g_fatFlagF01)) {
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr1, TASK_PRIO_TEST - 5); // level 5 lower
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newThread1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_join(newThread1, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_attr_destroy(&attr1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ fd = open64(g_fatPathname1, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT3);
+
+ ret = stat64(g_fatPathname1, &statbuf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ off64 = lseek64(fd, -FAT_SHORT_ARRAY_LENGTH, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off64, statbuf1.st_size - FAT_SHORT_ARRAY_LENGTH, off64, EXIT3);
+
+ (void)memset_s(readbuf, FAT_STANDARD_NAME_LENGTH, 0, FAT_STANDARD_NAME_LENGTH);
+ len = read(fd, readbuf, FAT_STANDARD_NAME_LENGTH - 1);
+ ICUNIT_GOTO_EQUAL(len, FAT_SHORT_ARRAY_LENGTH, len, EXIT3);
+ ICUNIT_GOTO_STRING_EQUAL(readbuf, "alalalalal", readbuf, EXIT3);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = remove(g_fatPathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = pthread_attr_destroy(&attr1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ printf("\tg_fatFlag=:%d\t", g_fatFlag);
+ }
+ printf("\n");
+ ICUNIT_GOTO_EQUAL(g_fatFlag, FAT_PRESSURE_CYCLES, g_fatFlag, EXIT2);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT2);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ close(fd);
+ remove(g_fatPathname1);
+ goto EXIT;
+EXIT2:
+ closedir(dir);
+ goto EXIT;
+EXIT1:
+ pthread_join(newThread1, NULL);
+ pthread_attr_destroy(&attr1);
+EXIT:
+ rmdir(FAT_PATH_NAME);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_PRESSURE_031
+* -@tspec The Pressure test
+* -@ttitle write the file to 4GB
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create two tasks;
+2. the first task write the file to 4GB;
+3. the second task write one byte to the file once more;
+4. delete the files;
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return failure
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFatPressure031(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_031", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_038.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_038.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..72a6dfa3ee2a72ab6a4705b3f0a2715cba2e2ae8
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_038.cpp
@@ -0,0 +1,388 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static CHAR g_fat1650Pathname4[FAT_SHORT_ARRAY_LENGTH][FAT_SHORT_ARRAY_LENGTH][FAT_NAME_LIMITTED_SIZE] = {0, };
+static CHAR g_fat1650Pathname5[FAT_SHORT_ARRAY_LENGTH][FAT_SHORT_ARRAY_LENGTH][FAT_NAME_LIMITTED_SIZE] = {0, };
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ INT32 len;
+ INT32 i = 0;
+ INT32 j = 0;
+ CHAR bufname[FAT_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR *bufRead = nullptr;
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)memset_s(g_fatPathname6, FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+ (void)strcat_s(g_fatPathname6, FAT_NAME_LIMITTED_SIZE, pathname1);
+
+ g_testCount++;
+ g_fatFlagF01++;
+
+ for (i = 0; i < FAT_SHORT_ARRAY_LENGTH; i++) {
+ (void)memset_s(bufname, FAT_SHORT_ARRAY_LENGTH, 0, FAT_SHORT_ARRAY_LENGTH);
+
+ (void)memset_s(g_fatPathname11[i], FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+
+ (void)snprintf_s(bufname, FAT_SHORT_ARRAY_LENGTH, FAT_SHORT_ARRAY_LENGTH, "/test%d", i);
+ (void)strcat_s(g_fatPathname6, FAT_NAME_LIMITTED_SIZE, bufname);
+ (void)strcpy_s(g_fatPathname11[i], FAT_NAME_LIMITTED_SIZE, g_fatPathname6);
+
+ ret = mkdir(g_fatPathname11[i], S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ for (j = 0; j < FAT_SHORT_ARRAY_LENGTH; j++) {
+ (void)memset_s(g_fatPathname7, FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+ (void)memset_s(bufname, FAT_SHORT_ARRAY_LENGTH, 0, strlen(bufname));
+ (void)memset_s(g_fat1650Pathname4[i][j], FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+ (void)memset_s(g_fat1650Pathname5[i][j], FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+
+ (void)snprintf_s(bufname, FAT_SHORT_ARRAY_LENGTH, FAT_SHORT_ARRAY_LENGTH, "/test%d", j);
+ (void)strcat_s(g_fatPathname7, FAT_NAME_LIMITTED_SIZE, g_fatPathname6);
+ (void)strcat_s(g_fatPathname7, FAT_NAME_LIMITTED_SIZE, bufname);
+ (void)strcat_s(g_fatPathname7, FAT_NAME_LIMITTED_SIZE, ".txt");
+ (void)strcpy_s(g_fat1650Pathname4[i][j], FAT_NAME_LIMITTED_SIZE, g_fatPathname7);
+
+ (void)memset_s(g_fatPathname7, FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+ (void)strcat_s(g_fatPathname7, FAT_NAME_LIMITTED_SIZE, g_fatPathname6);
+ (void)strcat_s(g_fatPathname7, FAT_NAME_LIMITTED_SIZE, bufname);
+ (void)strcat_s(g_fatPathname7, FAT_NAME_LIMITTED_SIZE, ".cpp");
+ (void)strcpy_s(g_fat1650Pathname5[i][j], FAT_NAME_LIMITTED_SIZE, g_fatPathname7);
+
+ g_fatFd12[i][j] =
+ open(g_fat1650Pathname4[i][j], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd12[i][j], -1, g_fatFd12[i][j], EXIT1);
+
+ ret = close(g_fatFd12[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+ }
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ bufRead = (CHAR *)malloc(10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+ ICUNIT_GOTO_NOT_EQUAL(bufRead, NULL, 0, EXIT1);
+ (void)memset_s(bufRead, 10 * BYTES_PER_MBYTES + 1, 0, 10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+
+ for (i = 0; i < 10; i++) { // loop 10 times
+ for (j = 0; j < 10; j++) { // loop 10 times
+ g_fatFd12[i][j] = open(g_fat1650Pathname4[i][j], O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd12[i][j], -1, g_fatFd12[i][j], EXIT2);
+
+ len = read(g_fatFd12[i][j], bufRead, 10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+ ICUNIT_GOTO_EQUAL(len, 10 * BYTES_PER_MBYTES, len, EXIT2); // 10 * BYTES_PER_MBYTES = 10MB
+
+ ret = close(g_fatFd12[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+ }
+
+ free(bufRead);
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_fatFlag++;
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ return NULL;
+EXIT2:
+ free(bufRead);
+EXIT1:
+ for (i = 0; i < 10; i++) { // loop 10 times
+ for (j = 0; j < 10; j++) { // loop 10 times
+ close(g_fatFd12[i][j]);
+ }
+ }
+EXIT:
+ for (i = 9; i >= 0; i--) { // loop 9 + 1 times
+ for (j = 9; j >= 0; j--) { // loop 9 + 1 times
+ remove(g_fat1650Pathname4[i][j]);
+ remove(g_fat1650Pathname5[i][j]);
+ }
+
+ remove(g_fatPathname11[i]);
+ }
+ g_testCount = 0;
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret;
+ INT32 i = 0;
+ INT32 j = 0;
+ INT32 len;
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+
+ CHAR *bufWrite = nullptr;
+ CHAR *bufWrite1 = nullptr;
+ CHAR *bufWrite2 = nullptr;
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ bufWrite = (CHAR *)malloc(10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, 10 * BYTES_PER_MBYTES + 1, 0, 10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+
+ bufWrite1 = (CHAR *)malloc(512 * BYTES_PER_KBYTES + 1); // 512 * BYTES_PER_KBYTES = 512KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, 512 * BYTES_PER_KBYTES + 1, 0, // 512 kb
+ 512 * BYTES_PER_KBYTES + 1); // 512 * BYTES_PER_KBYTES = 512KB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ }
+
+ for (j = 0; j < 8; j++) { // loop 8 times
+ (void)strcat_s(bufWrite1, 512 * BYTES_PER_KBYTES + 1, bufWrite2); // 512 kb
+ (void)strcat_s(bufWrite1, 512 * BYTES_PER_KBYTES + 1, bufWrite2); // 512 kb
+ (void)strcat_s(bufWrite1, 512 * BYTES_PER_KBYTES + 1, bufWrite2); // 512 kb
+ (void)strcat_s(bufWrite1, 512 * BYTES_PER_KBYTES + 1, bufWrite2); // 512 kb
+ }
+
+ for (i = 0; i < 10; i++) { // loop 10 times
+ (void)strcat_s(bufWrite, 10 * BYTES_PER_MBYTES, bufWrite1); // 10 * BYTES_PER_MBYTES = 10MB
+ (void)strcat_s(bufWrite, 10 * BYTES_PER_MBYTES, bufWrite1); // 10 * BYTES_PER_MBYTES = 10MB
+ }
+ free(bufWrite1);
+ free(bufWrite2);
+ for (i = 0; i < 10; i++) { // loop 10 times
+ for (j = 0; j < 10; j++) { // loop 10 times
+ g_fatFd12[i][j] = open(g_fat1650Pathname4[i][j], O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd12[i][j], -1, g_fatFd12[i][j], EXIT2);
+
+ len = write(g_fatFd12[i][j], bufWrite, strlen(bufWrite));
+ ICUNIT_GOTO_EQUAL(len, 10 * BYTES_PER_MBYTES, len, EXIT2); // 10 * BYTES_PER_MBYTES = 10MB
+
+ ret = close(g_fatFd12[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+ }
+ free(bufWrite);
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ for (i = 0; i < 10; i++) { // loop 10 times
+ for (j = 0; j < 10; j++) { // loop 10 times
+ ret = rename(g_fat1650Pathname4[i][j], g_fat1650Pathname5[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+ }
+ }
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ for (i = 9; i >= 0; i--) { // loop 9 + 1 times
+ for (j = 9; j >= 0; j--) { // loop 9 + 1 times
+ ret = remove(g_fat1650Pathname5[i][j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ ret = remove(g_fatPathname11[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ g_fatFlagF02++;
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(2); // delay 2 s
+
+ return NULL;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ for (i = 0; i < 10; i++) { // loop 10 times
+ for (j = 0; j < 10; j++) { // loop 10 times
+ close(g_fatFd12[i][j]);
+ }
+ }
+EXIT:
+ for (i = 9; i >= 0; i--) { // loop 9 + 1 times
+ for (j = 9; j >= 0; j--) { // loop 9 + 1 times
+ remove(g_fat1650Pathname4[i][j]);
+ remove(g_fat1650Pathname5[i][j]);
+ }
+ remove(g_fatPathname11[i]);
+ }
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+ g_testCount = 0;
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ DIR *dir = nullptr;
+ struct dirent *ptr = nullptr;
+ pthread_t newThread1, newThread2;
+ pthread_attr_t attr1, attr2;
+
+ g_fatFlag = 0;
+ g_fatFlagF01 = 0;
+ g_fatFlagF02 = 0;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ while ((g_fatFlag < FAT_PRESSURE_CYCLES) && (g_fatFlag == g_fatFlagF01)) {
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr1, 20); // level 20
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newThread1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, 20); // level 20
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newThread2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(FAT_SHORT_ARRAY_LENGTH);
+
+ ret = PosixPthreadDestroy(&attr2, newThread2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newThread1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ printf("\tg_fatFlag=:%d\t", g_fatFlag);
+ }
+ printf("\n");
+ ICUNIT_GOTO_EQUAL(g_fatFlag, FAT_PRESSURE_CYCLES, g_fatFlag, EXIT2);
+
+ dir = opendir(FAT_PATH_NAME);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newThread2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newThread1);
+EXIT:
+ rmdir(FAT_PATH_NAME);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_PRESSURE_038
+* -@tspec The Pressure test
+* -@ttitle Create the 10-level directory and create 10 subdirectories while creating the directory
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create two tasks;
+2. the first task create the 10-level directory ;
+3. the another task create 10 subdirectories while creating the directory;
+4. delete the directories and files;
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFatPressure038(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_038", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_040.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_040.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4c656a58dd75814fce6e9c19d218f2510ad30593
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_040.cpp
@@ -0,0 +1,417 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ INT32 j = 0;
+ CHAR bufname[FAT_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+ g_fatFlagF01++;
+ ret = format(FAT_DEV_PATH1, 0, 0);
+ ICUNIT_GOTO_NOT_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ (void)memset_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+ (void)memset_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+ (void)memset_s(g_fatPathname13[j], FAT_NAME_LIMITTED_SIZE, 0, FAT_STANDARD_NAME_LENGTH);
+ (void)memset_s(bufname, FAT_SHORT_ARRAY_LENGTH, 0, FAT_SHORT_ARRAY_LENGTH);
+ (void)snprintf_s(bufname, FAT_SHORT_ARRAY_LENGTH, FAT_SHORT_ARRAY_LENGTH, "/test%d", j);
+ (void)strcat_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, pathname);
+ (void)strcat_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, pathname);
+ (void)strcat_s(g_fatPathname13[j], FAT_NAME_LIMITTED_SIZE, pathname);
+
+ (void)strcat_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, bufname);
+ (void)strcat_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, bufname);
+ (void)strcat_s(g_fatPathname13[j], FAT_NAME_LIMITTED_SIZE, bufname);
+
+ (void)strcat_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, ".txt");
+ (void)strcat_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, ".cpp");
+ (void)strcat_s(g_fatPathname13[j], FAT_NAME_LIMITTED_SIZE, ".jpg");
+
+ g_fatFd11[j] = open(g_fatPathname11[j], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd11[j], -1, g_fatFd11[j], EXIT2);
+ }
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ off = lseek(g_fatFd11[0], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 100 * BYTES_PER_MBYTES, off, // 100mb
+ EXIT2);
+
+ off = lseek(g_fatFd11[1], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES, off, EXIT2); // BYTES_PER_MBYTES = 1MB
+
+ off = lseek(g_fatFd11[2], 0, SEEK_END); // the 2 nd fd
+ ICUNIT_GOTO_EQUAL(off, BYTES_PER_MBYTES, off, EXIT2); // BYTES_PER_MBYTES = 1MB
+
+ off = lseek(g_fatFd11[3], 0, SEEK_END); // fd 3
+ ICUNIT_GOTO_EQUAL(off, 256 * BYTES_PER_KBYTES, off, EXIT2); // 256 * BYTES_PER_KBYTES = 256KB
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ ret = close(g_fatFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+
+ for (j = 0; j < FAT_MOUNT_CYCLES_TEST; j++) {
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ }
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < FAT_MOUNT_CYCLES_TEST; j++) {
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ }
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ ret = access(g_fatPathname13[j], F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ }
+
+ g_fatFlag++;
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ return NULL;
+EXIT3:
+ mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+EXIT2:
+ for (j = 0; j < 4; j++) { // loop 4 times
+ close(g_fatFd11[j]);
+ }
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ remove(g_fatPathname11[j]);
+ remove(g_fatPathname12[j]);
+ remove(g_fatPathname13[j]);
+ }
+EXIT:
+ g_testCount = 0;
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret;
+ INT32 j = 0;
+ UINT64 len;
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufWrite1 = NULL;
+ CHAR *bufWrite2 = NULL;
+ CHAR *bufWrite3 = NULL;
+ CHAR *bufWrite4 = NULL;
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ bufWrite1 = (CHAR *)malloc(FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES + 1, 0,
+ FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite3 = (CHAR *)malloc(256 * BYTES_PER_KBYTES + 1); // 256 * BYTES_PER_KBYTES = 256KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite3, NULL, 0, EXIT4);
+ (void)memset_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, 0, 256 * BYTES_PER_KBYTES + 1); // 256 kb
+
+ bufWrite4 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite4, NULL, 0, EXIT5);
+ (void)memset_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ }
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ }
+
+ for (j = 0; j < 2; j++) { // loop 2 times
+ (void)strcat_s(bufWrite2, BYTES_PER_MBYTES + 1, bufWrite3);
+ (void)strcat_s(bufWrite2, BYTES_PER_MBYTES + 1, bufWrite3);
+ }
+
+ for (j = 0; j < 2; j++) { // loop 2 times
+ (void)strcat_s(bufWrite1, FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES + 1, bufWrite2);
+ }
+
+ free(bufWrite4);
+
+ g_testCount++;
+
+ for (j = 0; j < FAT_SHORT_ARRAY_LENGTH; j++) {
+ len = write(g_fatFd11[0], bufWrite1, strlen(bufWrite1));
+ ICUNIT_GOTO_EQUAL(len, FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES, len, EXIT5); // BYTES_PER_MBYTES = 1MB
+ }
+
+ len = write(g_fatFd11[1], bufWrite1, strlen(bufWrite1));
+ ICUNIT_GOTO_EQUAL(len, FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES, len, EXIT5); // BYTES_PER_MBYTES = 1MB
+
+ len = write(g_fatFd11[2], bufWrite2, strlen(bufWrite2)); // fd11 2
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_MBYTES, len, EXIT5);
+
+ len = write(g_fatFd11[3], bufWrite3, strlen(bufWrite3)); // fd 3
+ ICUNIT_GOTO_EQUAL(len, 256 * BYTES_PER_KBYTES, len, EXIT5); // 256 * BYTES_PER_KBYTES = 256KB
+
+ free(bufWrite1);
+ free(bufWrite2);
+ free(bufWrite3);
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ ret = rename(g_fatPathname11[j], g_fatPathname12[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ ret = rename(g_fatPathname12[j], g_fatPathname13[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(2); // delay 2 s
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ g_fatFd11[j] = open(g_fatPathname13[j], O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd11[j], -1, g_fatFd11[j], EXIT2);
+ }
+
+ off = lseek(g_fatFd11[0], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 100 * BYTES_PER_MBYTES, off, EXIT2); // BYTES_PER_MBYTES = 100 MB
+
+ off = lseek(g_fatFd11[1], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES, off, EXIT2); // BYTES_PER_MBYTES = 1MB
+
+ off = lseek(g_fatFd11[2], 0, SEEK_END); // the 2 nd fd
+ ICUNIT_GOTO_EQUAL(off, BYTES_PER_MBYTES, off, EXIT2); // BYTES_PER_MBYTES = 1MB
+
+ off = lseek(g_fatFd11[3], 0, SEEK_END); // fd 3
+ ICUNIT_GOTO_EQUAL(off, 256 * BYTES_PER_KBYTES, off, EXIT2); // 256 * BYTES_PER_KBYTES = 256KB
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ ret = close(g_fatFd11[j]);
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(g_fatPathname13[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ g_fatFlagF02++;
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(2); // delay 2 s
+
+ return NULL;
+EXIT5:
+ free(bufWrite3);
+EXIT4:
+ free(bufWrite1);
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ for (j = 0; j < 4; j++) { // loop 4 times
+ close(g_fatFd11[j]);
+ }
+EXIT1:
+ for (j = 0; j < 4; j++) { // loop 4 times
+ remove(g_fatPathname11[j]);
+ remove(g_fatPathname12[j]);
+ remove(g_fatPathname13[j]);
+ }
+
+ g_testCount = 0;
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newThread1, newThread2;
+ pthread_attr_t attr1, attr2;
+
+ g_fatFlag = 0;
+ g_fatFlagF01 = 0;
+ g_fatFlagF02 = 0;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ while ((g_fatFlag < FAT_PRESSURE_CYCLES) && (g_fatFlag == g_fatFlagF01)) {
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr1, TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newThread1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newThread2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(FAT_SHORT_ARRAY_LENGTH);
+
+ ret = PosixPthreadDestroy(&attr2, newThread2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newThread1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ printf("\tg_fatFlag=:%d\t", g_fatFlag);
+ }
+ printf("\n");
+ ICUNIT_GOTO_EQUAL(g_fatFlag, FAT_PRESSURE_CYCLES, g_fatFlag, EXIT2);
+
+ dir = opendir(FAT_PATH_NAME);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newThread2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newThread1);
+EXIT:
+ rmdir(FAT_PATH_NAME);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_PRESSURE_040
+* -@tspec The Pressure test
+* -@ttitle After the creation of four documents 1000 umount / mount 1,000 months after the renaming documents umount /
+mount
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create two tasks;
+2. the first task create 4 files ;
+3. the another task rename the files and mount/umount the filesysterm;
+4. delete the files;
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFatPressure040(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_040", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_041.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_041.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..21ff9f4c6a45ee38b0c29a9ed3ddec63e93f4413
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_041.cpp
@@ -0,0 +1,410 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ INT32 j = 0;
+ CHAR bufname[FAT_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "/vs/sd/fat_1655";
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+ g_fatFlagF01++;
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ (void)memset_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+ (void)memset_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+ (void)memset_s(bufname, FAT_SHORT_ARRAY_LENGTH, 0, FAT_SHORT_ARRAY_LENGTH);
+
+ (void)snprintf_s(bufname, FAT_SHORT_ARRAY_LENGTH, FAT_SHORT_ARRAY_LENGTH, "/test%d", j);
+ (void)strcat_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, pathname);
+ (void)strcat_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, pathname2);
+
+ (void)strcat_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, bufname);
+ (void)strcat_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, bufname);
+
+ (void)strcat_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, ".txt");
+ (void)strcat_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, ".txt");
+
+ g_fatFd11[j] = open(g_fatPathname11[j], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd11[j], -1, g_fatFd11[j], EXIT2);
+ }
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ off = lseek(g_fatFd11[0], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 100 * BYTES_PER_MBYTES, off, EXIT2); // BYTES_PER_MBYTES = 100 MB
+
+ off = lseek(g_fatFd11[1], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, FAT_SHORT_ARRAY_LENGTH * BYTES_PER_MBYTES, off, EXIT2); // BYTES_PER_MBYTES = 1MB
+
+ off = lseek(g_fatFd11[2], 0, SEEK_END); // the 2 nd fd
+ ICUNIT_GOTO_EQUAL(off, BYTES_PER_MBYTES, off, EXIT2); // BYTES_PER_MBYTES = 1MB
+
+ off = lseek(g_fatFd11[3], 0, SEEK_END); // fd 3
+ ICUNIT_GOTO_EQUAL(off, 256 * BYTES_PER_KBYTES, off, EXIT2); // 256 * BYTES_PER_KBYTES = 256KB
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ ret = close(g_fatFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+
+ for (j = 0; j < FAT_MAXIMUM_OPERATIONS; j++) {
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ }
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < FAT_MAXIMUM_OPERATIONS; j++) {
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ }
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ ret = access(g_fatPathname12[j], F_OK);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ }
+
+ g_fatFlag++;
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ return NULL;
+EXIT3:
+ mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+EXIT2:
+ for (j = 0; j < 4; j++) { // loop 4 times
+ close(g_fatFd11[j]);
+ }
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ remove(g_fatPathname11[j]);
+ remove(g_fatPathname12[j]);
+ }
+EXIT:
+ g_testCount = 0;
+ remove(pathname2);
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret;
+ INT32 j = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "/vs/sd/fat_1655";
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufWrite1 = NULL;
+ CHAR *bufWrite2 = NULL;
+ CHAR *bufWrite3 = NULL;
+ CHAR *bufWrite4 = NULL;
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ bufWrite1 = (CHAR *)malloc(10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, 10 * BYTES_PER_MBYTES + 1, 0, 10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+
+ bufWrite2 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite3 = (CHAR *)malloc(256 * BYTES_PER_KBYTES + 1); // 256 * BYTES_PER_KBYTES = 256KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite3, NULL, 0, EXIT4);
+ (void)memset_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, 0, 256 * BYTES_PER_KBYTES + 1); // 256 kb
+
+ bufWrite4 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite4, NULL, 0, EXIT5);
+ (void)memset_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ }
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ }
+
+ for (j = 0; j < 2; j++) { // loop 2 times
+ (void)strcat_s(bufWrite2, BYTES_PER_MBYTES + 1, bufWrite3);
+ (void)strcat_s(bufWrite2, BYTES_PER_MBYTES + 1, bufWrite3);
+ }
+
+ for (j = 0; j < 2; j++) { // loop 2 times
+ (void)strcat_s(bufWrite1, 10 * BYTES_PER_MBYTES + 1, bufWrite2); // 10 mb
+ (void)strcat_s(bufWrite1, 10 * BYTES_PER_MBYTES + 1, bufWrite2); // 10 mb
+ (void)strcat_s(bufWrite1, 10 * BYTES_PER_MBYTES + 1, bufWrite2); // 10 mb
+ (void)strcat_s(bufWrite1, 10 * BYTES_PER_MBYTES + 1, bufWrite2); // 10 mb
+ }
+
+ free(bufWrite4);
+
+ g_testCount++;
+
+ for (j = 0; j < 10; j++) { // loop 10 times
+ ret = write(g_fatFd11[0], bufWrite1, strlen(bufWrite1));
+ ICUNIT_GOTO_EQUAL(ret, 10 * BYTES_PER_MBYTES, ret, EXIT5); // 10 * BYTES_PER_MBYTES = 10MB
+ }
+
+ ret = write(g_fatFd11[1], bufWrite1, strlen(bufWrite1));
+ ICUNIT_GOTO_EQUAL(ret, 10 * BYTES_PER_MBYTES, ret, EXIT5); // 10 * BYTES_PER_MBYTES = 10MB
+
+ ret = write(g_fatFd11[2], bufWrite2, strlen(bufWrite2)); // fd 2
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTES, ret, EXIT5); // BYTES_PER_MBYTES = 1MB
+
+ ret = write(g_fatFd11[3], bufWrite3, strlen(bufWrite3)); // fd 3
+ ICUNIT_GOTO_EQUAL(ret, 256 * BYTES_PER_KBYTES, ret, EXIT5); // 256 * BYTES_PER_KBYTES = 256KB
+
+ free(bufWrite1);
+ free(bufWrite2);
+ free(bufWrite3);
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(2); // delay 2 s
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ g_fatFd11[j] = open(g_fatPathname12[j], O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd11[j], -1, g_fatFd11[j], EXIT2);
+ }
+
+ off = lseek(g_fatFd11[0], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 100 * BYTES_PER_MBYTES, off, EXIT2); // BYTES_PER_MBYTES = 100 MB
+
+ off = lseek(g_fatFd11[1], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10 * BYTES_PER_MBYTES, off, EXIT2); // 10 mb
+
+ off = lseek(g_fatFd11[2], 0, SEEK_END); // the 2 nd fd
+ ICUNIT_GOTO_EQUAL(off, BYTES_PER_MBYTES, off, EXIT2); // BYTES_PER_MBYTES = 1MB
+
+ off = lseek(g_fatFd11[3], 0, SEEK_END); // fd 3
+ ICUNIT_GOTO_EQUAL(off, 256 * BYTES_PER_KBYTES, off, EXIT2); // 256 * BYTES_PER_KBYTES = 256KB
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ ret = close(g_fatFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(g_fatPathname12[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+ ret = remove(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ g_fatFlagF02++;
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(2); // delay 2 s
+
+ return NULL;
+EXIT5:
+ free(bufWrite3);
+EXIT4:
+ free(bufWrite2);
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ for (j = 0; j < 4; j++) { // loop 4 times
+ close(g_fatFd11[j]);
+ }
+EXIT1:
+ for (j = 0; j < 4; j++) { // loop 4 times
+ remove(g_fatPathname11[j]);
+ remove(g_fatPathname12[j]);
+ }
+
+ g_testCount = 0;
+ remove(pathname2);
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ DIR *dir = nullptr;
+ struct dirent *ptr = nullptr;
+ pthread_t newThread1, newThread2;
+ pthread_attr_t attr1, attr2;
+
+ g_fatFlag = 0;
+ g_fatFlagF01 = 0;
+ g_fatFlagF02 = 0;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ while ((g_fatFlag < FAT_PRESSURE_CYCLES) && (g_fatFlag == g_fatFlagF01)) {
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr1, 20); // level 20
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newThread1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, 20); // level 20
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newThread2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ sleep(5); // sleep 5s
+
+ ret = PosixPthreadDestroy(&attr2, newThread2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newThread1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ printf("\tg_fatFlag=:%d\t", g_fatFlag);
+ }
+ printf("\n");
+ ICUNIT_GOTO_EQUAL(g_fatFlag, FAT_PRESSURE_CYCLES, g_fatFlag, EXIT2);
+
+ dir = opendir(FAT_PATH_NAME);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newThread2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newThread1);
+EXIT:
+ rmdir(FAT_PATH_NAME);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_PRESSURE_041
+* -@tspec The Pressure test
+* -@ttitle After the creation of four documents 1000 umount / mount 1,000 months after renaming the directory
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create two tasks;
+2. the first task create 4 files ;
+3. the another task rename the directory and mount/umount the filesysterm;
+4. delete the files;
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFatPressure041(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_041", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_042.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_042.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c70bc4058a38ba076a6ba771bc31aa458f524f35
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_042.cpp
@@ -0,0 +1,441 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 ret;
+ INT32 len;
+ INT32 j = 0;
+ CHAR bufname[FAT_SHORT_ARRAY_LENGTH] = "123456";
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR *bufRead1 = NULL;
+ CHAR *bufRead2 = NULL;
+ CHAR *bufRead3 = NULL;
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+ g_fatFlagF01++;
+
+ for (j = 0; j < 3; j++) { // loop 3 times
+ (void)memset_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+ (void)memset_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, 0, FAT_NAME_LIMITTED_SIZE);
+ (void)memset_s(bufname, FAT_SHORT_ARRAY_LENGTH, 0, FAT_SHORT_ARRAY_LENGTH);
+
+ (void)snprintf_s(bufname, FAT_SHORT_ARRAY_LENGTH, FAT_SHORT_ARRAY_LENGTH, "/test%d", j);
+ (void)strcat_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, pathname);
+ (void)strcat_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, pathname2);
+
+ (void)strcat_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, bufname);
+ (void)strcat_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, bufname);
+
+ (void)strcat_s(g_fatPathname11[j], FAT_NAME_LIMITTED_SIZE, ".txt");
+ (void)strcat_s(g_fatPathname12[j], FAT_NAME_LIMITTED_SIZE, ".cpp");
+
+ g_fatFd11[j] = open(g_fatPathname11[j], O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd11[j], -1, g_fatFd11[j], EXIT2);
+ }
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ bufRead1 = (CHAR *)malloc(10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+ ICUNIT_GOTO_NOT_EQUAL(bufRead1, NULL, 0, EXIT2);
+ (void)memset_s(bufRead1, 10 * BYTES_PER_MBYTES + 1, 0, 10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+
+ bufRead2 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufRead2, NULL, 0, EXIT3);
+ (void)memset_s(bufRead2, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufRead3 = (CHAR *)malloc(256 * BYTES_PER_KBYTES + 1); // 256 * BYTES_PER_KBYTES = 256KB
+ ICUNIT_GOTO_NOT_EQUAL(bufRead3, NULL, 0, EXIT4);
+ (void)memset_s(bufRead3, 256 * BYTES_PER_KBYTES + 1, 0, 256 * BYTES_PER_KBYTES + 1); // 256 kb
+
+ off = lseek(g_fatFd11[0], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 10 * BYTES_PER_MBYTES, off, EXIT5); // 10 mb
+
+ off = lseek(g_fatFd11[1], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, BYTES_PER_MBYTES, off, EXIT5);
+
+ off = lseek(g_fatFd11[2], 0, SEEK_END); // the 2 nd fd
+ ICUNIT_GOTO_EQUAL(off, 256 * BYTES_PER_KBYTES, off, EXIT5); // 256 kb
+
+ off = lseek(g_fatFd11[0], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT5);
+
+ off = lseek(g_fatFd11[1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT5);
+
+ off = lseek(g_fatFd11[2], 0, SEEK_SET); // fd 2
+ ICUNIT_GOTO_EQUAL(off, 0, off, EXIT5);
+
+ len = read(g_fatFd11[0], bufRead1, 10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+ ICUNIT_GOTO_EQUAL(len, 10 * BYTES_PER_MBYTES, len, EXIT5);
+
+ len = read(g_fatFd11[1], bufRead2, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_MBYTES, len, EXIT5);
+
+ len = read(g_fatFd11[2], bufRead3, 256 * BYTES_PER_KBYTES + 1); // 256 kb
+ ICUNIT_GOTO_EQUAL(len, 256 * BYTES_PER_KBYTES, len, EXIT5); // 256 kb
+
+ for (j = 0; j < 3; j++) { // loop 3 times
+ ret = close(g_fatFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT5);
+ }
+
+ for (j = 0; j < 3; j++) { // loop 3 times
+ g_fatFd11[j] = open(g_fatPathname11[j], O_NONBLOCK | O_TRUNC | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd11[j], -1, g_fatFd11[j], EXIT5);
+ }
+
+ len = write(g_fatFd11[0], bufRead2, strlen(bufRead2));
+ ICUNIT_GOTO_EQUAL(len, BYTES_PER_MBYTES, len, EXIT5);
+
+ len = write(g_fatFd11[1], bufRead3, strlen(bufRead3));
+ ICUNIT_GOTO_EQUAL(len, 256 * BYTES_PER_KBYTES, len, EXIT5); // 256 kb
+
+ len = write(g_fatFd11[2], bufRead1, strlen(bufRead1)); // fd 2
+ ICUNIT_GOTO_EQUAL(len, 10 * BYTES_PER_MBYTES, len, EXIT5); // 10 mb
+
+ for (j = 0; j < 3; j++) { // loop 3 times
+ ret = close(g_fatFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT5);
+ }
+
+ free(bufRead1);
+ free(bufRead2);
+ free(bufRead3);
+
+ g_fatFlag++;
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ return NULL;
+EXIT5:
+ free(bufRead3);
+EXIT4:
+ free(bufRead2);
+EXIT3:
+ free(bufRead1);
+EXIT2:
+ for (j = 0; j < 3; j++) { // loop 3 times
+ close(g_fatFd11[j]);
+ }
+
+ for (j = 0; j < 3; j++) { // loop 3 times
+ remove(g_fatPathname11[j]);
+ remove(g_fatPathname12[j]);
+ }
+EXIT:
+ g_testCount = 0;
+ remove(pathname2);
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 ret;
+ INT32 j = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR filebuf[260] = "abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123"
+ "456789abcedfghij9876550210abcdeabcde0123456789abcedfghij9876550210abcdeabcde0123456789abcedfgh"
+ "ij9876550210abcdeabcde0123456789abcedfghij9876550210lalalalalalalala";
+ CHAR *bufWrite1 = NULL;
+ CHAR *bufWrite2 = NULL;
+ CHAR *bufWrite3 = NULL;
+ CHAR *bufWrite4 = NULL;
+ off_t off;
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ bufWrite1 = (CHAR *)malloc(10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, 10 * BYTES_PER_MBYTES + 1, 0, 10 * BYTES_PER_MBYTES + 1); // 10 * BYTES_PER_MBYTES = 10MB
+
+ bufWrite2 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite3 = (CHAR *)malloc(256 * BYTES_PER_KBYTES + 1); // 256 * BYTES_PER_KBYTES = 256KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite3, NULL, 0, EXIT4);
+ (void)memset_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, 0, 256 * BYTES_PER_KBYTES + 1); // 256 kb
+
+ bufWrite4 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite4, NULL, 0, EXIT5);
+ (void)memset_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite4, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ }
+
+ for (j = 0; j < 4; j++) { // loop 4 times
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ (void)strcat_s(bufWrite3, 256 * BYTES_PER_KBYTES + 1, bufWrite4); // 256 kb
+ }
+
+ for (j = 0; j < 2; j++) { // loop 2 times
+ (void)strcat_s(bufWrite2, BYTES_PER_MBYTES + 1, bufWrite3);
+ (void)strcat_s(bufWrite2, BYTES_PER_MBYTES + 1, bufWrite3);
+ }
+
+ for (j = 0; j < 2; j++) { // loop 2 times
+ (void)strcat_s(bufWrite1, 10 * BYTES_PER_MBYTES + 1, bufWrite2); // 10 mb
+ (void)strcat_s(bufWrite1, 10 * BYTES_PER_MBYTES + 1, bufWrite2); // 10 mb
+ (void)strcat_s(bufWrite1, 10 * BYTES_PER_MBYTES + 1, bufWrite2); // 10 mb
+ (void)strcat_s(bufWrite1, 10 * BYTES_PER_MBYTES + 1, bufWrite2); // 10 mb
+ (void)strcat_s(bufWrite1, 10 * BYTES_PER_MBYTES + 1, bufWrite2); // 10 mb
+ }
+
+ free(bufWrite4);
+
+ g_testCount++;
+
+ ret = write(g_fatFd11[0], bufWrite1, strlen(bufWrite1));
+ ICUNIT_GOTO_EQUAL(ret, 10 * BYTES_PER_MBYTES, ret, EXIT5); // 10 * BYTES_PER_MBYTES = 10MB
+
+ ret = write(g_fatFd11[1], bufWrite2, strlen(bufWrite2));
+ ICUNIT_GOTO_EQUAL(ret, BYTES_PER_MBYTES, ret, EXIT5); // BYTES_PER_MBYTES = 1MB
+
+ ret = write(g_fatFd11[2], bufWrite3, strlen(bufWrite3)); // fd 2
+ ICUNIT_GOTO_EQUAL(ret, 256 * BYTES_PER_KBYTES, ret, EXIT5); // 256 * BYTES_PER_KBYTES = 256KB
+
+ free(bufWrite1);
+ free(bufWrite2);
+ free(bufWrite3);
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(1);
+
+ ret = pthread_mutex_lock(&g_vfatGlobalLock1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ for (j = 0; j < 3; j++) { // loop 3 times
+ ret = rename(g_fatPathname11[j], g_fatPathname12[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+
+ for (j = 0; j < FAT_MOUNT_CYCLES_TEST; j++) {
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT7);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT7);
+ }
+
+ for (j = 0; j < 3; j++) { // loop 3 times
+ g_fatFd11[j] = open(g_fatPathname12[j], O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(g_fatFd11[j], -1, g_fatFd11[j], EXIT2);
+ }
+
+ off = lseek(g_fatFd11[0], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, BYTES_PER_MBYTES, off, EXIT2); // BYTES_PER_MBYTES = 1MB
+
+ off = lseek(g_fatFd11[1], 0, SEEK_END);
+ ICUNIT_GOTO_EQUAL(off, 256 * BYTES_PER_KBYTES, off, EXIT2); // 256 * BYTES_PER_KBYTES = 256KB
+
+ off = lseek(g_fatFd11[2], 0, SEEK_END); // the 2 nd fd
+ ICUNIT_GOTO_EQUAL(off, 10 * BYTES_PER_MBYTES, off, EXIT2); // 10 mb
+
+ for (j = 0; j < 3; j++) { // loop 3 times
+ ret = close(g_fatFd11[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = unlink(g_fatPathname12[j]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ g_fatFlagF02++;
+
+ ret = rmdir(pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+
+ LosTaskDelay(2); // delay 2 s
+
+ return NULL;
+EXIT7:
+ mount(FAT_DEV_PATH, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ goto EXIT2;
+
+ free(bufWrite4);
+EXIT5:
+ free(bufWrite3);
+EXIT4:
+ free(bufWrite2);
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ for (j = 0; j < 3; j++) { // loop 3 times
+ close(g_fatFd11[j]);
+ }
+EXIT1:
+ for (j = 0; j < 3; j++) { // loop 3 times
+ remove(g_fatPathname11[j]);
+ remove(g_fatPathname12[j]);
+ }
+EXIT:
+ g_testCount = 0;
+ remove(pathname2);
+ (void)pthread_mutex_unlock(&g_vfatGlobalLock1);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ DIR *dir = NULL;
+ struct dirent *ptr = NULL;
+ pthread_t newThread1, newThread2;
+ pthread_attr_t attr1, attr2;
+
+ g_fatFlag = 0;
+ g_fatFlagF01 = 0;
+ g_fatFlagF02 = 0;
+
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ while ((g_fatFlag < FAT_PRESSURE_CYCLES) && (g_fatFlag == g_fatFlagF01)) {
+ g_testCount = 0;
+
+ ret = PosixPthreadInit(&attr1, 20); // level 20
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&newThread1, &attr1, PthreadF01, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr2, 20); // level 20
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = pthread_create(&newThread2, &attr2, PthreadF02, NULL);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
+
+ LosTaskDelay(10); // delay 10 s
+
+ ret = PosixPthreadDestroy(&attr2, newThread2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = PosixPthreadDestroy(&attr1, newThread1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ printf("\tg_fatFlag=:%d\t", g_fatFlag);
+ }
+ printf("\n");
+ ICUNIT_GOTO_EQUAL(g_fatFlag, FAT_PRESSURE_CYCLES, g_fatFlag, EXIT2);
+
+ dir = opendir(FAT_PATH_NAME);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT3);
+
+ ptr = readdir(dir);
+ ICUNIT_GOTO_EQUAL(ptr, NULL, ptr, EXIT3);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ closedir(dir);
+ goto EXIT;
+EXIT2:
+ PosixPthreadDestroy(&attr2, newThread2);
+EXIT1:
+ PosixPthreadDestroy(&attr1, newThread1);
+EXIT:
+ rmdir(FAT_PATH_NAME);
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_PRESSURE_042
+* -@tspec The Pressure test
+* -@ttitle After the creation of four documents 1000 umount / mount 1,000 months after read and write
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create two tasks;
+2. the first task create 3 files ;
+3. the another task read and write the files and mount/umount the filesysterm;
+4. delete the files;
+* -@texpect
+1. Return successed
+2. Return successed
+3. Return successed
+4. Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFatPressure042(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_042", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_301.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_301.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c21d6ce4a4f4c59c895cdcc41c46e93086e1ca5c
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_301.cpp
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 fd = -1;
+ INT32 len;
+ INT32 i = FAT_SHORT_ARRAY_LENGTH;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR buffile[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR filebuf[20 + 1] = "12345678901234567890";
+ struct statfs buf1 = { 0 };
+ struct statfs buf2 = { 0 };
+ struct statfs buf3 = { 0 };
+ struct statfs buf4 = { 0 };
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, 8, 2); // cluster size 8 2 for FAT32
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/cdir");
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(buffile, FAT_STANDARD_NAME_LENGTH, "/cdir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatfsPrintf(buf1);
+
+ ret = statfs(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.f_bavail, buf2.f_bavail, buf1.f_bavail, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT);
+
+ while (i--) {
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(filebuf), len, EXIT);
+ }
+
+ ret = statfs(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatfsPrintf(buf3);
+
+ ret = statfs(buffile, &buf4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatfsPrintf(buf4);
+
+ ICUNIT_GOTO_EQUAL(buf3.f_type, 0x4d44, buf3.f_type, EXIT);
+ ICUNIT_GOTO_EQUAL(buf4.f_type, 0x4d44, buf4.f_type, EXIT);
+ ICUNIT_GOTO_EQUAL(buf3.f_namelen, 0xFF, buf3.f_namelen, EXIT);
+ ICUNIT_GOTO_EQUAL(buf4.f_namelen, 0xFF, buf4.f_namelen, EXIT);
+ ICUNIT_GOTO_EQUAL(buf3.f_bsize, 4096, buf3.f_bsize, EXIT); // 4096 for size 4k
+ ICUNIT_GOTO_EQUAL(buf4.f_bsize, 4096, buf4.f_bsize, EXIT); // 4096 for size 4k
+
+ i = 250; // loop time 250
+ while (i--) {
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(filebuf), len, EXIT);
+ }
+
+ ret = statfs(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatfsPrintf(buf3);
+
+ ret = statfs(buffile, &buf4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatfsPrintf(buf4);
+
+ FatDeleteFile(fd, buffile);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ return FAT_NO_ERROR;
+EXIT:
+ format(FAT_DEV_PATH, 8, 0); // cluster size 8, 0 for auto
+EXIT0:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPressure301(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_301", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_302.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_302.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5e8a70a69962979548c709383c5ab15a8d62f4a4
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_302.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR buffile[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 n = 103;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/dir");
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(buffile, FAT_STANDARD_NAME_LENGTH, "/dir/files");
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT);
+
+ while (n--) {
+ len = write(fd, "0123456789012345678901234567890123456789", 40); // write 40 bytes
+ ICUNIT_GOTO_EQUAL(len, 40, len, EXIT); // len must be 40
+ }
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(buffile, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_blocks, buf2.st_blocks, buf1.st_blocks, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_size, buf2.st_size, buf1.st_size, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_blksize, buf2.st_blksize, buf1.st_blksize, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_ino, buf2.st_ino, buf1.st_ino, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_mode, buf2.st_mode, buf1.st_mode, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_mtim.tv_nsec, buf2.st_mtim.tv_nsec, buf1.st_mtim.tv_nsec, EXIT);
+
+ FatDeleteFile(fd, buffile);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ format(FAT_DEV_PATH, 8, 0); // cluster size 8, 0 for auto
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPressure302(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_302", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_303.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_303.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..832a8bc6820d3f747998bc7addd5f1fc8814fea4
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_303.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 fd = -1;
+ INT32 ret, len;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+ INT32 n = 256;
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/dir");
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ (void)strcat_s(pathname3, FAT_STANDARD_NAME_LENGTH, "/dir/files");
+ fd = open(pathname3, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT);
+
+ while (n--) {
+ len = write(fd, "01234567890123456789012345", 16); // len 16
+ ICUNIT_GOTO_EQUAL(len, 16, len, EXIT);
+ }
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = stat(pathname3, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ fd = open(pathname3, O_NONBLOCK | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT);
+
+ ret = fstat(fd, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_size, 16 * 256, buf1.st_size, EXIT); // 16 * 256 = 4k
+ ICUNIT_GOTO_EQUAL(buf2.st_size, 16 * 256, buf2.st_size, EXIT); // 16 * 256 = 4k
+ ICUNIT_GOTO_EQUAL(buf1.st_blocks, 1, buf1.st_blocks, EXIT);
+ ICUNIT_GOTO_EQUAL(buf2.st_blocks, 1, buf2.st_blocks, EXIT);
+
+ ICUNIT_GOTO_EQUAL(buf1.st_mode & S_IFMT, S_IFREG, buf1.st_mode & S_IFMT, EXIT);
+ ICUNIT_GOTO_EQUAL(buf2.st_mode & S_IFMT, S_IFREG, buf2.st_mode & S_IFMT, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_blksize, buf2.st_blksize, buf1.st_blksize, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_ino, buf2.st_ino, buf1.st_ino, EXIT);
+ ICUNIT_GOTO_EQUAL(buf1.st_mtim.tv_nsec, buf2.st_mtim.tv_nsec, buf1.st_mtim.tv_nsec, EXIT);
+
+ FatDeleteFile(fd, pathname3);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT:
+ format(FAT_DEV_PATH, 8, 0); // cluster size 8, 0 for auto
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPressure303(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_303", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_305.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_305.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..40f7b63bbddb79d6e83aa1ce769367b3ba359f79
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_305.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 i = 0;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ DIR *dir = NULL;
+ DIR *dir1[50];
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ while (i < 50) { // loop 50 times
+ dir1[i] = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT2);
+
+ i++;
+ }
+
+ for (i = 0; i < 50; i++) { // loop 50 times
+ ret = closedir(dir1[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = format(FAT_DEV_PATH, 8, 2); // cluster size 8 2 for FAT32
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ goto EXIT;
+EXIT2:
+ for (; i >= 0; i--) {
+ closedir(dir1[i]);
+ }
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPressure305(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_305", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_306.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_306.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..469e061827883a59c38a04a3e2cb9cb6a84f378d
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_306.cpp
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 i = 0;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR pathname2[50][FAT_STANDARD_NAME_LENGTH] = {FAT_PATH_NAME, };
+ CHAR bufname[FAT_SHORT_ARRAY_LENGTH] = "";
+ DIR *dir = NULL;
+ DIR *dir1[50] = {NULL, };
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT4);
+
+ ret = format(FAT_DEV_PATH, 8, 2); // cluster size 8 2 for FAT32
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT4);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT4);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ for (i = 0; i < 50; i++) { // loop 50 times
+ (void)memset_s(bufname, FAT_SHORT_ARRAY_LENGTH, 0, FAT_SHORT_ARRAY_LENGTH);
+ (void)memset_s(pathname2[i], FAT_STANDARD_NAME_LENGTH, 0, FAT_SHORT_ARRAY_LENGTH);
+ (void)snprintf_s(bufname, FAT_SHORT_ARRAY_LENGTH, FAT_SHORT_ARRAY_LENGTH, "/test%d", i);
+ FatStrcat2(pathname2[i], bufname, strlen(bufname));
+
+ ret = mkdir(pathname2[i], S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+
+ for (i = 0; i < 50; i++) { // loop 50 times
+ dir1[i] = opendir(pathname2[i]);
+ ICUNIT_GOTO_NOT_EQUAL(dir1[i], NULL, dir1[i], EXIT3);
+ }
+
+ for (i = 0; i < 50; i++) { // loop 50 times
+ ret = closedir(dir1[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ }
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ for (i = 0; i < 50; i++) { // loop 50 times
+ ret = remove(pathname2[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+ }
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT4:
+ mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ goto EXIT;
+EXIT3:
+ for (i = 0; i < 50; i++) { // loop 50 times
+ closedir(dir1[i]);
+ }
+EXIT2:
+ for (i = 0; i < 50; i++) { // loop 50 times
+ remove(pathname2[i]);
+ }
+EXIT1:
+ closedir(dir);
+EXIT:
+ remove(pathname1);
+EXIT0:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPressure306(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_306", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_309.cpp b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_309.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b8200426648b0f1f202556e8fbfa78928a24fa05
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_fs_fat_pressure_309.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei
+ * Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source
+ * code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2.
+ * Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the
+ * following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3.
+ * Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED
+ * BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN
+ * NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ *
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 i = 0;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_MAIN_DIR;
+ DIR *dir = NULL;
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, 8, 2); // cluster size 8 2 for FAT32
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = mount(FAT_DEV_PATH1, FAT_MOUNT_DIR, "vfat", 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ dir = opendir(pathname1);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < 20; i++) { // loop 20 times
+ ret = format(FAT_DEV_PATH, 8, 2); // cluster size 8 2 for FAT32
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, 8, 2); // cluster size 8 2 for FAT32
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = format(FAT_DEV_PATH, 8, 2); // cluster size 8 2 for FAT32
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT);
+ }
+
+ ret = format(FAT_DEV_PATH, 8, 0); // cluster size 8, 0 for auto
+ ICUNIT_GOTO_EQUAL(ret, FAT_IS_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT2:
+ mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ goto EXIT;
+EXIT1:
+ closedir(dir);
+EXIT:
+ return FAT_NO_ERROR;
+}
+
+VOID ItFsFatPressure309(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_PRESSURE_309", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL3, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_003.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ca93e97645c2220f4697bbc1ff7205a6a730b51e
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_003.cpp
@@ -0,0 +1,546 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 index1 = 0;
+ INT32 fd[100] = {};
+ INT32 fd1[100] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/file%d.txt", index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100
+ len = write(fd1[index1], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ ret = lseek(fd1[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd1[index1], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f01 is excecuting\n");
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 index1 = 0;
+ INT32 fd[100] = {};
+ INT32 fd1[100] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is excecuting\n");
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/file%d.txt", index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100
+ len = write(fd1[index1], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ ret = lseek(fd1[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd1[index1], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 index1 = 0;
+ INT32 fd[100] = {};
+ INT32 fd1[100] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/file%d.txt", index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100
+ len = write(fd1[index1], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ ret = lseek(fd1[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd1[index1], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ LosTaskDelay(3); // 3s
+ printf("pthread_f03 is excecuting\n");
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file%d.txt",
+ i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname4[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ CHAR bufname5[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR bufname6[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = mkdir(bufname6, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test It_vfs_fat_mutipthread_003
+* - @tspec function test
+* - @ttitle multithreading writes the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously write to this file.
+3 Check the contents of the file
+4. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread003(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_003", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_004.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cf9b091e8e57c8b198e255ade97f9112f9e14f69
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_004.cpp
@@ -0,0 +1,509 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 index1 = 0;
+ INT32 fd[100] = {};
+ INT32 fd1[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+ printf("In %s,line %d\n", __FUNCTION__, __LINE__);
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ printf("In %s,line %d, i =%d\n", __FUNCTION__, __LINE__, i);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ printf("In %s,line %d, i =%d\n", __FUNCTION__, __LINE__, i);
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file_%d.txt",
+ index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+
+ len = write(fd1[index1], writebuf, strlen(writebuf));
+
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f01 is excecuting\n");
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file_%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file_%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 index1 = 0;
+ INT32 fd[100] = {};
+ INT32 fd1[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+ printf("In %s,line %d\n", __FUNCTION__, __LINE__);
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ printf("In %s,line %d, i =%d\n", __FUNCTION__, __LINE__, i);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ printf("In %s,line %d, i =%d\n", __FUNCTION__, __LINE__, i);
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file_%d.txt",
+ index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+
+ len = write(fd1[index1], writebuf, strlen(writebuf));
+
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ LosTaskDelay(10); // delay 10 s
+ printf("pthread_f02 is excecuting\n");
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file_%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file_%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 index1 = 0;
+ INT32 fd[100] = {};
+ INT32 fd1[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+ printf("In %s,line %d\n", __FUNCTION__, __LINE__);
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ printf("In %s,line %d, i =%d\n", __FUNCTION__, __LINE__, i);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ printf("In %s,line %d, i =%d\n", __FUNCTION__, __LINE__, i);
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file_%d.txt",
+ index1);
+ fd1[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+
+ len = write(fd1[index1], writebuf, strlen(writebuf));
+
+ ret = close(fd1[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is excecuting\n");
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file_%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd1[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file_%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_004
+* - @tspec function test
+* - @ttitle multithreading reads the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously read this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread004(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_004", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_005.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0a063f657afcabc338b6c373f603125f11352ce2
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_005.cpp
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len;
+ INT32 flag = 0;
+ INT32 fd = -1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR *bufWrite1 = nullptr;
+ CHAR *bufWrite2 = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ printf("pthread_f01 is excecuting\n");
+ bufWrite = (CHAR *)malloc(4 * BYTES_PER_MBYTES + 1); // 4MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, 4 * BYTES_PER_MBYTES + 1); // 4mb
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ }
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ }
+
+ for (i = 0; i < 2; i++) { // loop 2 times
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file0.txt");
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+
+ for (j = 0; j < (8 * BYTES_PER_KBYTES / 8); j++) { // 8 kb
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = read(fd, readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf2);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ printf("pthread_f01 exiting\n");
+ return NULL;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len;
+ INT32 flag = 0;
+ INT32 fd = -1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR *bufWrite1 = nullptr;
+ CHAR *bufWrite2 = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ printf("pthread_f02 is excecuting\n");
+ bufWrite = (CHAR *)malloc(4 * BYTES_PER_MBYTES + 1); // 4MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, 4 * BYTES_PER_MBYTES + 1); // 4mb
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ }
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ }
+
+ for (i = 0; i < 2; i++) { // loop 2 times
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file1.txt");
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+
+ for (j = 0; j < (8 * BYTES_PER_KBYTES / 8); j++) { // 8 kb
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f02 is excecuting\n");
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = read(fd, readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf2);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ printf("pthread_f02 exiting\n");
+ return NULL;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len;
+ INT32 flag = 0;
+ INT32 fd = -1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR *bufWrite1 = nullptr;
+ CHAR *bufWrite2 = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ printf("pthread_f03 is excecuting\n");
+ bufWrite = (CHAR *)malloc(4 * BYTES_PER_MBYTES + 1); // 4MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, 4 * BYTES_PER_MBYTES + 1); // 4mb
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ }
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ }
+
+ for (i = 0; i < 2; i++) { // loop 2 times
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file2.txt");
+ fd = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ for (j = 0; j < (8 * BYTES_PER_KBYTES / 8); j++) { // 8 kb
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f03 is excecuting\n");
+
+ ret = lseek(fd, 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ len = read(fd, readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf2);
+
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ printf("pthread_f03 exiting\n");
+ return NULL;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ close(fd);
+EXIT:
+ unlink(pathname);
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_005
+* - @tspec function test
+* - @ttitle multithreading reads the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously read this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread005(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_005", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_006.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..29e2284189d5f5a68855d278d257495cda4154cc
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_006.cpp
@@ -0,0 +1,710 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len;
+ INT32 index = 0;
+ INT32 index1 = 0;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR *bufWrite1 = nullptr;
+ CHAR *bufWrite2 = nullptr;
+ CHAR *bufWrite3 = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ struct stat buf1 = { 0 };
+
+ bufWrite = (CHAR *)malloc(4 * BYTES_PER_MBYTES + 1); // 4MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, 4 * BYTES_PER_MBYTES + 1); // 4mb
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ }
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ }
+
+ for (i = 0; i < 2; i++) { // loop 2 times
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ index = 0;
+ for (i = 0; i < FAT_LONG_FILESIZE; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < (8 * BYTES_PER_KBYTES / 8); j++) { // 8 k
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ bufWrite3 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite3, NULL, NULL, EXIT);
+ (void)memset_s(bufWrite3, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite3, BYTES_PER_MBYTES + 1, filebuf);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_LONG_FILESIZE; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/vs/sd/test0/test00/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index1], bufWrite3, strlen(bufWrite3));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = lseek(fd[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index1], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/vs/sd/test0/test00/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufWrite3);
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ unlink(pathname);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/vs/sd/test0/test00/file%d.txt", i);
+ unlink(pathname1);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len;
+ INT32 index = 0;
+ INT32 index1 = 0;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR *bufWrite1 = nullptr;
+ CHAR *bufWrite2 = nullptr;
+ CHAR *bufWrite3 = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ struct stat buf1 = { 0 };
+
+ bufWrite = (CHAR *)malloc(4 * BYTES_PER_MBYTES + 1); // 4MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, 4 * BYTES_PER_MBYTES + 1); // 4mb
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ }
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ }
+
+ for (i = 0; i < 2; i++) { // loop 2 times
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ index = 0;
+ for (i = 0; i < FAT_LONG_FILESIZE; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < (8 * BYTES_PER_KBYTES / 8); j++) { // 8 k
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f02 is excecuting\n");
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ bufWrite3 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite3, NULL, NULL, EXIT);
+ (void)memset_s(bufWrite3, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite3, BYTES_PER_MBYTES + 1, filebuf);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_LONG_FILESIZE; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/vs/sd/test1/test11/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index1], bufWrite3, strlen(bufWrite3));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ ret = lseek(fd[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index1], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/vs/sd/test1/test11/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufWrite3);
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/vs/sd/test1/test11/file%d.txt", i);
+ unlink(pathname1);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len;
+ INT32 index = 0;
+ INT32 index1 = 0;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR *bufWrite1 = nullptr;
+ CHAR *bufWrite2 = nullptr;
+ CHAR *bufWrite3 = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ struct stat buf1 = { 0 };
+
+ bufWrite = (CHAR *)malloc(4 * BYTES_PER_MBYTES + 1); // 4MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, 0, EXIT1);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, 4 * BYTES_PER_MBYTES + 1); // 4mb
+
+ bufWrite1 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite1, NULL, 0, EXIT2);
+ (void)memset_s(bufWrite1, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ bufWrite2 = (CHAR *)malloc(16 * BYTES_PER_KBYTES + 1); // 16 * BYTES_PER_KBYTES = 16KB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite2, NULL, 0, EXIT3);
+ (void)memset_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, 0, 16 * BYTES_PER_KBYTES + 1); // 16 kb
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ (void)strcat_s(bufWrite2, 16 * BYTES_PER_KBYTES + 1, filebuf); // 16 kb
+ }
+
+ for (j = 0; j < 16; j++) { // loop 16 times
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ (void)strcat_s(bufWrite1, BYTES_PER_MBYTES + 1, bufWrite2);
+ }
+
+ for (i = 0; i < 2; i++) { // loop 2 times
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, bufWrite1);
+ }
+
+ free(bufWrite1);
+ free(bufWrite2);
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ index = 0;
+ for (i = 0; i < FAT_LONG_FILESIZE; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < (8 * BYTES_PER_KBYTES / 8); j++) { // 8 k
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // 3s
+ printf("pthread_f03 is excecuting\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ bufWrite3 = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite3, NULL, NULL, EXIT);
+ (void)memset_s(bufWrite3, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite3, BYTES_PER_MBYTES + 1, filebuf);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_LONG_FILESIZE; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/vs/sd/test2/test22/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index1], bufWrite3, strlen(bufWrite3));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = lseek(fd[index1], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index1], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/vs/sd/test2/test22/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufWrite3);
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT3:
+ free(bufWrite1);
+EXIT2:
+ free(bufWrite);
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ unlink(pathname);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/vs/sd/test2/test22/file%d.txt", i);
+ unlink(pathname1);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname4[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ CHAR bufname5[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR bufname6[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_006
+* - @tspec function test
+* - @ttitle multithreading reads the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously read this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread006(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_006", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_008.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2e5b8a493a0712a691ba85bc5cde5bb160d52a3b
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_008.cpp
@@ -0,0 +1,555 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len;
+ INT32 index = 0;
+ INT32 index1 = 0;
+ INT32 fd[100] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "1111";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ CHAR buffile2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_STANDARD_NAME_LENGTH; i++) { // 50 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // д100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufWrite);
+ index1 = FAT_STANDARD_NAME_LENGTH;
+ for (i = FAT_STANDARD_NAME_LENGTH; i < FAT_MAX_CYCLES; i++) { // 50 ¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt",
+ index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index1] == -1) {
+ break;
+ }
+ len = write(fd[index1], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 4, len, EXIT1); // write 4 bytes
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf2);
+
+ for (i = index1; i >= FAT_STANDARD_NAME_LENGTH; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ return NULL;
+
+ free(bufWrite);
+EXIT1:
+ for (i = index1; i >= FAT_STANDARD_NAME_LENGTH; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= FAT_STANDARD_NAME_LENGTH; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len;
+ INT32 index = 0;
+ INT32 index1 = 0;
+ INT32 fd[100] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "1111";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME1;
+ CHAR buffile2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_STANDARD_NAME_LENGTH; i++) { // 50 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // д100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f02 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufWrite);
+ index1 = FAT_STANDARD_NAME_LENGTH;
+ for (i = FAT_STANDARD_NAME_LENGTH; i < FAT_MAX_CYCLES; i++) { // 50 ¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt",
+ index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index1] == -1) {
+ break;
+ }
+ len = write(fd[index1], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 4, len, EXIT1); // write 4 bytes
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf2);
+
+ for (i = index1; i >= FAT_STANDARD_NAME_LENGTH; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ return NULL;
+
+ free(bufWrite);
+EXIT1:
+ for (i = index1; i >= FAT_STANDARD_NAME_LENGTH; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= FAT_STANDARD_NAME_LENGTH; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test1/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len;
+ INT32 index = 0;
+ INT32 index1 = 0;
+ INT32 fd[100] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "1111";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ CHAR buffile2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_STANDARD_NAME_LENGTH; i++) { // 50 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // д100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // 3s
+ printf("pthread_f03 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ free(bufWrite);
+ index1 = FAT_STANDARD_NAME_LENGTH;
+ for (i = FAT_STANDARD_NAME_LENGTH; i < FAT_MAX_CYCLES; i++) { // 50 ¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt",
+ index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index1] == -1) {
+ break;
+ }
+ len = write(fd[index1], writebuf, strlen(writebuf));
+ ICUNIT_GOTO_EQUAL(len, 4, len, EXIT1); // write 4 bytes
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf2);
+
+ for (i = index1; i >= FAT_STANDARD_NAME_LENGTH; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ g_testCount++;
+
+ return NULL;
+
+EXIT1:
+ for (i = index1; i >= FAT_STANDARD_NAME_LENGTH; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index1; i >= FAT_STANDARD_NAME_LENGTH; i--) {
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test2/file%d.txt", i);
+ unlink(pathname1);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/vs/sd/test0/file%d.txt", i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname4[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ CHAR bufname5[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR bufname6[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_008
+* - @tspec function test
+* - @ttitle multithreading reads the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously read this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread008(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_008", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_009.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_009.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fa619d10871dab4cd4004e5deb59f31ef94a8ea2
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_009.cpp
@@ -0,0 +1,404 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 fd[100] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ struct stat buf1 = { 0 };
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // 100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+
+EXIT1:
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 fd[100] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME1;
+ struct stat buf1 = { 0 };
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f02 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+
+EXIT1:
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 fd[100] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME1;
+ struct stat buf1 = { 0 };
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // 3s
+ printf("pthread_f03 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+
+EXIT1:
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file%d.txt",
+ i);
+ unlink(pathname);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname4[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ CHAR bufname5[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR bufname6[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_009
+* - @tspec function test
+* - @ttitle multithreading reads the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously read this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread009(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_009", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_010.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..798f922de3ffe75b1dfd05660c12867dcae19ec5
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_010.cpp
@@ -0,0 +1,574 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 index1 = 0;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ CHAR buffile2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < 5; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 256; j++) { // дÂú256
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 5; // index1 should set to 5
+ for (i = 5; i < FAT_MIDDLE_CYCLES; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 128; j++) { // дÂú128
+ len = write(fd[index1], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf2);
+
+ for (i = index1; i >= 5; i--) { // loop until 5
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+
+ free(bufWrite);
+EXIT1:
+ for (i = index1; i >= 5; i--) { // loop until 5
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file%d.txt",
+ i);
+ unlink(pathname);
+ }
+
+ for (i = index1; i >= 5; i--) { // loop until 5
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/file%d.txt", i);
+ unlink(pathname1);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 index1 = 0;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME1;
+ CHAR buffile2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < 5; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 256; j++) { // дÂú256
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 5; // index1 should set to 5
+ for (i = 5; i < FAT_MIDDLE_CYCLES; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 128; j++) { // дÂú128
+ len = write(fd[index1], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f02 is excecuting\n");
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf2);
+
+ for (i = index1; i >= 5; i--) { // loop until 5
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+
+ free(bufWrite);
+EXIT1:
+ for (i = index1; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file%d.txt",
+ i);
+ unlink(pathname);
+ }
+
+ for (i = index1; i >= 5; i--) { // loop until 5
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/file%d.txt", i);
+ unlink(pathname1);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, index;
+ INT32 index1 = 0;
+ INT32 fd[10] = {};
+ INT32 flag = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME2;
+ CHAR buffile2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ struct stat buf1 = { 0 };
+ struct stat buf2 = { 0 };
+
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < 5; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 256; j++) { // дÂú256
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // 3s
+ printf("pthread_f03 is excecuting\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ ret = stat(buffile, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf1);
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 5; // index1 should set to 5
+ for (i = 5; i < FAT_MIDDLE_CYCLES; i++) { // 5 ¸öÎļþ
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/file%d.txt", index1);
+ fd[index1] = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index1] == -1) {
+ break;
+ }
+
+ for (j = 0; j < 128; j++) { // дÂú128
+ len = write(fd[index1], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd[index1]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile2, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ FatStatPrintf(buf2);
+
+ for (i = index1; i >= 5; i--) { // loop until 5
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/file%d.txt", i);
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+
+ free(bufWrite);
+EXIT1:
+ for (i = index1; i >= 5; i--) { // loop until 5
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file%d.txt",
+ i);
+ unlink(pathname);
+ }
+
+ for (i = index1; i >= 5; i--) { // loop until 5
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/file%d.txt", i);
+ unlink(pathname1);
+ }
+ free(bufWrite);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname4[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ CHAR bufname5[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR bufname6[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_010
+* - @tspec function test
+* - @ttitle multithreading reads the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously read this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread010(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_010", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_012.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_012.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fbb3acdcb734abd7ba389710a91d1737a3d48256
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_012.cpp
@@ -0,0 +1,630 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i, j, ret, len, flag;
+ INT32 index = 0;
+ INT32 index1 = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf = { 0 };
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/ttest%d",
+ index1);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf)); // four byte
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i, j, ret, len, flag;
+ INT32 index = 0;
+ INT32 index1 = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME1;
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf = { 0 };
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 50 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/ttest%d", i);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf)); // 10M
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i, j, ret, len, flag;
+ INT32 index = 0;
+ INT32 index1 = 0;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME2;
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf = { 0 };
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 50 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // 3s
+ printf("pthread_f03 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ index1 = 0;
+ for (i = 0; i < 100; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/ttest%d",
+ index1);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf)); // 10M
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname4[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ CHAR bufname5[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR bufname6[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test It_vfs_fat_mutipthread_012
+* - @tspec function test
+* - @ttitle multithreading writes the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously write to this file.
+3 Check the contents of the file
+4. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread012(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_012", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_014.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_014.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a0dd652f9735648a09ecf943ac78db6716b33c2f
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_014.cpp
@@ -0,0 +1,633 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i = 0;
+ INT32 j, ret, len, flag, index, index1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME0;
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf = { 0 };
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/ttest%d", index1);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf)); // four byte
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test00/ttest%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i = 0;
+ INT32 j, ret, len, flag, index, index1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME1;
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf = { 0 };
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/ttest%d", index1);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf)); // four byte
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test11/ttest%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i = 0;
+ INT32 j, ret, len, flag, index, index1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR buffile[FAT_NAME_LIMITTED_SIZE] = FAT_PATH_NAME2;
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf = { 0 };
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // 3s
+ printf("pthread_f03 is excecuting\n");
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/ttest%d", index1);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf)); // four byte
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+ ret = stat(buffile, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test22/ttest%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/ttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname4[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ CHAR bufname5[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR bufname6[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test It_vfs_fat_mutipthread_014
+* - @tspec function test
+* - @ttitle multithreading writes the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously write to this file.
+3 Check the contents of the file
+4. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread014(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_014", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_016.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_016.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..17c1f2ee888950810452715f404b44638905b7d0
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_016.cpp
@@ -0,0 +1,666 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i, j, ret, len, flag, index, index1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/tttest%d",
+ index1);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf)); // four byte
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname5, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/tttest_%d",
+ index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/tttest_%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/tttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ i = 0;
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/tttest_%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i, j, ret, len, flag, index, index1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/tttest%d",
+ index1);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf)); // four byte
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname5, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/tttest_%d",
+ index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/tttest_%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/tttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ i = 0;
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/tttest_%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i, j, ret, len, flag, index, index1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR writebuf[FAT_STANDARD_NAME_LENGTH] = "0000";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f03 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/tttest%d",
+ index1);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1 == -1) {
+ break;
+ }
+
+ len = write(fd1, writebuf, strlen(writebuf)); // four byte
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname5, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/tttest_%d",
+ index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/tttest_%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/tttest%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ i = 0;
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/tttest_%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname4[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ CHAR bufname5[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR bufname6[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test It_vfs_fat_mutipthread_016
+* - @tspec function test
+* - @ttitle multithreading writes the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously write to this file.
+3 Check the contents of the file
+4. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread016(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_016", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_017.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_017.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4a87a7d2f238e4f3836d799e6b25878560dc6833
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_017.cpp
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/testdir%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/testdir_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/testdir_%d",
+ i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/testdir%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/testdir_%d",
+ i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test1%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test01_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test01_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test1%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test01_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname4[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ CHAR bufname5[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR bufname6[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test It_vfs_fat_mutipthread_017
+* - @tspec function test
+* - @ttitle multithreading writes the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously write to this file.
+3 Check the contents of the file
+4. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread017(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_017", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_018.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_018.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3c19cf76095fa6994b04460199d4866ed4047f25
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_018.cpp
@@ -0,0 +1,646 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i = 0;
+ INT32 j, ret, len, flag, index, index1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/tttest%d", index1);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1 == -1) {
+ break;
+ }
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname5, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/tttest_%d", index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/tttest_%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test00/tttest%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ i = 0;
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test0/test00/tttest_%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ret = rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ret = rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i = 0;
+ INT32 j, ret, len, flag, index, index1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3s
+ printf("pthread_f02 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/tttest%d", index1);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1 == -1) {
+ break;
+ }
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname5, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/tttest_%d", index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/tttest_%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test11/tttest%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ i = 0;
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/tttest_%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ret = rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ret = rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 fd = -1;
+ INT32 fd1 = -1;
+ INT32 i = 0;
+ INT32 j, ret, len, flag, index, index1;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname3[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname4[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname5[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d",
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f03 is excecuting\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test_%d",
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ index1 = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100 dir
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/tttest%d", index1);
+ ret = mkdir(pathname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ fd1 = open(pathname4, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd1 == -1) {
+ break;
+ }
+ ret = close(fd1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname5, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/tttest_%d", index1);
+ ret = rename(pathname3, pathname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index1++;
+ }
+
+ if (flag == 0) {
+ index1--;
+ }
+
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/tttest_%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "//file.txt");
+ ret = unlink(pathname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd1);
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test22/tttest%d",
+ i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname4);
+ rmdir(pathname3);
+
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ i = 0;
+ for (i = index1; i >= 0; i--) {
+ (void)snprintf_s(pathname3, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/tttest_%d", i);
+ (void)strcpy_s(pathname4, FAT_STANDARD_NAME_LENGTH, pathname3);
+ (void)strcat_s(pathname4, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname4);
+ ret = rmdir(pathname3);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/test_%d", i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ret = rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname4[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ CHAR bufname5[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR bufname6[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test It_vfs_fat_mutipthread_001
+* - @tspec function test
+* - @ttitle multithreading writes the same file at the same time
+* - @tbrief
+1. Create a file to open
+2. Create three threads to simultaneously write to this file.
+3 Check the contents of the file
+4. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread018(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_018", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_019.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_019.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..606a36fdce7e1b4c5960d50415b9971685c713c2
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_019.cpp
@@ -0,0 +1,448 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file1%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f01 is excecuting\n");
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, nullptr);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file1%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file1%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test/test0/file2%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f02 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test/test0/file2%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test/test0/file2%d.txt", i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test/test0/test1/file3%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is excecuting\n");
+ break;
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test/test0/test1/file3_%d.txt", index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test/test0/test1/file3_%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test/test0/test1/file3_%d.txt", i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ (void)strcat_s(bufname2, FAT_STANDARD_NAME_LENGTH, "/test0");
+ (void)strcat_s(bufname3, FAT_STANDARD_NAME_LENGTH, "/test0/test1");
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 3); // level less 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 1); // fd 2 level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_019
+* - @tspec function test
+* - @ttitleMultithreading deletes the same file at the same time
+* - @tbrief
+1. Create a file
+2. Create three threads to delete this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread019(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_019", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_020.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_020.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..28fbcf23a0a7e054e63fb348563c6b37abad920b
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_020.cpp
@@ -0,0 +1,444 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file1%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file1%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file1%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file2%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is excecuting\n");
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf)); // four bytes
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file2%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file2%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file3%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf)); // four bytes
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is excecuting\n");
+ break;
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file3_%d.txt",
+ index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file3_%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file3_%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 1); // level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 3); // level less 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_020
+* - @tspec function test
+* - @ttitleMultithreading deletes the same file at the same time
+* - @tbrief
+1. Create a file
+2. Create three threads to delete this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread020(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_020", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_021.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_021.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e9cde0f047a6a9920bf996de4b95306878e2900d
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_021.cpp
@@ -0,0 +1,428 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file1%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f01 is excecuting\n");
+ break;
+ default:
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file1%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file1%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file2%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is excecuting\n");
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf)); // four bytes
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file2%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file2%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file3%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f03 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf)); // four bytes
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file3_%d.txt",
+ index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file3_%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file3_%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 1); // level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 3); // fd 2 level less for 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_021
+* - @tspec function test
+* - @ttitleMultithreading deletes the same file at the same time
+* - @tbrief
+1. Create a file
+2. Create three threads to delete this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread021(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_021", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_022.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_022.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3a5273b4c0e1fdc4d25dbc4e2c9cac6f6b10da9c
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_022.cpp
@@ -0,0 +1,469 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_GOTO_NOT_EQUAL(bufWrite, NULL, NULL, EXIT0);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file1%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, nullptr);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file1%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file1%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+EXIT0:
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/file2%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f02 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/file2%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test1/test11/file2%d.txt", i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/file3%d.txt", index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f03 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/file3_%d.txt", index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/file3_%d.txt", i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH,
+ "/bin/vs/sd/test2/test22/file3_%d.txt", i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME00;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname4[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME11;
+ CHAR bufname5[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ CHAR bufname6[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME22;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname4, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname5, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname6, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 3); // level less 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 1); // level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname6);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname5);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname2);
+ rmdir(bufname1);
+ rmdir(bufname4);
+ rmdir(bufname3);
+ rmdir(bufname6);
+ rmdir(bufname5);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_022
+* - @tspec function test
+* - @ttitleMultithreading deletes the same file at the same time
+* - @tbrief
+1. Create a file
+2. Create three threads to delete this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread022(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_022", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_023.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_023.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dc994c2a4902097b648cad3423ce8eb3f675105c
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_023.cpp
@@ -0,0 +1,445 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file1%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file1%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test0/file1%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file2%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is excecuting\n");
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf)); // four bytes
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file2%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test1/file2%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file3%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f03 is excecuting\n");
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf)); // four bytes
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file3_%d.txt",
+ index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file3_%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test2/file3_%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 1); // level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 3); // fd 2 level less for 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_023
+* - @tspec function test
+* - @ttitleMultithreading deletes the same file at the same time
+* - @tbrief
+1. Create a file
+2. Create three threads to delete this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread023(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_023", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_024.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_024.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a4e429bfca04a385765c7dde4bda3ab2bbd7be11
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_024.cpp
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file1%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f01 is excecuting\n");
+ break;
+ default:
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file1%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file1%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file2%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is excecuting\n");
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf)); // four bytes
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file2%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file2%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0000";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file3%d.txt",
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f03 is excecuting\n");
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf)); // four bytes
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ break;
+ default:
+ flag = 1;
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file3_%d.txt",
+ index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file3_%d.txt",
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "/bin/vs/sd/test/file3_%d.txt",
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 1); // level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 3); // fd 2 level less for 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_024
+* - @tspec function test
+* - @ttitleMultithreading deletes the same file at the same time
+* - @tbrief
+1. Create a file
+2. Create three threads to delete this file.
+3. Delete all files and threads;
+* - @ tprior 1
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread024(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_024", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_027.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_027.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ea8858a8e63f3081735474dd1d4cdd3a761b51cd
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_027.cpp
@@ -0,0 +1,381 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME0,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME1,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME1,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME1,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME2,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME2,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME2,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_027
+* - @tspec pressure test
+* - @ttitle multithreaded open, write, read, offset, close the 100M file
+* - @tbrief
+1. In the peer directory
+2. Three threads
+3. Same priority
+4. 100 files per thread
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+VOID ItFsFatMutipthread027(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_027", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_029.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_029.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fd1003226294e60bdef7877bbfa2fb8f41b91b88
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_029.cpp
@@ -0,0 +1,381 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME_0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME_0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME_0,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt",
+ FAT_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt",
+ FAT_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt",
+ FAT_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_0;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_01;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_029
+* - @tspec pressure test
+* - @ttitle multithreaded open, write, read, offset, close the 100M file
+* - @tbrief
+1. In the different levels of directory
+2. Three threads
+3. Same priority
+4. 100 files per thread
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread029(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_029", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_030.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_030.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..66d04432dfbb9e5e755dcbc5b79832dfa6fbc48b
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_030.cpp
@@ -0,0 +1,380 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME0,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME1,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME1,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME1,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME2,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME2,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME2,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_030
+* - @tspec pressure test
+* - @ttitle multithreaded open, search, close the 100M file
+* - @tbrief
+1. In the peer directory
+2. Three threads
+3. Same priority
+4. 100 files per thread
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread030(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_030", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_032.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_032.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..93506b180cd0219e53ade972a6b87c56531ad256
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_032.cpp
@@ -0,0 +1,381 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME_0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME_0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt", FAT_PATH_NAME_0,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt",
+ FAT_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt",
+ FAT_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file%d.txt",
+ FAT_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+
+ return NULL;
+}
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_0;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_01;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_032
+* - @tspec pressure test
+* - @ttitle multithreaded open, search, close the 10b file
+* - @tbrief
+1. In the different levels of directory
+2. Three threads
+3. Same priority
+4. 100 files per thread
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread032(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_032", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_033.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_033.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..38c5510564b5697f5dd73a17422783feb4a56cce
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_033.cpp
@@ -0,0 +1,423 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index, offset;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ DIR *dir = NULL;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME0,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, FAT_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME0, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME0, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index, offset;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ DIR *dir = NULL;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME1,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, FAT_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME1, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME1, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index, offset;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ DIR *dir = NULL;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME2,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, FAT_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME2, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME2, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_033
+* - @tspec pressure test
+* - @ttitle multithreaded open, search, close the 100 directory
+* - @tbrief
+1. In the peer directory
+2. Three threads
+3. Same priority
+4. 100 directory per thread
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread033(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_033", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_035.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_035.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..67439785eb8df3634f264e29d0eeeb489fbd4a6a
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_035.cpp
@@ -0,0 +1,426 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index, offset;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ DIR *dir = NULL;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, FAT_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index, offset;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ DIR *dir = NULL;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME_0,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, FAT_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME_0,
+ i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME_0,
+ i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index, offset;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+ DIR *dir = NULL;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME_01,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ dir = opendir(pathname);
+ ICUNIT_GOTO_NOT_EQUAL(dir, NULL, dir, EXIT1);
+ offset = telldir(dir);
+ ICUNIT_GOTO_EQUAL(offset, FAT_NO_ERROR, offset, EXIT1);
+
+ ret = closedir(dir);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME_01,
+ i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ closedir(dir);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME_01,
+ i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_0;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_01;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_035
+* - @tspec pressure test
+* - @ttitle multithreaded open, search, close the 100M directory
+* - @tbrief
+1. In the different levels of directory
+2. Three threads
+3. Same priority
+4. 100 directory per thread
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread035(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_035", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_036.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_036.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d9bbcba8ccdd7af126d83b0dd7c412a674dbe31c
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_036.cpp
@@ -0,0 +1,426 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME0,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME0,
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME0, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME0, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME0, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME1,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME1,
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME1, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME1, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME1, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME2,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME2,
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME2, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test%d", FAT_PATH_NAME2, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test_%d", FAT_PATH_NAME2, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_036
+* - @tspec pressure test
+* - @ttitle multithreaded creat, rename, remove the 100M directory
+* - @tbrief
+1. In the peer directory
+2. Three threads
+3. Same priority
+4. 100 directory per thread
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread036(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_036", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_038.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_038.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fd4d78b190826e5d24cb098ae56d6885c48a9765
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_038.cpp
@@ -0,0 +1,432 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test1%d", FAT_PATH_NAME,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(3); // delay 3 s
+ printf("pthread_f01 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test1_%d", FAT_PATH_NAME,
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test1_%d", FAT_PATH_NAME, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test1%d", FAT_PATH_NAME, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test1_%d", FAT_PATH_NAME, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test2%d", FAT_PATH_NAME_0,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(5); // delay 5 s
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test2_%d", FAT_PATH_NAME_0,
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test2_%d", FAT_PATH_NAME_0,
+ i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test2%d", FAT_PATH_NAME_0, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test2_%d", FAT_PATH_NAME_0,
+ i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 fd = -1;
+ INT32 i, j, ret, len, flag, index;
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname2[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test3%d", FAT_PATH_NAME_01,
+ index);
+ ret = mkdir(pathname, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (ret == -1) {
+ break;
+ }
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ fd = open(pathname1, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd == -1) {
+ break;
+ }
+
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd, bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+
+ LosTaskDelay(7); // delay 7 s
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname2, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test3_%d", FAT_PATH_NAME_01,
+ index);
+ ret = rename(pathname, pathname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test3_%d", FAT_PATH_NAME_01,
+ i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ ret = unlink(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = rmdir(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ close(fd);
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test3%d", FAT_PATH_NAME_01, i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/test3_%d", FAT_PATH_NAME_01,
+ i);
+ (void)strcpy_s(pathname1, FAT_STANDARD_NAME_LENGTH, pathname);
+ (void)strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/file.txt");
+ unlink(pathname1);
+ rmdir(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_0;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_01;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_038
+* - @tspec pressure test
+* - @ttitle multithreaded creat, rename, remove the 100M directory
+* - @tbrief
+1. In the different levels of directory
+2. Three threads
+3. Same priority
+4. 100 directory per thread
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread038(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_038", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_039.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_039.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..37cb5620b6dd52b09125cc9b4dffeef25cfebcb0
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_039.cpp
@@ -0,0 +1,438 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_039
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the same directory
+2. Three threads
+3. Same priority
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread039(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_039", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_040.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_040.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..460d1c05a25ff1832b755f58b57f0a9c8df3c2fb
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_040.cpp
@@ -0,0 +1,456 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt", FAT_PATH_NAME2,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_040
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the peer directory
+2. Three threads
+3. Same priority
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread040(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_040", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_041.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_041.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..520c3ffaf4c0fbbdfd69c22ae4e89a6dcda5988a
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_041.cpp
@@ -0,0 +1,456 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt",
+ FAT_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_0;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_01;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_041
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the different levels of directory
+2. Three threads
+3. Same priority
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread041(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_041", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_042.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_042.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8db6215de189c3464e78e162ccdfb359512fb48c
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_042.cpp
@@ -0,0 +1,459 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt", FAT_PATH_NAME2,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 3); // level less 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 1); // fd 2 level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_042
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the peer directory
+2. Three threads
+3. different priority
+ pthread_f01 high
+ pthread_f02 middle
+ pthread_f03 low
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread042(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_042", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_043.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_043.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7699a7668d18f1d2493ebc9a941e3f9f8116d87f
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_043.cpp
@@ -0,0 +1,441 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)(void) snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 3); // level less 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 1); // fd 2 level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_043
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the same directory
+2. Three threads
+3. different priority
+ pthread_f01 high
+ pthread_f02 middle
+ pthread_f03 low
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread043(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_043", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_044.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_044.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0af397d4ea860cf66fecefd5210849f1481331d8
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_044.cpp
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt",
+ FAT_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_0;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_01;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 3); // level less 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 1); // fd 2 level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_044
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the different levels of directory
+2. Three threads
+3. different priority
+ pthread_f01 high
+ pthread_f02 middle
+ pthread_f03 low
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+VOID ItFsFatMutipthread044(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_044", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_045.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_045.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..54d726eae408818136d6fb72e7b7cec6cfc6973f
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_045.cpp
@@ -0,0 +1,459 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt", FAT_PATH_NAME2,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 1); // level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 3); // fd 2 level less for 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_045
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the peer directory
+2. Three threads
+3. different priority
+ pthread_f01 middle
+ pthread_f02 low
+ pthread_f03 high
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread045(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_045", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_046.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_046.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8b4c640e336d83098f269b8f95172af9e23cb0bb
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_046.cpp
@@ -0,0 +1,425 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+ g_testCount++;
+ free(bufWrite);
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME, index);
+
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+ free(bufWrite);
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 1); // level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 3); // fd 2 level less for 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_046
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the same directory
+2. Three threads
+3. different priority
+ pthread_f01 middle
+ pthread_f02 low
+ pthread_f03 high
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+VOID ItFsFatMutipthread046(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_046", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_047.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_047.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..58e9b5dcd3b7d5bd3fdc1f18875ca1b94edc20f1
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_047.cpp
@@ -0,0 +1,459 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt",
+ FAT_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_0;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_01;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 1); // level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 3); // fd 2 level less for 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_045
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the different levels of directory
+2. Three threads
+3. different priority
+ pthread_f01 middle
+ pthread_f02 low
+ pthread_f03 high
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread047(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_047", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_048.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_048.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bf6fde5052e121b24bc51c853f3626d57f7d85c6
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_048.cpp
@@ -0,0 +1,460 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ printf("%s_%d, read ret = %d, errno = %d(%s)\n", __func__, __LINE__, len, errno, strerror(errno));
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME0,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME1,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt", FAT_PATH_NAME2,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME2, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME0;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME1;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME2;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 1); // level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 3); // level less 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_048
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the peer directory
+2. Three threads
+3. different priority
+ pthread_f01 low
+ pthread_f02 high
+ pthread_f03 middle
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread048(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_048", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_049.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_049.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8a18abf312b1f1995ef08178250fa8877258271f
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_049.cpp
@@ -0,0 +1,441 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 1); // level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 3); // level less 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_049
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the same directory
+2. Three threads
+3. different priority
+ pthread_f01 low
+ pthread_f02 high
+ pthread_f03 middle
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread049(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_049", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_050.cpp b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_050.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d565ac09d6421d2390994a59637d5e3364cd196f
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/pressure/It_vfs_fat_mutipthread_050.cpp
@@ -0,0 +1,459 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+
+static VOID *PthreadF01(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR readbuf[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f01 is executing\n");
+
+ ret = lseek(fd[index], 0, SEEK_SET);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ len = read(fd[index], readbuf, 10); // read 10 bytes
+ ICUNIT_GOTO_EQUAL(len, 10, len, EXIT1); // len must be 10
+ ICUNIT_ASSERT_STRING_EQUAL_RET(readbuf, "0123456789", readbuf, NULL);
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file1%d.txt", FAT_PATH_NAME,
+ i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF02(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+ struct stat statbuf;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f02 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = stat(pathname, &statbuf);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ FatStatPrintf(statbuf);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file2%d.txt",
+ FAT_PATH_NAME_0, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+
+static VOID *PthreadF03(void *arg)
+{
+ INT32 i, j, ret, len, flag, index;
+ INT32 fd[100] = {};
+ CHAR pathname[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = "";
+ CHAR filebuf[260] = "01234567890123456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123"
+ "456789abcedfghij9876543210abcdeabcde0123456789abcedfghij9876543210abcdeabcde0123456789abcedfgh"
+ "ij9876543210abcdeabcde0123456789abcedfghij9876543210lalalalalalalala";
+ CHAR writebuf[20] = "0123456789";
+ CHAR *bufWrite = nullptr;
+
+ flag = 0;
+ bufWrite = (CHAR *)malloc(BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+ ICUNIT_ASSERT_NOT_EQUAL_NULL(bufWrite, NULL, NULL);
+ (void)memset_s(bufWrite, BYTES_PER_MBYTES + 1, 0, BYTES_PER_MBYTES + 1); // BYTES_PER_MBYTES = 1MB
+
+ for (i = 0; i < BYTES_PER_KBYTES * 4; i++) { // loop in 4 Kb
+ (void)strcat_s(bufWrite, BYTES_PER_MBYTES, filebuf);
+ }
+
+ index = 0;
+ for (i = 0; i < FAT_MAX_CYCLES; i++) { // 100¸öÎļþ
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3%d.txt",
+ FAT_PATH_NAME_01, index);
+ fd[index] = open(pathname, O_NONBLOCK | O_CREAT | O_RDWR | O_EXCL, S_IRWXU | S_IRWXG | S_IRWXO);
+ if (fd[index] == -1) {
+ break;
+ }
+ switch (index % 3) { // mod 3
+ case 0:
+ for (j = 0; j < FAT_MAX_CYCLES; j++) { // дÂú100M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(3); // delay 3 s
+ break;
+ case 1:
+ for (j = 0; j < FAT_MIDDLE_CYCLES; j++) { // дÂú10M
+ len = write(fd[index], bufWrite, strlen(bufWrite));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ }
+ LosTaskDelay(5); // delay 5 s
+ break;
+ case 2: // the 2 nd case
+ len = write(fd[index], writebuf, strlen(writebuf));
+ if (len <= 0) {
+ flag = 1;
+ break;
+ }
+ LosTaskDelay(7); // delay 7 s
+ break;
+ default:
+ break;
+ }
+
+ printf("pthread_f03 is executing\n");
+
+ ret = close(fd[index]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ (void)snprintf_s(pathname1, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, index);
+ ret = rename(pathname, pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ if (flag == 1) {
+ break;
+ }
+ index++;
+ }
+
+ if (flag == 0) {
+ index--;
+ }
+
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, i);
+ ret = unlink(pathname);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ }
+
+ g_testCount++;
+
+ free(bufWrite);
+
+ return NULL;
+EXIT1:
+ for (i = index; i >= 0; i--) {
+ close(fd[i]);
+ }
+ unlink(pathname);
+EXIT:
+ for (i = index; i >= 0; i--) {
+ (void)snprintf_s(pathname, FAT_STANDARD_NAME_LENGTH, FAT_STANDARD_NAME_LENGTH, "%s/file3_%d.txt",
+ FAT_PATH_NAME_01, i);
+ unlink(pathname);
+ }
+ g_testCount = 0;
+ free(bufWrite);
+ return NULL;
+}
+static UINT32 TestCase(VOID)
+{
+ INT32 ret, i;
+ CHAR bufname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR bufname2[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_0;
+ CHAR bufname3[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME_01;
+ pthread_attr_t attr[FAT_MAX_THREADS];
+ pthread_t threadId[FAT_MAX_THREADS];
+
+ g_testCount = 0;
+
+ ret = mkdir(bufname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname2, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(bufname3, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+ ret = PosixPthreadInit(&attr[0], TASK_PRIO_TEST - 1); // level less 1
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[0], &attr[0], PthreadF01, (void *)0);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[1], TASK_PRIO_TEST - 3); // level less 3
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[1], &attr[1], PthreadF02, (void *)1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = PosixPthreadInit(&attr[2], TASK_PRIO_TEST - 2); // 2 less than TASK_PRIO_TEST
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = pthread_create(&threadId[2], &attr[2], PthreadF03, (void *)2); // the no 2 thread
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_join(threadId[i], NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ ret = pthread_attr_destroy(&attr[i]);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+ }
+
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ICUNIT_ASSERT_EQUAL(g_testCount, 3, g_testCount); // there 3 threads
+
+ ret = rmdir(bufname3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = rmdir(bufname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+
+EXIT1:
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_join(threadId[i], NULL);
+ }
+ for (i = 0; i < FAT_MAX_THREADS; i++) {
+ pthread_attr_destroy(&attr[i]);
+ }
+EXIT:
+ rmdir(bufname3);
+ rmdir(bufname2);
+ rmdir(bufname1);
+
+ return FAT_NO_ERROR;
+}
+
+/* *
+* - @test IT_FS_FAT_MUTIPTHREAD_050
+* - @tspec pressure test
+* - @ttitle multithreaded operating the files
+* - @tbrief
+1. In the different levels of directory
+2. Three threads
+3. different priority
+ pthread_f01 low
+ pthread_f02 high
+ pthread_f03 middle
+4. pthread_f01 open, write, read, offset, close files
+5. pthread_f02 open, search, close files
+6. pthread_f03 create, rename, remove files
+7. 100 files per thread include 100M, 10M, 10b
+* - @ tprior 4
+* - @ tauto TRUE
+* - @ tremark
+*/
+
+VOID ItFsFatMutipthread050(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_MUTIPTHREAD_050", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL4, TEST_PRESSURE);
+}
diff --git a/testsuites/unittest/fs/vfat2/smoke/It_vfs_fat_026.cpp b/testsuites/unittest/fs/vfat2/smoke/It_vfs_fat_026.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7a4185266ae7ccf7693de2d65a3395d76817815c
--- /dev/null
+++ b/testsuites/unittest/fs/vfat2/smoke/It_vfs_fat_026.cpp
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "It_vfs_fat.h"
+static const int FAT_FORMAT_SEC = 8;
+static const int SIZE_4K = 4096;
+static const int WRITE_TIME = 250;
+
+static UINT32 TestCase(VOID)
+{
+ INT32 ret;
+ INT32 fd = 0;
+ INT32 len = 0;
+ INT32 i = 0;
+ CHAR pathname1[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR buffile[FAT_STANDARD_NAME_LENGTH] = FAT_PATH_NAME;
+ CHAR filebuf[FAT_STANDARD_NAME_LENGTH] = "12345678901234567890";
+ struct statfs buf1 = { 0 };
+ struct statfs buf2 = { 0 };
+ struct statfs buf3 = { 0 };
+ struct statfs buf4 = { 0 };
+
+ ret = chdir("/");
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT0);
+
+ ret = umount(FAT_MOUNT_DIR);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = format(FAT_DEV_PATH, FAT_FORMAT_SEC, FAT_FILE_SYSTEMTYPE_AUTO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mount(FAT_DEV_PATH, FAT_MOUNT_DIR, FAT_FILESYS_TYPE, 0, NULL);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ ret = strcat_s(pathname1, FAT_STANDARD_NAME_LENGTH, "/dir");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ ret = mkdir(pathname1, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = strcat_s(buffile, FAT_STANDARD_NAME_LENGTH, "/dir/files");
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
+
+ fd = open(buffile, O_NONBLOCK | O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_GOTO_NOT_EQUAL(fd, FAT_IS_ERROR, fd, EXIT3);
+
+ ret = statfs(pathname1, &buf1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ FatStatfsPrintf(buf1);
+
+ ret = statfs(buffile, &buf2);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ FatStatfsPrintf(buf2);
+
+ ICUNIT_GOTO_EQUAL(buf1.f_type, buf2.f_type, buf1.f_type, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.f_bavail, buf2.f_bavail, buf1.f_bavail, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.f_bsize, buf2.f_bsize, buf1.f_bsize, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.f_blocks, buf2.f_blocks, buf1.f_blocks, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.f_bfree, buf2.f_bfree, buf1.f_bfree, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf1.f_files, buf2.f_files, buf1.f_files, EXIT3);
+
+ while (i--) {
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(filebuf), len, EXIT3);
+ }
+
+ ret = statfs(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ FatStatfsPrintf(buf3);
+
+ ret = statfs(buffile, &buf4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ FatStatfsPrintf(buf4);
+
+ ICUNIT_GOTO_EQUAL(buf3.f_type, 0x4d44, buf3.f_type, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf4.f_type, 0x4d44, buf4.f_type, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf3.f_namelen, 0xFF, buf3.f_namelen, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf4.f_namelen, 0xFF, buf4.f_namelen, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf3.f_bsize, SIZE_4K, buf3.f_bsize, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf4.f_bsize, SIZE_4K, buf4.f_bsize, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf3.f_bfree + 1, buf1.f_bfree, buf3.f_bfree + 1, EXIT3);
+ ICUNIT_GOTO_EQUAL(buf4.f_bfree + 1, buf2.f_bfree, buf4.f_bfree + 1, EXIT3);
+
+ i = WRITE_TIME;
+ while (i--) {
+ len = write(fd, filebuf, strlen(filebuf));
+ ICUNIT_GOTO_EQUAL((UINT32)len, strlen(filebuf), len, EXIT3);
+ }
+
+ ret = statfs(pathname1, &buf3);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ FatStatfsPrintf(buf3);
+
+ ret = statfs(buffile, &buf4);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+ FatStatfsPrintf(buf4);
+
+ ret = close(fd);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT3);
+
+ ret = unlink(buffile);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT2);
+
+ ret = rmdir(pathname1);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT1);
+
+ ret = rmdir(FAT_PATH_NAME);
+ ICUNIT_GOTO_EQUAL(ret, FAT_NO_ERROR, ret, EXIT);
+
+ return FAT_NO_ERROR;
+EXIT3:
+ close(fd);
+EXIT2:
+ FatStrcat2(pathname1, "/dir/files", strlen(pathname1));
+ remove(pathname1);
+EXIT1:
+ FatStrcat2(pathname1, "/dir", strlen(pathname1));
+ remove(pathname1);
+EXIT:
+ remove(FAT_PATH_NAME);
+EXIT0:
+ return FAT_NO_ERROR;
+}
+
+/* *
+* -@test IT_FS_FAT_026
+* -@tspec The function test for filesystem
+* -@ttitle Use the statfs to view the information for the filesystem
+* -@tprecon The filesystem module is open
+* -@tbrief
+1. create one file;
+2. use the statfs to view the information for the filesystem;
+3. write the file and view the information once again;
+4. delete all the file and directory.
+* -@texpect
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+* Sucessful operation
+* -@tprior 1
+* -@tauto TRUE
+* -@tremark
+*/
+
+VOID ItFsFat026(VOID)
+{
+ TEST_ADD_CASE("IT_FS_FAT_026", TestCase, TEST_VFS, TEST_VFAT, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/liteipc/BUILD.gn b/testsuites/unittest/liteipc/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..84c5b39b4844dbda1052517488345ae16af9bf40
--- /dev/null
+++ b/testsuites/unittest/liteipc/BUILD.gn
@@ -0,0 +1,54 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../config.gni")
+
+unittest("liteos_a_liteipc_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../common/include",
+ "../liteipc",
+ ]
+ sources = [
+ "../common/osTest.cpp",
+ "smgr_demo.cpp",
+ "it_test_liteipc.cpp",
+ ]
+ if (LOSCFG_USER_TEST_SMOKE == true) {
+ sources_smoke = [
+ "smoke/liteipc_test_001.cpp",
+ "smoke/liteipc_test_002.cpp",
+ ]
+ sources += sources_smoke
+ }
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+ configs = [ "..:public_config" ]
+}
diff --git a/testsuites/unittest/liteipc/it_test_liteipc.cpp b/testsuites/unittest/liteipc/it_test_liteipc.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4c425aaec59c4ce4df11ff3617e3fa07dbe64993
--- /dev/null
+++ b/testsuites/unittest/liteipc/it_test_liteipc.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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
+#include
+#include "it_test_liteipc.h"
+
+using namespace testing::ext;
+namespace OHOS {
+class LiteIpcTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+
+/* *
+ * @tc.name: ItPosixLiteIpc001
+ * @tc.desc: function test for liteipc
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(LiteIpcTest, ItPosixLiteIpc001, TestSize.Level0)
+{
+ ItPosixLiteIpc001();
+}
+
+/* *
+ * @tc.name: ItPosixLiteIpc002
+ * @tc.desc: function test for liteipc
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(LiteIpcTest, ItPosixLiteIpc002, TestSize.Level0)
+{
+ ItPosixLiteIpc002();
+}
+}
\ No newline at end of file
diff --git a/testsuites/unittest/liteipc/it_test_liteipc.h b/testsuites/unittest/liteipc/it_test_liteipc.h
new file mode 100644
index 0000000000000000000000000000000000000000..1d4282adcfb1660dff1c5c88fbb93c24c7e2f7be
--- /dev/null
+++ b/testsuites/unittest/liteipc/it_test_liteipc.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _IT_TEST_LITEIPC_H
+#define _IT_TEST_LITEIPC_H
+
+#include "osTest.h"
+#include "sys/resource.h"
+
+#define USE_TIMESTAMP YES
+
+extern void ItPosixLiteIpc001(void);
+extern void ItPosixLiteIpc002(void);
+
+#endif
diff --git a/testsuites/unittest/liteipc/liteipc.h b/testsuites/unittest/liteipc/liteipc.h
new file mode 100644
index 0000000000000000000000000000000000000000..6ce880fcf40d0b9d59fb107d77bb06effc6b9bbb
--- /dev/null
+++ b/testsuites/unittest/liteipc/liteipc.h
@@ -0,0 +1,110 @@
+/*
+ * 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 _LITEIPC_H
+#define _LITEIPC_H
+
+#include
+
+#define LITEIPC_DRIVER "/dev/lite_ipc"
+
+typedef enum { OBJ_FD, OBJ_PTR, OBJ_SVC } ObjType;
+
+typedef struct {
+ uint32_t buffSz;
+ void *buff;
+} BuffPtr;
+
+typedef struct {
+ uint32_t handle;
+ uint32_t token;
+ uint32_t cookie;
+} SvcIdentity;
+
+typedef union {
+ uint32_t fd;
+ BuffPtr ptr;
+ SvcIdentity svc;
+} ObjContent;
+
+typedef struct {
+ ObjType type;
+ ObjContent content;
+} SpecialObj;
+
+typedef enum { MT_REQUEST, MT_REPLY, MT_FAILED_REPLY, MT_DEATH_NOTIFY } MsgType;
+typedef enum { CMS_GEN_HANDLE, CMS_REMOVE_HANDLE, CMS_ADD_ACCESS } CmsCmd;
+
+/* lite ipc ioctl */
+#define IPC_IOC_MAGIC 'i'
+#define IPC_SET_CMS _IO(IPC_IOC_MAGIC, 1)
+#define IPC_CMS_CMD _IOWR(IPC_IOC_MAGIC, 2, CmsCmdContent)
+#define IPC_SET_IPC_THREAD _IO(IPC_IOC_MAGIC, 3)
+#define IPC_SEND_RECV_MSG _IOWR(IPC_IOC_MAGIC, 4, IpcContent)
+
+typedef struct {
+ CmsCmd cmd;
+ uint32_t taskID;
+ uint32_t serviceHandle;
+} CmsCmdContent;
+
+typedef struct {
+ MsgType type; /**< cmd type, decide the data structure below */
+ SvcIdentity target; /**< serviceHandle or targetTaskId, depending on type */
+ uint32_t code;
+ uint32_t flag;
+#if (USE_TIMESTAMP == YES)
+ uint64_t timestamp;
+#endif
+ uint32_t dataSz; /**< size of data */
+ void* data;
+ uint32_t spObjNum;
+ void* offsets;
+ uint32_t processID; /**< filled by kernel, processId of sender/reciever */
+ uint32_t taskID; /**< filled by kernel, taskId of sender/reciever */
+#ifdef LOSCFG_SECURITY_CAPABILITY
+ uint32_t userID;
+ uint32_t gid;
+#endif
+} IpcMsg;
+
+#define SEND (1 << 0)
+#define RECV (1 << 1)
+#define BUFF_FREE (1 << 2)
+
+typedef struct {
+ uint32_t flag;
+ IpcMsg *outMsg; /**< data to send to target */
+ IpcMsg *inMsg; /**< data reply by target */
+ void *buffToFree;
+} IpcContent;
+
+#endif //_LITEIPC_H
\ No newline at end of file
diff --git a/testsuites/unittest/liteipc/smgr_demo.cpp b/testsuites/unittest/liteipc/smgr_demo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f4c673c4b285cc4162a403c98cf3dfa10543ec92
--- /dev/null
+++ b/testsuites/unittest/liteipc/smgr_demo.cpp
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "it_test_liteipc.h"
+#include "signal.h"
+#include "sys/wait.h"
+
+#include "unistd.h"
+#include "liteipc.h"
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+#include "sys/ioctl.h"
+#include "sys/time.h"
+
+#include "smgr_demo.h"
+
+ServiceName g_serviceNameMap[MAX_SREVICE_NUM];
+BOOL g_cmsRunningFlag = FALSE;
+
+static void InitCms()
+{
+ memset(g_serviceNameMap, 0, sizeof(g_serviceNameMap));
+}
+
+uint32_t SetCms(int fd)
+{
+ return ioctl(fd, IPC_SET_CMS, 200);
+}
+
+void SendReply(int fd, IpcMsg *dataIn, uint32_t result, uint32_t serviceHandle)
+{
+ IpcContent data1;
+ IpcMsg dataOut;
+ unsigned int ret;
+ uint32_t ptr[2];
+
+ data1.flag = SEND | BUFF_FREE;
+ data1.buffToFree = dataIn;
+ data1.outMsg = &dataOut;
+ memset(data1.outMsg, 0, sizeof(IpcMsg));
+ data1.outMsg->type = MT_REPLY;
+ data1.outMsg->target.handle = dataIn->taskID;
+ data1.outMsg->target.token = dataIn->target.token;
+ data1.outMsg->code = dataIn->code;
+#if (USE_TIMESTAMP == YES)
+ data1.outMsg->timestamp = dataIn->timestamp;
+#endif
+ ptr[0] = result;
+ ptr[1] = serviceHandle;
+ data1.outMsg->dataSz = 8;
+ data1.outMsg->data = ptr;
+ ret = ioctl(fd, IPC_SEND_RECV_MSG, &data1);
+ if (ret) {
+ printf("SendReply failed\n");
+ }
+}
+
+void FreeBuffer(int fd, IpcMsg *dataIn)
+{
+ IpcContent data1;
+ unsigned int ret;
+ data1.flag = BUFF_FREE;
+ data1.buffToFree = dataIn;
+ ret = ioctl(fd, IPC_SEND_RECV_MSG, &data1);
+ if (ret) {
+ printf("FreeBuffer failed\n");
+ }
+}
+
+static uint32_t SendCmsCmd(int fd, CmsCmdContent *content)
+{
+ unsigned int ret;
+ ret = ioctl(fd, IPC_CMS_CMD, content);
+ if (ret) {
+ printf("SendCmsCmd failed\n");
+ }
+ return ret;
+}
+
+uint32_t RegService(int fd, char *serviceName, uint32_t nameLen, uint32_t *serviceHandle)
+{
+ IpcContent data1;
+ IpcMsg dataIn;
+ IpcMsg dataOut;
+ uint32_t ret;
+ uint32_t *ptr = nullptr;
+ ServiceName name;
+
+ if (nameLen > NAME_LEN_MAX) {
+ return -1;
+ }
+ memcpy(name.serviceName, serviceName, nameLen);
+ name.nameLen = nameLen;
+
+ data1.flag = SEND | RECV;
+ data1.outMsg = &dataOut;
+ memset(data1.outMsg, 0, sizeof(IpcMsg));
+ data1.outMsg->type = MT_REQUEST;
+ data1.outMsg->target.handle = 0;
+ data1.outMsg->code = REG_CODE;
+ data1.outMsg->dataSz = sizeof(ServiceName);
+ data1.outMsg->data = &name;
+
+ ret = ioctl(fd, IPC_SEND_RECV_MSG, &data1);
+ if (ret != 0) {
+ printf("RegService failed\n");
+ return ret;
+ }
+ ptr = (uint32_t*)(data1.inMsg->data);
+ *serviceHandle = ptr[1];
+ FreeBuffer(fd, data1.inMsg);
+ return ptr[0];
+}
+
+uint32_t GetService(int fd, char *serviceName, uint32_t nameLen, uint32_t *serviceHandle)
+{
+ IpcContent data1;
+ IpcMsg dataIn;
+ IpcMsg dataOut;
+ uint32_t ret;
+ uint32_t *ptr = nullptr;
+ ServiceName name;
+
+ if (nameLen > NAME_LEN_MAX) {
+ return -1;
+ }
+ memcpy(name.serviceName, serviceName, nameLen);
+ name.nameLen = nameLen;
+
+ data1.flag = SEND | RECV;
+ data1.outMsg = &dataOut;
+ memset(data1.outMsg, 0, sizeof(IpcMsg));
+ data1.outMsg->type = MT_REQUEST;
+ data1.outMsg->target.handle = 0;
+ data1.outMsg->code = GET_CODE;
+ data1.outMsg->dataSz = sizeof(ServiceName);
+ data1.outMsg->data = &name;
+
+ ret = ioctl(fd, IPC_SEND_RECV_MSG, &data1);
+ if (ret != 0) {
+ return ret;
+ }
+ ptr = (uint32_t*)(data1.inMsg->data);
+ *serviceHandle = ptr[1];
+ FreeBuffer(fd, data1.inMsg);
+ return ptr[0];
+}
+
+static void HandleServiceRegAndGet(int fd, IpcMsg *data)
+{
+ uint32_t ret, i;
+
+ if (data->code == STOP_CODE) {
+ g_cmsRunningFlag = FALSE;
+ return;
+ }
+
+ ServiceName *info = (ServiceName*)(data->data);
+ CmsCmdContent content;
+ if ((info->nameLen == 0) || (info->serviceName == NULL)) {
+ goto ERROR_EXIT;
+ }
+ for (i = 0; i < MAX_SREVICE_NUM; i++) {
+ if (g_serviceNameMap[i].serviceName != NULL && g_serviceNameMap[i].nameLen == info->nameLen) {
+ if(memcmp(g_serviceNameMap[i].serviceName, info->serviceName, info->nameLen) == 0) {
+ break;
+ }
+ }
+ }
+ printf("recieve service request, code:%d, service name:%s\n", data->code, info->serviceName);
+ switch (data->code) {
+ case REG_CODE:
+ if (i == MAX_SREVICE_NUM) {
+ content.cmd = CMS_GEN_HANDLE;
+ content.taskID = data->taskID;
+ ret = SendCmsCmd(fd, &content);
+ if (ret) {
+ goto ERROR_EXIT;
+ }
+ if (g_serviceNameMap[content.serviceHandle].serviceName != NULL && g_serviceNameMap[content.serviceHandle].nameLen == info->nameLen) {
+ printf("the task has already a service named:%s\n", g_serviceNameMap[content.serviceHandle].serviceName);
+ goto ERROR_REG;
+ } else {
+ memcpy(g_serviceNameMap[content.serviceHandle].serviceName, info->serviceName, info->nameLen);
+ g_serviceNameMap[content.serviceHandle].nameLen = info->nameLen;
+ SendReply(fd, data, 0, content.serviceHandle);
+ }
+ }else {
+ printf("this service already registed\n");
+ goto ERROR_EXIT;
+ }
+ break;
+ case GET_CODE:
+ if (i == MAX_SREVICE_NUM) {
+ goto ERROR_EXIT;
+ }else {
+ content.cmd = CMS_ADD_ACCESS;
+ content.taskID = data->taskID;
+ content.serviceHandle = i;
+ SendCmsCmd(fd, &content);
+ SendReply(fd, data, 0, i);
+ }
+ break;
+ default:
+ break;
+ }
+ return;
+ERROR_REG:
+ content.cmd = CMS_REMOVE_HANDLE;
+ SendCmsCmd(fd, &content);
+ERROR_EXIT:
+ SendReply(fd, data, -1, 0);
+}
+
+static uint32_t CmsLoop(int fd)
+{
+ IpcContent data1;
+ IpcMsg dataIn;
+ IpcMsg dataOut;
+ uint32_t ret;
+ g_cmsRunningFlag = TRUE;
+ while (g_cmsRunningFlag == TRUE) {
+ data1.flag = RECV;
+ ret = ioctl(fd, IPC_SEND_RECV_MSG, &data1);
+ if (ret != 0) {
+ printf("bad request!\n");
+ continue;
+ }
+ switch (data1.inMsg->type) {
+ case MT_REQUEST:
+ HandleServiceRegAndGet(fd, data1.inMsg);
+ break;
+ default:
+ printf("request not support:%d!\n", data1.inMsg->type);
+ FreeBuffer(fd, data1.inMsg);
+ break;
+ }
+ }
+}
+
+void StartCms(int fd)
+{
+ InitCms();
+ CmsLoop(fd);
+}
+
+void StopCms(int fd)
+{
+ IpcContent data1;
+ IpcMsg dataOut;
+ int ret;
+
+ data1.flag = SEND;
+ data1.outMsg = &dataOut;
+ memset(data1.outMsg, 0, sizeof(IpcMsg));
+ data1.outMsg->type = MT_REQUEST;
+ data1.outMsg->target.handle = 0;
+ data1.outMsg->code = STOP_CODE;
+ data1.outMsg->dataSz = 0;
+ data1.outMsg->data = 0;
+
+ ret = ioctl(fd, IPC_SEND_RECV_MSG, &data1);
+ if (ret != 0) {
+ printf("StopCms failed ioctl ret:%d!\n", ret);
+ }
+}
+
diff --git a/testsuites/unittest/liteipc/smgr_demo.h b/testsuites/unittest/liteipc/smgr_demo.h
new file mode 100644
index 0000000000000000000000000000000000000000..06526fa3abb317fc8005495246681129914db716
--- /dev/null
+++ b/testsuites/unittest/liteipc/smgr_demo.h
@@ -0,0 +1,53 @@
+/*
+ * 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 "liteipc.h"
+
+#define MAX_SREVICE_NUM 100
+#define NAME_LEN_MAX 30
+typedef struct {
+ char serviceName[NAME_LEN_MAX + 1];
+ uint32_t nameLen;
+} ServiceName;
+
+typedef enum {
+ REG_CODE,
+ GET_CODE,
+ STOP_CODE
+} SmgrCode;
+
+void StartCms(int fd);
+void StopCms(int fd);
+uint32_t RegService(int fd, char *serviceName, uint32_t nameLen, uint32_t *serviceHandle);
+uint32_t GetService(int fd, char *serviceName, uint32_t nameLen, uint32_t *serviceHandle);
+void SendReply(int fd, IpcMsg *dataIn, uint32_t result, uint32_t serviceHandle);
+void FreeBuffer(int fd, IpcMsg *dataIn);
+
diff --git a/testsuites/unittest/liteipc/smoke/liteipc_test_001.cpp b/testsuites/unittest/liteipc/smoke/liteipc_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..658e68e9d88261b00a7ff3424feeab24533fb692
--- /dev/null
+++ b/testsuites/unittest/liteipc/smoke/liteipc_test_001.cpp
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "it_test_liteipc.h"
+#include "sys/wait.h"
+
+#include "unistd.h"
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+#include "sys/time.h"
+#include "sys/ioctl.h"
+#include "fcntl.h"
+
+#include "liteipc.h"
+#include "smgr_demo.h"
+
+static int LiteIpcTest(void)
+{
+ unsigned int ret;
+ IpcContent tmp;
+ void *retptr = nullptr;
+ /* testing open liteipc driver with different flag, expecting result is that flag matters nothing */
+ int fd = open(LITEIPC_DRIVER, O_WRONLY | O_CLOEXEC);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+ ret = close(fd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ fd = open(LITEIPC_DRIVER, O_RDONLY | O_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+ ret = close(fd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ fd = open(LITEIPC_DRIVER, O_RDWR | O_SYNC);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+
+ /* testing mmap liteipc mem pool with different size and flag */
+ retptr = mmap(nullptr, 1024 * 4096, PROT_READ, MAP_PRIVATE, fd, 0);
+ ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
+ //retptr = mmap(nullptr, 0, PROT_READ, MAP_PRIVATE, fd, 0);
+ //ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
+ retptr = mmap(nullptr, -1, PROT_READ, MAP_PRIVATE, fd, 0);
+ ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
+ retptr = mmap(nullptr, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+ ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
+ retptr = mmap(nullptr, 4096, PROT_READ, MAP_SHARED, fd, 0);
+ ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
+
+ retptr = mmap(nullptr, 1, PROT_READ, MAP_PRIVATE, fd, 0);
+ ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
+ retptr = mmap(nullptr, 4095, PROT_READ, MAP_PRIVATE, fd, 0);
+ ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
+
+ /* testing read/write api */
+ char buf[10] = {0};
+ ret = read(fd, buf, 10);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ret = write(fd, buf, 10);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ /* before set cms, testing ioctl cmd */
+ ret = ioctl(fd, IPC_CMS_CMD, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+ ret = ioctl(fd, IPC_SET_IPC_THREAD, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+ ret = ioctl(fd, IPC_SEND_RECV_MSG, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+ ret = ioctl(fd, IPC_SEND_RECV_MSG, &tmp);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ sleep(2);
+ /* after set cms, testing set cms cmd */
+ ret = ioctl(fd, IPC_SET_CMS, 200);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ exit(0);
+ return 0;
+}
+
+static int TestCase(void)
+{
+ unsigned int ret;
+ int fd = -1;
+ void *retptr = nullptr;
+ int status = 0;
+ pid_t pid = fork();
+ ICUNIT_GOTO_WITHIN_EQUAL(pid, 0, 100000, pid, EXIT);
+ if (pid == 0) {
+ LiteIpcTest();
+ exit(-1);
+ }
+
+ sleep(1);
+ fd = open(LITEIPC_DRIVER, O_RDONLY);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+
+ retptr = mmap(nullptr, 16 * 4096, PROT_READ, MAP_PRIVATE, fd, 0);
+ ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
+ ret = ioctl(fd, IPC_SET_CMS, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+ ret = ioctl(fd, IPC_SET_CMS, 200);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = ioctl(fd, IPC_SET_CMS, 200);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_GOTO_EQUAL(ret, pid, ret, EXIT);
+ status = WEXITSTATUS(status);
+ ICUNIT_GOTO_EQUAL(status, 0, status, EXIT);
+
+ return 0;
+EXIT:
+ return 1;
+}
+
+void ItPosixLiteIpc001(void)
+{
+ TEST_ADD_CASE("ItPosixLiteIpc001", TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/liteipc/smoke/liteipc_test_002.cpp b/testsuites/unittest/liteipc/smoke/liteipc_test_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2dd89a709dfec0bdf3797b21b5eb1d366cd880e5
--- /dev/null
+++ b/testsuites/unittest/liteipc/smoke/liteipc_test_002.cpp
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "it_test_liteipc.h"
+#include "sys/wait.h"
+
+#include "unistd.h"
+#include "liteipc.h"
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+#include "sys/time.h"
+#include "sys/ioctl.h"
+#include "fcntl.h"
+
+#include "smgr_demo.h"
+
+#define NEED_BREAK YES
+
+static int g_ipcFd;
+char g_serviceName[] = "ohos.testservice";
+
+static int CallTestServiceLoop(uint32_t id)
+{
+ IpcContent data1;
+ IpcMsg dataIn;
+ IpcMsg dataOut;
+ uint32_t ret;
+ void *retptr = nullptr;
+ uint32_t num = 0;
+ uint32_t *ptr = nullptr;
+ struct timeval test_time;
+ struct timeval test_time2;
+ unsigned int serviceHandle;
+
+ printf("i am the client%d process, my process id is %d\n", id, getpid());
+ ret = GetService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+ retptr = mmap(NULL, 4096, PROT_READ, MAP_PRIVATE, g_ipcFd, 0);
+ ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
+ ret = GetService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ while (1) {
+ num++;
+#if (NEED_BREAK == YES)
+ if (num > 50000) {
+ break;
+ }
+#endif
+ data1.flag = SEND | RECV;
+ data1.outMsg = &dataOut;
+ memset(data1.outMsg, 0, sizeof(IpcMsg));
+ data1.outMsg->type = MT_REQUEST;
+ data1.outMsg->target.handle = serviceHandle;
+ data1.outMsg->dataSz = 4;
+ data1.outMsg->data = #
+ ret = ioctl(g_ipcFd, IPC_SEND_RECV_MSG, &data1);
+ if (ret != 0) {
+ printf("client%d CallTestServiceLoop ioctl ret:%d, errno:%d, num:%d\n", id, ret, errno, num);
+ ICUNIT_ASSERT_EQUAL(errno, ETIME, errno);
+ goto EXIT;
+ } else {
+ ptr = (uint32_t*)(data1.inMsg->data);
+ ICUNIT_ASSERT_EQUAL(ptr[0], 0, ptr[0]);
+ ICUNIT_ASSERT_EQUAL(ptr[1], 2 * num, ptr[1]);
+ FreeBuffer(g_ipcFd, data1.inMsg);
+ }
+ }
+ char tmpBuff[2048];
+ data1.flag = SEND | RECV;
+ data1.outMsg = &dataOut;
+ memset(data1.outMsg, 0, sizeof(IpcMsg));
+ data1.outMsg->type = MT_REQUEST;
+ data1.outMsg->target.handle = serviceHandle;
+ data1.outMsg->dataSz = 1024;
+ data1.outMsg->data = tmpBuff;
+ ret = ioctl(g_ipcFd, IPC_SEND_RECV_MSG, &data1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ FreeBuffer(g_ipcFd, data1.inMsg);
+ data1.outMsg->dataSz = 2048;
+ data1.outMsg->data = tmpBuff;
+ ret = ioctl(g_ipcFd, IPC_SEND_RECV_MSG, &data1);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+ data1.outMsg->spObjNum = 300;
+ data1.outMsg->offsets = tmpBuff;
+ ret = ioctl(g_ipcFd, IPC_SEND_RECV_MSG, &data1);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+EXIT:
+ exit(0);
+ return 0;
+}
+
+static void HandleRequest(IpcMsg *data)
+{
+ uint32_t *ptr = (uint32_t*)data->data;
+ SendReply(g_ipcFd, data, 0, 2 * ptr[0]);
+}
+
+static int TestServiceLoop(void)
+{
+ IpcContent data1;
+ IpcMsg dataIn;
+ IpcMsg dataOut;
+ int ret;
+ void *retptr = nullptr;
+ struct timeval last_time;
+ struct timeval test_time;
+ int cnt = 0;
+ unsigned int serviceHandle;
+
+ printf("i am the test service process, my process id is %d\n", getpid());
+ ret = RegService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+ retptr = mmap(NULL, 4096, PROT_READ, MAP_PRIVATE, g_ipcFd, 0);
+ ICUNIT_ASSERT_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr);
+ ret = RegService(g_ipcFd, g_serviceName, sizeof(g_serviceName), &serviceHandle);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ gettimeofday(&last_time, 0);
+ while (1) {
+ cnt++;
+#if (NEED_BREAK == YES)
+ if (cnt > 100000 - 10) {
+ printf("TestServiceLoop break!\n");
+ break;
+ }
+#endif
+ data1.flag = RECV;
+ ret = ioctl(g_ipcFd, IPC_SEND_RECV_MSG, &data1);
+ if ((cnt % 1000000) == 0) {
+ gettimeofday(&test_time, 0);
+ printf("LiteIPC cnt:%d, time used:%d sec\n", cnt, test_time.tv_sec - last_time.tv_sec);
+ }
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ switch (data1.inMsg->type) {
+ case MT_REQUEST:
+ HandleRequest(data1.inMsg);
+ break;
+ default:
+ printf("request not support:%d!\n", data1.inMsg->type);
+ FreeBuffer(g_ipcFd, data1.inMsg);
+ break;
+ }
+ }
+ sleep(6);
+ exit(0);
+ return 0;
+}
+
+static int LiteIpcTest(void)
+{
+
+ int count = 0;
+ unsigned int ret;
+ void *retptr = nullptr;
+ pid_t farPid, sonPid, pid;
+ int status;
+
+ retptr = mmap(NULL, 16 * 4096, PROT_READ, MAP_PRIVATE, g_ipcFd, 0);
+ ICUNIT_GOTO_NOT_EQUAL((int)(intptr_t)retptr, -1, retptr, EXIT1);
+
+ pid = fork();
+ ICUNIT_GOTO_WITHIN_EQUAL(pid, 0, 100000, pid, EXIT1);
+ if (pid == 0) {
+ TestServiceLoop();
+ exit(-1);
+ }
+ sleep(1);//wait server start
+
+ pid = fork();
+ ICUNIT_GOTO_WITHIN_EQUAL(pid, 0, 100000, pid, EXIT1);
+ if (pid == 0) {
+ CallTestServiceLoop(1);
+ exit(-1);
+ }
+
+ pid = fork();
+ ICUNIT_GOTO_WITHIN_EQUAL(pid, 0, 100000, pid, EXIT1);
+ if (pid == 0) {
+ CallTestServiceLoop(2);
+ exit(-1);
+ }
+
+ ret = waitpid(-1, &status, 0);
+ printf("waitpid1 ret:%d\n", ret);
+ status = WEXITSTATUS(status);
+ ICUNIT_GOTO_EQUAL(status, 0, status, EXIT2);
+
+ ret = waitpid(-1, &status, 0);
+ printf("waitpid2 ret:%d\n", ret);
+ status = WEXITSTATUS(status);
+ ICUNIT_GOTO_EQUAL(status, 0, status, EXIT2);
+
+ ret = waitpid(-1, &status, 0);
+ printf("waitpid3 ret:%d\n", ret);
+ status = WEXITSTATUS(status);
+ ICUNIT_GOTO_EQUAL(status, 0, status, EXIT2);
+
+ return 0;
+EXIT1:
+ return 1;
+EXIT2:
+ printf("EXIT2 status:%d\n", status);
+ return status;
+}
+
+static int TestCase(void)
+{
+ int ret;
+ int status;
+ g_ipcFd = open(LITEIPC_DRIVER, O_RDWR);
+ ICUNIT_ASSERT_NOT_EQUAL(g_ipcFd, -1, g_ipcFd);
+
+ pid_t pid = fork();
+ ICUNIT_GOTO_WITHIN_EQUAL(pid, 0, 100000, pid, EXIT);
+ if (pid == 0) {
+ sleep(1);//wait cms start
+ ret = LiteIpcTest();
+ StopCms(g_ipcFd);
+ if (ret == 0) {
+ exit(0);
+ }
+ if (ret == 1) {
+ exit(-1);
+ }
+ exit(ret);
+ }
+
+ StartCms(g_ipcFd);
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_GOTO_EQUAL(ret, pid, ret, EXIT);
+ status = WEXITSTATUS(status);
+ ICUNIT_GOTO_EQUAL(status, 0, status, EXIT);
+
+ return 0;
+EXIT:
+ return 1;
+}
+
+void ItPosixLiteIpc002(void)
+{
+ TEST_ADD_CASE("ItPosixLiteIpc002", TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/mem/shm/BUILD.gn b/testsuites/unittest/mem/shm/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..d5534ee36407452f7aa3c219ab22e15a0f9e6cc6
--- /dev/null
+++ b/testsuites/unittest/mem/shm/BUILD.gn
@@ -0,0 +1,65 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../../config.gni")
+
+unittest("liteos_a_mem_shm_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../../common/include",
+ "../../mem/shm",
+ ]
+ sources = [
+ "../../common/osTest.cpp",
+ "mem_shm_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_SMOKE == true) {
+ sources_smoke = [
+ "smoke/shm_test_001.cpp",
+ "smoke/shm_test_002.cpp",
+ "smoke/shm_test_003.cpp",
+ "smoke/shm_test_004.cpp",
+ "smoke/shm_test_005.cpp",
+ "smoke/shm_test_006.cpp",
+ "smoke/shm_test_007.cpp",
+ "smoke/shm_test_008.cpp",
+ "smoke/shm_test_009.cpp",
+ "smoke/shm_test_010.cpp",
+ "smoke/shm_test_011.cpp",
+ "smoke/shm_test_012.cpp",
+ "smoke/shm_test_013.cpp",
+ "smoke/shm_test_014.cpp",
+ ]
+ sources += sources_smoke
+ }
+ configs = [ "../..:public_config" ]
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+}
diff --git a/testsuites/unittest/mem/shm/it_test_shm.h b/testsuites/unittest/mem/shm/it_test_shm.h
new file mode 100644
index 0000000000000000000000000000000000000000..96f5ae7ce72cd8f8f569cc1f6c80ab533a7cf68e
--- /dev/null
+++ b/testsuites/unittest/mem/shm/it_test_shm.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _IT_TEST_MEM_SHM_H
+#define _IT_TEST_MEM_SHM_H
+
+#include "osTest.h"
+#include "sys/shm.h"
+
+#define INVALID_PTR ((void *)-1)
+extern void ItTestShm001(void);
+extern void ItTestShm002(void);
+extern void ItTestShm003(void);
+extern void ItTestShm004(void);
+extern void ItTestShm005(void);
+extern void ItTestShm006(void);
+extern void ItTestShm007(void);
+extern void ItTestShm008(void);
+extern void ItTestShm009(void);
+extern void ItTestShm010(void);
+extern void ItTestShm011(void);
+extern void ItTestShm012(void);
+extern void it_test_shm_013(void);
+extern void it_test_shm_014(void);
+extern void ItTestMem100(void);
+
+#endif
diff --git a/testsuites/unittest/mem/shm/mem_shm_test.cpp b/testsuites/unittest/mem/shm/mem_shm_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..17d9127538c9588150f60f3f358c4a664635c6c8
--- /dev/null
+++ b/testsuites/unittest/mem/shm/mem_shm_test.cpp
@@ -0,0 +1,167 @@
+/*
+ * 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
+#include
+
+#include "it_test_shm.h"
+
+using namespace testing::ext;
+namespace OHOS {
+class MemShmTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_SMOKE)
+/* *
+ * @tc.name: it_test_shm_001
+ * @tc.desc: function for MemShmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemShmTest, ItTestShm001, TestSize.Level0)
+{
+ ItTestShm001();
+}
+
+/* *
+ * @tc.name: it_test_shm_002
+ * @tc.desc: function for MemShmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemShmTest, ItTestShm002, TestSize.Level0)
+{
+ ItTestShm002();
+}
+
+/* *
+ * @tc.name: it_test_shm_003
+ * @tc.desc: function for MemShmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemShmTest, ItTestShm003, TestSize.Level0)
+{
+ ItTestShm003();
+}
+
+/* *
+ * @tc.name: it_test_shm_004
+ * @tc.desc: function for MemShmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemShmTest, ItTestShm004, TestSize.Level0)
+{
+ ItTestShm004();
+}
+
+/* *
+ * @tc.name: it_test_shm_005
+ * @tc.desc: function for MemShmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemShmTest, ItTestShm005, TestSize.Level0)
+{
+ ItTestShm005();
+}
+
+/* *
+ * @tc.name: it_test_shm_006
+ * @tc.desc: function for MemShmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemShmTest, ItTestShm006, TestSize.Level0)
+{
+ ItTestShm006();
+}
+
+/* *
+ * @tc.name: it_test_shm_007
+ * @tc.desc: function for MemShmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemShmTest, ItTestShm007, TestSize.Level0)
+{
+ ItTestShm007();
+}
+
+/* *
+ * @tc.name: it_test_shm_008
+ * @tc.desc: function for MemShmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemShmTest, ItTestShm008, TestSize.Level0)
+{
+ ItTestShm008();
+}
+
+/* *
+ * @tc.name: it_test_shm_009
+ * @tc.desc: function for MemShmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemShmTest, ItTestShm009, TestSize.Level0)
+{
+ ItTestShm009();
+}
+
+/* *
+ * @tc.name: it_test_shm_010
+ * @tc.desc: function for MemShmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemShmTest, ItTestShm010, TestSize.Level0)
+{
+ ItTestShm010();
+}
+
+/* *
+ * @tc.name: it_test_shm_011
+ * @tc.desc: function for MemShmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemShmTest, ItTestShm011, TestSize.Level0)
+{
+ ItTestShm011();
+}
+#endif
+}
+// namespace OHOS
diff --git a/testsuites/unittest/mem/shm/smoke/it_test_mem_100.cpp b/testsuites/unittest/mem/shm/smoke/it_test_mem_100.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..05e1a59f518d9f30e9e1cd2f8aa991a3a4b53ea0
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/it_test_mem_100.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+#include "wchar.h"
+
+#define TEST_STR "abcdefghijk"
+
+static int TestCase(void)
+{
+ int flag;
+ wchar_t res[] = L"abcd";
+ wchar_t res1[] = L"mngh";
+ wchar_t res2[] = L"abcdmngh";
+ wchar_t *p, *pnew;
+
+ pnew = (wchar_t*)malloc(sizeof(wchar_t) * (wcslen(res) + wcslen(res1)));
+ p = wmempcpy(pnew, res, wcslen(res));
+ wmempcpy(p, res1, wcslen(res1));
+ flag = wmemcmp(pnew, res2, wcslen(res));
+
+ p = nullptr;
+ pnew = nullptr;
+ free(pnew);
+ ICUNIT_ASSERT_EQUAL(flag, 0, flag);
+
+ return 0;
+}
+
+void ItTestMem100(void)
+{
+ TEST_ADD_CASE("it_test_mem_100", TestCase, TEST_VFS, TEST_JFFS, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_001.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eb085b8be9d9a3f0dcd33aeeec0260bda3229f50
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_001.cpp
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+#include "pthread.h"
+
+#define TEXT_SZ 8
+static int g_threadCount = 0;
+
+struct shared_use_st {
+ int written;
+ char text[TEXT_SZ];
+};
+
+VOID *ShmReadFunc(VOID *ptr)
+{
+ void *shm = nullptr;
+ struct shared_use_st *shared = nullptr;
+ int shmid;
+ int ret;
+
+ shmid = shmget((key_t)1234, sizeof(struct shared_use_st), 0666 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shmid, -1, shmid);
+
+ shm = shmat(shmid, 0, 0);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shm, INVALID_PTR, shm);
+
+ printf("Memory attached at %p\n", shm);
+
+ shared = (struct shared_use_st *)shm;
+ while (1) {
+ if (shared->written == 1) {
+ printf("You wrote: %s\n", shared->text);
+ sleep(1);
+
+ shared->written = 0;
+ if (strncmp(shared->text, "end", 3) == 0) {
+ break;
+ }
+ } else {
+ sleep(1);
+ }
+ }
+
+ ret = shmdt(shm);
+ ICUNIT_ASSERT_EQUAL_NULL_VOID(ret, 0, ret);
+
+ ret = shmctl(shmid, IPC_RMID, 0);
+ ICUNIT_ASSERT_EQUAL_NULL_VOID(ret, 0, ret);
+
+ g_threadCount++;
+ return nullptr;
+}
+
+VOID *ShmWriteFunc(VOID *ptr)
+{
+ void *shm = nullptr;
+ struct shared_use_st *shared = nullptr;
+ char buffer[BUFSIZ + 1] = {'\0'};
+ int shmid;
+ int ret;
+ static int count = 0;
+
+ shmid = shmget((key_t)1234, sizeof(struct shared_use_st), 0666 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shmid, -1, shmid);
+
+ shm = shmat(shmid, (void *)0, 0);
+ ICUNIT_ASSERT_NOT_EQUAL_NULL_VOID(shm, INVALID_PTR, shm);
+
+ printf("Memory attched at %p\n", shm);
+
+ shared = (struct shared_use_st *)shm;
+ while (1) {
+ while (shared->written == 1) {
+ sleep(1);
+ printf("%s %d, Waiting...\n", __FUNCTION__, __LINE__);
+ }
+
+ printf("Enter some text: ");
+ if (count == 0) {
+ (void)snprintf_s(buffer, BUFSIZ, BUFSIZ + 1, "test");
+ } else {
+ (void)snprintf_s(buffer, BUFSIZ, BUFSIZ + 1, "end");
+ }
+ count++;
+ (void)strncpy_s(shared->text, TEXT_SZ, buffer, TEXT_SZ - 1);
+
+ shared->written = 1;
+ if (strncmp(buffer, "end", 3) == 0) {
+ break;
+ }
+ }
+
+ ret = shmdt(shm);
+ ICUNIT_ASSERT_EQUAL_NULL_VOID(ret, 0, ret);
+
+ sleep(1);
+ g_threadCount++;
+ return nullptr;
+}
+
+
+static int Testcase(VOID)
+{
+ pthread_t newPthread[2];
+ int curThreadPri, curThreadPolicy;
+ pthread_attr_t a = { 0 };
+ struct sched_param param = { 0 };
+ int ret;
+ int i, j;
+
+ g_threadCount = 0;
+
+ ret = pthread_getschedparam(pthread_self(), &curThreadPolicy, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ curThreadPri = param.sched_priority;
+ ret = pthread_attr_init(&a);
+ param.sched_priority = curThreadPri;
+ pthread_attr_setschedparam(&a, ¶m);
+
+ ret = pthread_create(&newPthread[0], &a, ShmReadFunc, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&newPthread[1], &a, ShmWriteFunc, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newPthread[0], nullptr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(newPthread[1], nullptr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ICUNIT_ASSERT_EQUAL(g_threadCount, 2, g_threadCount);
+
+ return 0;
+}
+
+void ItTestShm001(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_001", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_002.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c624257f14d045510d3e81404f5221a48134f1a1
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_002.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+
+#define SHMID_MAX 192
+
+static int Testcase(VOID)
+{
+ int shmid[SHMID_MAX + 1] = {-1};
+ int ret;
+ int i;
+
+ shmid[0] = shmget((key_t)0x1234, PAGE_SIZE, 0777 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]);
+
+ ret = shmctl(shmid[0], IPC_RMID, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ shmid[0] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]);
+
+ ret = shmctl(shmid[0], IPC_RMID, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ for (i = 0; i < SHMID_MAX; i++) {
+ shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid[i], -1, shmid[i]);
+ }
+
+ shmid[SHMID_MAX] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
+ ICUNIT_ASSERT_EQUAL(shmid[SHMID_MAX], -1, shmid[SHMID_MAX]);
+
+ for (i = 0; i < SHMID_MAX; i++) {
+ ret = shmctl(shmid[i], IPC_RMID, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ }
+
+ for (i = 0; i < SHMID_MAX; i++) {
+ ret = shmctl(shmid[i], IPC_RMID, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ }
+
+ return 0;
+}
+
+void ItTestShm002(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_002", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_003.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c9bfaba3fee71c706dabf390832cb86830d9e51a
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_003.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+
+static int Testcase(VOID)
+{
+ int shmid;
+ int ret;
+ void *shm = NULL;
+ void *vaddrPageAlign = NULL;
+ void *vaddr = NULL;
+
+ shmid = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
+
+ shm = shmat(shmid, NULL, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(shm, INVALID_PTR, shm);
+
+ (void)memset_s(shm, PAGE_SIZE, 0, PAGE_SIZE);
+
+ ret = shmdt(shm);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ vaddrPageAlign = mmap(NULL, PAGE_SIZE * 2, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(vaddrPageAlign, NULL, vaddrPageAlign);
+
+ ret = munmap(vaddrPageAlign, PAGE_SIZE * 2);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ shm = shmat(shmid, vaddrPageAlign, 0);
+ ICUNIT_ASSERT_EQUAL(shm, vaddrPageAlign, shm);
+
+ (void)memset_s(shm, PAGE_SIZE, 0, PAGE_SIZE);
+
+ ret = shmdt(shm);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ vaddr = (void *)((uintptr_t)vaddrPageAlign + 0x10);
+ shm = shmat(shmid, vaddr, SHM_REMAP);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ shm = shmat(shmid, vaddr, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ ret = shmctl(shmid, IPC_RMID, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+void ItTestShm003(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_003", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_004.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4f34419f75c68ab963313e3b2eff0a8b892e6e7b
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_004.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+
+static int Testcase(VOID)
+{
+ int shmid;
+ int ret;
+ void *shm = NULL;
+ struct shmid_ds ds = { 0 };
+ struct shminfo info = { 0 };
+
+ shmid = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
+
+ shm = shmat(shmid, NULL, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(shm, INVALID_PTR, shm);
+
+ (void)memset_s(shm, PAGE_SIZE, 0, PAGE_SIZE);
+
+ ret = shmctl(shmid, IPC_STAT, &ds);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(ds.shm_segsz, PAGE_SIZE, ds.shm_segsz);
+ ICUNIT_ASSERT_EQUAL(ds.shm_nattch, 1, ds.shm_nattch);
+ ICUNIT_ASSERT_EQUAL(ds.shm_cpid, getpid(), ds.shm_cpid);
+ ICUNIT_ASSERT_EQUAL(ds.shm_lpid, getpid(), ds.shm_lpid);
+ ICUNIT_ASSERT_EQUAL(ds.shm_perm.uid, getuid(), ds.shm_perm.uid);
+
+ ret = shmctl(shmid, SHM_STAT, &ds);
+ ICUNIT_ASSERT_EQUAL(ret, 0x10000, ret);
+
+ ds.shm_perm.uid = getuid();
+ ds.shm_perm.gid = getgid();
+ ds.shm_perm.mode = 0;
+ ret = shmctl(shmid, IPC_SET, &ds);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = shmctl(shmid, IPC_INFO, (struct shmid_ds *)&info);
+ ICUNIT_ASSERT_EQUAL(ret, 192, ret);
+ ICUNIT_ASSERT_EQUAL(info.shmmax, 0x1000000, info.shmmax);
+ ICUNIT_ASSERT_EQUAL(info.shmmin, 1, info.shmmin);
+ ICUNIT_ASSERT_EQUAL(info.shmmni, 192, info.shmmni);
+ ICUNIT_ASSERT_EQUAL(info.shmseg, 128, info.shmseg);
+ ICUNIT_ASSERT_EQUAL(info.shmall, 0x1000, info.shmall);
+
+ ret = shmdt(shm);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ ret = shmctl(shmid, IPC_RMID, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+void ItTestShm004(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_004", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_005.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cc57eb992c00fc25d1cb84a6cfb714baa3b7f8da
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_005.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+
+static int Testcase(VOID)
+{
+ int shmid;
+ int ret;
+ void *shm = NULL;
+ void *vaddrPageAlign = NULL;
+ void *vaddr = NULL;
+
+ shmid = shmget(IPC_PRIVATE, PAGE_SIZE, 0);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ errno = 0;
+ shmid = shmget(0x111, PAGE_SIZE, 0777 | IPC_EXCL);
+ ICUNIT_ASSERT_EQUAL(shmid, -1, shmid);
+ ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
+
+ shmid = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
+
+ shm = shmat(shmid, NULL, SHM_REMAP);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ shm = shmat(shmid, (const void *)0x100, 0);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ shm = shmat(shmid, NULL, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(shm, (void *)-1, shm);
+
+ ret = shmdt((const void *)0x100);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ ret = shmdt(shm);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ ret = shmctl(0x111, IPC_RMID, NULL);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ ret = shmctl(shmid, IPC_RMID, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = shmctl(shmid, IPC_RMID, NULL);
+ ICUNIT_ASSERT_EQUAL(errno, EIDRM, errno);
+
+ return 0;
+}
+
+void ItTestShm005(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_005", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_006.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4b78d6f4a3b9f220418b29165242685bfb951064
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_006.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+
+static int Testcase(VOID)
+{
+ const int memSize = PAGE_SIZE;
+ int ret;
+ int shmid;
+ void *shared = NULL;
+ void *remap = NULL;
+
+ shmid = shmget(IPC_PRIVATE, memSize, 0666 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
+
+ shared = shmat(shmid, 0, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
+
+ ret = shmdt(shared);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ remap = shared;
+ shared = shmat(shmid, remap, SHM_REMAP);
+ ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
+
+ ret = shmdt(shared);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ ret = shmctl(shmid, IPC_RMID, NULL);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ return 0;
+}
+
+void ItTestShm006(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_006", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_007.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..83e38df728395d98c9f03efc834bbd99ad4464b4
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_007.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+#include "sys/types.h"
+
+static int Testcase(void)
+{
+ const int memSize = 1024;
+ int shmid;
+ char *shared = NULL;
+ char testStr[] = "hello shmem";
+ pid_t pid;
+ int ret;
+ int status;
+
+ shmid = shmget((key_t)1234, memSize, 0666 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
+
+ ret = fork();
+ if (ret == 0) {
+ usleep(100000);
+ if ((shared = (char *)shmat(shmid, 0, 0)) == (void *)-1) {
+ printf("child : error: shmat()\n");
+ exit(1);
+ }
+
+ if (strncmp(shared, testStr, sizeof(testStr)) != 0) {
+ printf("child : error strncmp() shared = %s\n", shared);
+ exit(1);
+ }
+
+ if ((shmdt(shared)) < 0) {
+ printf("child : error : shmdt()\n");
+ exit(1);
+ }
+
+ if (shmctl(shmid, IPC_RMID, NULL) == -1) {
+ printf("child : error : shmctl()\n");
+ exit(1);
+ }
+
+ exit(0);
+ } else {
+ pid = ret;
+ usleep(50000);
+
+ shared = (char *)shmat(shmid, 0, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
+
+ ret = strncpy_s(shared, memSize, testStr, sizeof(testStr));
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = shmdt(shared);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ usleep(100000);
+
+ ret = wait(&status);
+ status = WEXITSTATUS(status);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+ ICUNIT_ASSERT_EQUAL(status, 0, status);
+ }
+
+ return 0;
+}
+
+void ItTestShm007(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_007", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_008.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..00bb3759d15bacc01adbd8f72a9b6b155736067f
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_008.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+#include "sys/types.h"
+
+static int Testcase(void)
+{
+ const int memSize = PAGE_SIZE;
+ int ret;
+ int shmid;
+ void *shared = NULL;
+
+ shmid = shmget(IPC_PRIVATE, memSize, SHM_R | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
+
+ shared = shmat(shmid, 0, 0);
+ ICUNIT_ASSERT_EQUAL(shared, (void *)-1, shared);
+ ICUNIT_ASSERT_EQUAL(errno, EACCES, errno);
+
+ shared = shmat(shmid, 0, SHM_RDONLY);
+ ICUNIT_ASSERT_NOT_EQUAL(shared, (void *)-1, shared);
+
+ ret = shmdt(shared);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ ret = shmctl(shmid, IPC_RMID, NULL);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ return 0;
+}
+
+void ItTestShm008(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_008", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_009.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_009.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a8aeb1d0c05152109533c1ec9e6ccae54e359979
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_009.cpp
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+#include "sys/types.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+static int *g_shmptr = NULL;
+
+static void ChildProcess(void)
+{
+ struct sched_param param;
+
+ param.sched_priority = sched_get_priority_max(SCHED_RR);
+ if(sched_setparam(getpid(), ¶m) != 0) {
+ printf("An error occurs when calling sched_setparam()");
+ return;
+ }
+
+ /* to avoid blocking */
+ alarm(2);
+ while(1);
+}
+
+static void TestProcess(void)
+{
+ /* to avoid blocking */
+ alarm(5);
+
+ while(1) {
+ (*g_shmptr)++;
+ sched_yield();
+ }
+}
+
+static void ExitChildren(int sig)
+{
+ exit(0);
+}
+
+static void KillChildren(int childPid)
+{
+ kill(childPid, SIGTERM);
+ sleep(1); //wait for kill child finish.
+}
+
+static int Testcase(void)
+{
+ int childPid, oldcount, newcount, shmid;
+ struct sched_param param = {0};
+ struct sched_param paramCopy = {0};
+ int processPolicy = 0;
+ int threadPrio = 0;
+ int ret;
+ int pid;
+
+ void *ptr = (void *)signal(SIGTERM, ExitChildren);
+ ICUNIT_ASSERT_NOT_EQUAL(ptr, NULL, ptr);
+
+ shmid = shmget(IPC_PRIVATE, sizeof(int), IPC_CREAT | 0600);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
+
+ g_shmptr = (int *)shmat(shmid, 0, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(g_shmptr, (int *)-1, g_shmptr);
+
+ *g_shmptr = 0;
+
+ processPolicy = sched_getscheduler(getpid());
+ ret = sched_getparam(getpid(), ¶mCopy);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ param.sched_priority = (sched_get_priority_min(SCHED_RR) +
+ sched_get_priority_max(SCHED_RR)) / 2;
+ ret = sched_setscheduler(getpid(), SCHED_RR, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_getschedparam(pthread_self(), &processPolicy, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ threadPrio = param.sched_priority;
+ ret = pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ childPid = fork();
+ ICUNIT_GOTO_NOT_EQUAL(childPid, -1, childPid, OUT_SCHEDULER);
+
+ if (childPid == 0) {
+ TestProcess();
+ exit(0);
+ }
+ sleep(1);
+
+ param.sched_priority = sched_get_priority_min(SCHED_RR);
+ oldcount = *g_shmptr;
+ ret = sched_setparam(childPid, ¶m);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, OUT_SCHEDULER);
+
+ ret = 1;
+ newcount = *g_shmptr;
+ ICUNIT_GOTO_NOT_EQUAL(oldcount, newcount, newcount, OUT);
+
+ ret = 0;
+OUT:
+ KillChildren(childPid);
+ pid = waitpid(childPid, NULL, 0);
+ ICUNIT_ASSERT_EQUAL(pid, childPid, pid);
+ (void)sched_setparam(getpid(), ¶mCopy);
+OUT_SCHEDULER:
+ (void)sched_setscheduler(getpid(), processPolicy, ¶mCopy);
+ param.sched_priority = threadPrio;
+ pthread_setschedparam(pthread_self(), SCHED_RR, ¶m);
+
+ ret = shmdt(g_shmptr);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ ret = shmctl(shmid, IPC_RMID, NULL);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ return ret;
+}
+
+void ItTestShm009(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_009", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_010.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..73a9b53759a69bd18c2069a80c601fc72f2b6b8b
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_010.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+#include "sys/types.h"
+
+static int Testcase(void)
+{
+ const int memSize = 1024;
+ int shmid;
+ int ret;
+ int status;
+
+ ret = fork();
+ if (ret == 0) {
+ usleep(10000);
+ shmid = shmget((key_t)1234, memSize, 0666 | IPC_CREAT);
+ if (shmid < 0) {
+ if (errno == EACCES) {
+ exit(1);
+ }
+ }
+
+ exit(0);
+ } else {
+ shmid = shmget((key_t)1234, memSize, 0000 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
+ usleep(20000);
+ ret = shmctl(shmid, IPC_RMID, NULL);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ wait(&status);
+ status = WEXITSTATUS(status);
+ ICUNIT_ASSERT_EQUAL(status, 1, status);
+ }
+
+ return 0;
+}
+
+void ItTestShm010(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_010", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_011.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_011.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..8838e1902672f52f35fb8c2e099c7b7ec819027f
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_011.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+#include "sys/types.h"
+
+static int Testcase(void)
+{
+ const int memSize = 1024;
+ int *shared = NULL;
+ int shmid;
+ int ret;
+ int status;
+
+ shmid = shmget((key_t)IPC_PRIVATE, memSize, 0666 | IPC_CREAT);
+ ICUNIT_ASSERT_NOT_EQUAL(shmid, -1, shmid);
+
+ ret = fork();
+ if (ret == 0) {
+ shared = (int *)shmat(shmid, NULL, 0);
+ if (shared == (int *)-1) {
+ exit(1);
+ }
+ *shared = 2;
+ exit(0);
+ } else {
+ usleep(20000);
+ shared = (int *)shmat(shmid, NULL, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(shared, (int *)-1, shared);
+
+ ICUNIT_ASSERT_EQUAL(*shared, 2, *shared);
+
+ ret = shmdt(shared);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ ret = shmctl(shmid, IPC_RMID, NULL);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ wait(&status);
+ status = WEXITSTATUS(status);
+ ICUNIT_ASSERT_EQUAL(status, 0, status);
+ }
+
+ return 0;
+}
+
+void ItTestShm011(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_011", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_012.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_012.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..474e4ebb0df9240695df010ccc69f7f692012115
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_012.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+#include "sys/types.h"
+
+#define SHMNAME "shm_ram"
+#define OPEN_FLAG (O_RDWR | O_CREAT | O_EXCL)
+#define OPEN_MODE 00777
+
+static int Testcase(void)
+{
+ int fd = shm_open(SHMNAME, OPEN_FLAG, OPEN_MODE);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+
+ errno = 0;
+ fd = shm_open(SHMNAME, OPEN_FLAG, OPEN_MODE);
+ ICUNIT_ASSERT_EQUAL(fd, -1, fd);
+ ICUNIT_ASSERT_EQUAL(errno, EEXIST, errno);
+
+ errno = 0;
+ fd = shm_open("SHM_RAM", O_RDONLY, OPEN_MODE);
+ ICUNIT_ASSERT_EQUAL(fd, -1, fd);
+ ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
+
+ errno = 0;
+ fd = shm_open("..../1.txt/123", OPEN_FLAG, OPEN_MODE);
+ ICUNIT_ASSERT_EQUAL(fd, -1, fd);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ errno = 0;
+ fd = shm_open("SHM_RAM", OPEN_FLAG, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+ int ret = shm_unlink(SHMNAME);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = shm_unlink("SHM_RAM");
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ errno = 0;
+ ret = shm_unlink("shm_ram_unlink");
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
+
+ return 0;
+}
+
+void ItTestShm012(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_012", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_013.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_013.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..72375cfe2a6b95b440ee9021c2fe085e99dd23e6
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_013.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+#include "sys/types.h"
+
+static int testcase(void)
+{
+ int shmfd;
+ int ret;
+ int count;
+ int pageSize = getpagesize();
+ char *writebuf = NULL;
+ char *readbuf = NULL;
+
+ shmfd = shm_open("test_1", O_RDWR | O_CREAT | O_EXCL, 0644);
+ ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
+
+ writebuf = (char*)malloc(pageSize);
+ readbuf = (char*)malloc(pageSize);
+ ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf);
+ ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
+ memset_s(writebuf, pageSize, 0xf, pageSize);
+
+ count = write(shmfd, writebuf, pageSize);
+ ICUNIT_ASSERT_EQUAL(count, pageSize, count);
+
+ ret = lseek(shmfd, 0, SEEK_SET);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ count = read(shmfd, readbuf, pageSize);
+ ICUNIT_ASSERT_EQUAL(count, pageSize, count);
+ free(readbuf);
+ free(writebuf);
+ close(shmfd);
+ ret = shm_unlink("test_1");
+ return 0;
+}
+
+void it_test_shm_013(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_013", testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/shm/smoke/shm_test_014.cpp b/testsuites/unittest/mem/shm/smoke/shm_test_014.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c22774740eddc2d1421540f0054f52bbfd544bd1
--- /dev/null
+++ b/testsuites/unittest/mem/shm/smoke/shm_test_014.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_shm.h"
+#include "sys/types.h"
+
+#define SHMNAME "shm_ram"
+
+static int testcase(void)
+{
+ int shmfd;
+ int ret;
+ int count;
+ int pageSize = getpagesize();
+ char *writebuf = NULL;
+ char *readbuf = NULL;
+
+ errno = 0;
+ shmfd = shm_open("test_2", O_RDONLY, 00664);
+ ICUNIT_ASSERT_EQUAL(shmfd, -1, shmfd);
+ ICUNIT_ASSERT_EQUAL(errno, 2, errno);
+
+ shmfd = shm_open("test_2", O_RDONLY | O_CREAT, 00664);
+ ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
+ writebuf = (char*)malloc(pageSize);
+ ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
+ readbuf = (char*)malloc(pageSize);
+ ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf);
+ memset_s(writebuf, pageSize, 0xf, pageSize);
+
+ errno = 0;
+
+ count = write(shmfd, writebuf, pageSize);
+ ICUNIT_ASSERT_EQUAL(count, -1, count);
+ ICUNIT_ASSERT_EQUAL(errno, EACCES, errno);
+ close(shmfd);
+ ret = shm_unlink("test_2");
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ shmfd = shm_open("test_3", O_WRONLY | O_CREAT, 00664);
+ ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ errno = 0;
+ count = write(shmfd, writebuf, pageSize);
+ ICUNIT_ASSERT_EQUAL(count, pageSize, count);
+
+ errno = 0;
+ count = read(shmfd, readbuf, pageSize);
+ ICUNIT_ASSERT_EQUAL(count, -1, count);
+ ICUNIT_ASSERT_EQUAL(errno, EACCES, errno);
+ free(writebuf);
+ free(readbuf);
+ close(shmfd);
+
+ ret = shm_unlink("test_3");
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+void it_test_shm_014(void)
+{
+ TEST_ADD_CASE("IT_MEM_SHM_014", testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
\ No newline at end of file
diff --git a/testsuites/unittest/mem/vm/BUILD.gn b/testsuites/unittest/mem/vm/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..8957523d7e6c8f810abb878950f84f9eded8b5fd
--- /dev/null
+++ b/testsuites/unittest/mem/vm/BUILD.gn
@@ -0,0 +1,66 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../../config.gni")
+
+unittest("liteos_a_mem_vm_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../../common/include",
+ "../../mem/vm",
+ ]
+ sources = [
+ "../../common/osTest.cpp",
+ "mem_vm_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_SMOKE == true) {
+ sources_smoke = [
+ "smoke/mmap_test_001.cpp",
+ "smoke/mmap_test_002.cpp",
+ "smoke/mmap_test_003.cpp",
+ "smoke/mmap_test_004.cpp",
+ "smoke/mmap_test_005.cpp",
+ "smoke/mmap_test_006.cpp",
+ "smoke/mmap_test_007.cpp",
+ "smoke/mmap_test_008.cpp",
+ "smoke/mmap_test_009.cpp",
+ "smoke/mmap_test_010.cpp",
+ "smoke/mprotect_test_001.cpp",
+ "smoke/mremap_test_001.cpp",
+ "smoke/oom_test_001.cpp",
+ "smoke/open_wmemstream_test_001.cpp",
+ "smoke/user_copy_test_001.cpp",
+ ]
+ sources += sources_smoke
+ }
+ configs = [ "../..:public_config" ]
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+}
diff --git a/testsuites/unittest/mem/vm/it_test_vm.h b/testsuites/unittest/mem/vm/it_test_vm.h
new file mode 100644
index 0000000000000000000000000000000000000000..7537401b1b01a3daf60c61eb209bcbcef60e7a88
--- /dev/null
+++ b/testsuites/unittest/mem/vm/it_test_vm.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _IT_TEST_MEM_VM_H
+#define _IT_TEST_MEM_VM_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "osTest.h"
+
+extern void ItTestMmap001(void);
+extern void ItTestMmap002(void);
+extern void ItTestMmap003(void);
+extern void ItTestMmap004(void);
+extern void ItTestMmap005(void);
+extern void ItTestMmap006(void);
+extern void ItTestMmap007(void);
+extern void ItTestMmap008(void);
+extern void ItTestMmap009(void);
+extern void ItTestMmap010(void);
+extern void ItTestMprotect001(void);
+extern void ItTestMremap001(void);
+extern void ItTestOom001(void);
+extern void ItTestUserCopy001(void);
+extern void open_wmemstream_test_001(void);
+#endif
diff --git a/testsuites/unittest/mem/vm/mem_vm_test.cpp b/testsuites/unittest/mem/vm/mem_vm_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1f23739d5426749f28171a18efb71828ca53fb34
--- /dev/null
+++ b/testsuites/unittest/mem/vm/mem_vm_test.cpp
@@ -0,0 +1,213 @@
+/*
+ * 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
+#include
+
+#include "it_test_vm.h"
+
+using namespace testing::ext;
+namespace OHOS {
+class MemVmTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_SMOKE)
+/* *
+ * @tc.name: it_test_mmap_001
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestMmap001, TestSize.Level0)
+{
+ ItTestMmap001();
+}
+#if 0 // need tmpfs
+/* *
+ * @tc.name: it_test_mmap_002
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestMmap002, TestSize.Level0)
+{
+ ItTestMmap002();
+}
+
+/* *
+ * @tc.name: it_test_mmap_003
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestMmap003, TestSize.Level0)
+{
+ ItTestMmap003();
+}
+
+/* *
+ * @tc.name: it_test_mmap_004
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestMmap004, TestSize.Level0)
+{
+ ItTestMmap004();
+}
+#endif
+
+/* *
+ * @tc.name: it_test_mmap_005
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestMmap005, TestSize.Level0)
+{
+ ItTestMmap005();
+}
+
+/* *
+ * @tc.name: it_test_mmap_006
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestMmap006, TestSize.Level0)
+{
+ ItTestMmap006();
+}
+
+/* *
+ * @tc.name: it_test_mmap_007
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestMmap007, TestSize.Level0)
+{
+ ItTestMmap007();
+}
+
+/* *
+ * @tc.name: it_test_mmap_008
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestMmap008, TestSize.Level0)
+{
+ ItTestMmap008();
+}
+
+/* *
+ * @tc.name: it_test_mmap_009
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestMmap009, TestSize.Level0)
+{
+ ItTestMmap009();
+}
+
+/* *
+ * @tc.name: it_test_mmap_010
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: DTS202101220LSHEDP1100
+ */
+HWTEST_F(MemVmTest, ItTestMmap010, TestSize.Level0)
+{
+ ItTestMmap010();
+}
+
+/* *
+ * @tc.name: it_test_mprotect_001
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestMprotect001, TestSize.Level0)
+{
+ ItTestMprotect001();
+}
+
+#ifndef LOSCFG_USER_TEST_SMP
+/* *
+ * @tc.name: it_test_oom_001
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestOom001, TestSize.Level0)
+{
+ ItTestOom001();
+}
+
+#endif
+/* *
+ * @tc.name: it_test_mremap_001
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestMremap001, TestSize.Level0)
+{
+ ItTestMremap001();
+}
+
+/* *
+ * @tc.name: it_test_user_copy_001
+ * @tc.desc: function for MemVmTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, ItTestUserCopy001, TestSize.Level0)
+{
+ ItTestUserCopy001();
+}
+
+/* *
+ * @tc.name: open_wmemstream_test_001
+ * @tc.desc: function for open_wmemstream
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MemVmTest, open_wmemstream_test_001, TestSize.Level0)
+{
+ open_wmemstream_test_001();
+}
+#endif
+} // namespace OHOS
diff --git a/testsuites/unittest/mem/vm/smoke/mmap_test_001.cpp b/testsuites/unittest/mem/vm/smoke/mmap_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1c7f4c4c325d9905398652b333d5e846e3e6bd33
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mmap_test_001.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_vm.h"
+
+#define MAP_ARRAY_SIZE 9
+#define MAP_FLAGS (MAP_ANONYMOUS | MAP_PRIVATE)
+
+static const struct {
+ void *addr;
+ int ret;
+ unsigned int flags;
+} g_gMmapTests[MAP_ARRAY_SIZE] = {
+ {(void *)0, 0, MAP_FLAGS},
+ {(void *)1, -1, MAP_FLAGS | MAP_FIXED},
+ {(void *)(PAGE_SIZE - 1), -1, MAP_FLAGS | MAP_FIXED},
+ {(void *)PAGE_SIZE, -1, MAP_FLAGS | MAP_FIXED},
+ {(void *)-1, 0, MAP_FLAGS},
+ {(void *)(-PAGE_SIZE), -1, MAP_FLAGS | MAP_FIXED},
+ {(void *)(-1 - PAGE_SIZE), -1, MAP_FLAGS | MAP_FIXED},
+ {(void *)(-1 - PAGE_SIZE - 1), -1, MAP_FLAGS | MAP_FIXED},
+ {(void *)(0x1000 * PAGE_SIZE), 0, MAP_FLAGS | MAP_FIXED},
+};
+
+static int Testcase(void)
+{
+ void *p = NULL;
+ int i;
+ int ret;
+ int count = sizeof(g_gMmapTests) / sizeof(g_gMmapTests[0]);
+ void *array[MAP_ARRAY_SIZE] = {NULL};
+
+ for (i = 0; i < count; i++) {
+ p = mmap((void *)g_gMmapTests[i].addr, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, g_gMmapTests[i].flags, -1,
+ 0);
+ ret = (p == MAP_FAILED) ? -1 : 0;
+ ICUNIT_ASSERT_EQUAL(g_gMmapTests[i].ret, ret, p);
+ array[i] = p;
+ }
+
+ for (i = 0; i < count; i++) {
+ if (array[i] == MAP_FAILED) {
+ continue;
+ }
+ ret = munmap(array[i], PAGE_SIZE);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ }
+
+ return 0;
+}
+
+void ItTestMmap001(void)
+{
+ TEST_ADD_CASE("IT_MEM_MMAP_001", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/mmap_test_002.cpp b/testsuites/unittest/mem/vm/smoke/mmap_test_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..06c19c13514176169a644c7d64d5314474264f86
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mmap_test_002.cpp
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_vm.h"
+
+#define MAP_RESERVED0080 0x0080
+
+static int CheckedMmap(int prot, int flags, int fd)
+{
+ void *p = NULL;
+ int pageSize = getpagesize();
+ int ret;
+
+ if (pageSize < 0) {
+ printf("err: mmap size invaild\n");
+ return -1;
+ }
+ p = mmap(NULL, pageSize, prot, flags, fd, 0);
+ if (p == MAP_FAILED) {
+ return errno;
+ } else {
+ ret = munmap(p, pageSize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return 0;
+ }
+}
+
+static int Testcase(void)
+{
+ int shmfd;
+ int ret;
+ int count;
+ int pageSize = getpagesize();
+ char *buf = NULL;
+
+ shmfd = shm_open("/test", O_RDWR | O_CREAT, 0644);
+ ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
+
+ if (pageSize <= 0) {
+ printf("err: malloc size invaild\n");
+ return -1;
+ }
+ if (pageSize <= 0) {
+ printf("err: malloc size invaild\n");
+ return -1;
+ }
+ buf = (char *)malloc(pageSize);
+ ICUNIT_ASSERT_NOT_EQUAL(buf, NULL, buf);
+ (void)memset_s(buf, pageSize, 0xf, pageSize);
+
+ count = write(shmfd, buf, pageSize);
+ ICUNIT_ASSERT_EQUAL(count, pageSize, count);
+
+ free(buf);
+
+ /* Simple MAP_ANONYMOUS */
+ ret = CheckedMmap(PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ /* Simple shm fd shared */
+ ret = CheckedMmap(PROT_READ | PROT_WRITE, MAP_SHARED, shmfd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ /* Simple shm fd private */
+ ret = CheckedMmap(PROT_READ | PROT_WRITE, MAP_PRIVATE, shmfd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ /* MAP_ANONYMOUS with extra PROT flags */
+ ret = CheckedMmap(PROT_READ | PROT_WRITE | 0x100000, MAP_ANONYMOUS, -1);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ /* Shm fd with garbage PROT */
+ ret = CheckedMmap(0xffff, MAP_SHARED, shmfd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ /* Undefined flag. */
+ ret = CheckedMmap(PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_RESERVED0080, -1);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ /* Both MAP_SHARED and MAP_PRIVATE */
+ ret = CheckedMmap(PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_SHARED, -1);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ /* Shm fd with both SHARED and PRIVATE */
+ ret = CheckedMmap(PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_SHARED, shmfd);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ /* At least one of MAP_SHARED or MAP_PRIVATE without ANON */
+ ret = CheckedMmap(PROT_READ | PROT_WRITE, 0, shmfd);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ /* MAP_ANONYMOUS with either sharing flag (impacts fork). */
+ ret = CheckedMmap(PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = CheckedMmap(PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ /* MAP_ANONYMOUS should require an fd of -1. */
+ ret = CheckedMmap(PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = close(shmfd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return 0;
+}
+
+void ItTestMmap002(void)
+{
+ TEST_ADD_CASE("IT_MEM_MMAP_002", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/mmap_test_003.cpp b/testsuites/unittest/mem/vm/smoke/mmap_test_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2508b381c9cd273d1cb2265ba44537bfbc3705e4
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mmap_test_003.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_vm.h"
+
+#define MAP_TEST_FILE "/dev/shm/test"
+
+static int Testcase(void)
+{
+ char *p1 = NULL;
+ char *p2 = NULL;
+ char *p3 = NULL;
+ int fd, pageSize;
+ int ret;
+
+ pageSize = getpagesize();
+ fd = open(MAP_TEST_FILE, O_RDONLY);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+
+ p1 = (char *)mmap(NULL, pageSize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(p1, MAP_FAILED, p1);
+ (void)memset_s(p1, pageSize, 0, pageSize);
+
+ p2 = (char *)mmap(NULL, pageSize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(p2, MAP_FAILED, p2);
+ (void)memset_s(p2, pageSize, 0, pageSize);
+
+ ret = memcmp(p1, p2, pageSize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ p1[0] = 1;
+ ICUNIT_ASSERT_EQUAL(p2[0], 0, p2[0]);
+
+ p2[0] = 2;
+ ICUNIT_ASSERT_EQUAL(p1[0], 1, p1[0]);
+
+ p3 = (char *)mmap(NULL, pageSize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(p3, MAP_FAILED, p3);
+ ICUNIT_ASSERT_EQUAL(p3[0], 0xf, p3[0]);
+
+ ret = munmap(p1, pageSize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = munmap(p2, pageSize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = munmap(p3, pageSize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = close(fd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+void ItTestMmap003(void)
+{
+ TEST_ADD_CASE("IT_MEM_MMAP_003", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/mmap_test_004.cpp b/testsuites/unittest/mem/vm/smoke/mmap_test_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7ab16a865020cd282f998f408b0325f6f239c920
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mmap_test_004.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_vm.h"
+
+#define MAP_TEST_FILE "/dev/shm/test"
+
+static int Testcase(void)
+{
+ char *p1 = NULL;
+ char *p2 = NULL;
+ char *p3 = NULL;
+ int fd, pageSize;
+ int ret;
+
+ pageSize = getpagesize();
+ fd = open(MAP_TEST_FILE, O_RDWR);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+
+ p1 = (char *)mmap(NULL, pageSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(p1, MAP_FAILED, p1);
+ (void)memset_s(p1, pageSize, 0, pageSize);
+
+ p2 = (char *)mmap(NULL, pageSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(p2, MAP_FAILED, p2);
+ (void)memset_s(p2, pageSize, 0, pageSize);
+
+ ret = memcmp(p1, p2, pageSize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ p1[0] = 1;
+ ICUNIT_ASSERT_EQUAL(p2[0], 1, p2[0]);
+
+ p2[0] = 2;
+ ICUNIT_ASSERT_EQUAL(p1[0], 2, p1[0]);
+
+ p3 = (char *)mmap(NULL, pageSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(p3, MAP_FAILED, p3);
+ ICUNIT_ASSERT_EQUAL(p3[0], 2, p3[0]);
+
+ ret = munmap(p1, pageSize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = munmap(p2, pageSize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = munmap(p3, pageSize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = close(fd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+void ItTestMmap004(void)
+{
+ TEST_ADD_CASE("IT_MEM_MMAP_004", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/mmap_test_005.cpp b/testsuites/unittest/mem/vm/smoke/mmap_test_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3685d3e434cdf82db4e337f51209d1fd6d7c2c1a
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mmap_test_005.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_vm.h"
+
+#define MAP_TEST_FILE "/lib/libc.so"
+
+static int Testcase(void)
+{
+ void *map = NULL;
+ int fd;
+
+ fd = open(MAP_TEST_FILE, O_RDONLY);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+
+ map = mmap(NULL, 0, PROT_READ, MAP_PRIVATE, fd, 0);
+ ICUNIT_ASSERT_EQUAL(map, MAP_FAILED, map);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ return 0;
+}
+
+void ItTestMmap005(void)
+{
+ TEST_ADD_CASE("IT_MEM_MMAP_005", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/mmap_test_006.cpp b/testsuites/unittest/mem/vm/smoke/mmap_test_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4908d6140edc5136319f8860eb0c0e1592755f5b
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mmap_test_006.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_vm.h"
+#define INVALID_FD 0xFFFFFFFF
+#define INVALID_VADDR 0xAFFFFFFF
+#define VALIDE_ADDR 0x12000000
+#define ADDR_OFFSET 0X123
+#define OVER_LEN 0x40000000
+#define MAP_LEN 0x1000
+#define FLAG_NUM 3
+
+static int Testcase(void)
+{
+ void *mem = NULL;
+ void *invalueAddr = NULL;
+ size_t len = MAP_LEN;
+ char file[] = "/storage/testMmapEINVAL.txt";
+ int flags[FLAG_NUM] = {0, MAP_ANON, MAP_PRIVATE | MAP_SHARED};
+ int ret, fd;
+
+ fd = open(file, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+
+ invalueAddr = (void *)(VALIDE_ADDR | ADDR_OFFSET);
+ mem = mmap(invalueAddr, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
+ ICUNIT_GOTO_EQUAL(mem, MAP_FAILED, mem, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ mem = mmap((void *)INVALID_VADDR, len, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
+ ICUNIT_GOTO_EQUAL(mem, MAP_FAILED, mem, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ mem = mmap((void *)INVALID_VADDR, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
+ ICUNIT_GOTO_NOT_EQUAL(mem, MAP_FAILED, mem, EXIT);
+ ret = munmap(mem, len);
+ ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
+
+ len = OVER_LEN;
+ mem = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ ICUNIT_GOTO_EQUAL(mem, MAP_FAILED, mem, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ len = MAP_LEN;
+ mem = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, INVALID_FD);
+ ICUNIT_GOTO_EQUAL(mem, MAP_FAILED, mem, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ len = 0;
+ mem = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ ICUNIT_GOTO_EQUAL(mem, MAP_FAILED, mem, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+
+ len = MAP_LEN;
+ for (int i = 0; i < FLAG_NUM; i++) {
+ mem = mmap(NULL, len, PROT_READ | PROT_WRITE, flags[i], fd, 0);
+ ICUNIT_GOTO_EQUAL(mem, MAP_FAILED, mem, EXIT);
+ ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT);
+ }
+
+EXIT:
+ ret = close(fd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = remove(file);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+void ItTestMmap006(void)
+{
+ TEST_ADD_CASE("IT_MEM_MMAP_006", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/mmap_test_007.cpp b/testsuites/unittest/mem/vm/smoke/mmap_test_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..01dce375ef808b8d54037bf728d484571b31aac0
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mmap_test_007.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_vm.h"
+
+#define MAP_LEN 0x200000
+#define MAP_ADDR 0x1200000
+#define MAP_OFFSET 0x100000
+
+static int Testcase(void)
+{
+ size_t len = MAP_LEN;
+ unsigned long fixAddr = MAP_ADDR;
+ unsigned long before, after;
+ size_t shinkLen;
+ unsigned int flags = MAP_ANON | MAP_SHARED | MAP_FIXED;
+ void *mem = NULL;
+ void *prev = NULL;
+ void *next = NULL;
+ void *belong = NULL;
+ int ret;
+
+ mem = mmap((void *)fixAddr, len, PROT_READ | PROT_WRITE, flags, -1, 0);
+ ICUNIT_GOTO_NOT_EQUAL(mem, MAP_FAILED, mem, EXIT);
+
+ before = fixAddr - MAP_OFFSET;
+ prev = mmap((void *)before, len, PROT_READ | PROT_WRITE, flags, -1, 0);
+ ICUNIT_GOTO_NOT_EQUAL(prev, MAP_FAILED, prev, EXIT1);
+
+ after = fixAddr + MAP_OFFSET;
+ next = mmap((void *)after, len, PROT_READ | PROT_WRITE, flags, -1, 0);
+ ICUNIT_GOTO_NOT_EQUAL(next, MAP_FAILED, next, EXIT2);
+
+ shinkLen = len - MAP_OFFSET;
+ belong = mmap((void *)after, shinkLen, PROT_READ | PROT_WRITE, flags, -1, 0);
+ ICUNIT_GOTO_NOT_EQUAL(belong, MAP_FAILED, belong, EXIT3);
+
+ ret = munmap(prev, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = munmap(next, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+
+EXIT1:
+ ret = munmap(mem, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_NOK;
+EXIT2:
+ ret = munmap(mem, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = munmap(prev, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_NOK;
+EXIT3:
+ ret = munmap(prev, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = munmap(next, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+EXIT:
+ return LOS_NOK;
+}
+
+void ItTestMmap007(void)
+{
+ TEST_ADD_CASE("IT_MEM_MMAP_007", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/mmap_test_008.cpp b/testsuites/unittest/mem/vm/smoke/mmap_test_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2d024751bd7c8df6b43ed39709cc6ee4f7a1e54d
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mmap_test_008.cpp
@@ -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 "it_test_vm.h"
+
+#define MAP_OFFSET 0x1000
+#define MAP_ADDR 0x1200000
+#define MAP_LEN 0x2000
+
+static int Testcase(void)
+{
+ unsigned long fixAddr = MAP_ADDR;
+ unsigned int len = MAP_LEN;
+ unsigned int flags = MAP_ANON | MAP_SHARED;
+ void *mem = NULL;
+ void *memFix = NULL;
+ void *memNoFix = NULL;
+ void *pre = NULL;
+ void *next = NULL;
+ void *overlay = NULL;
+ int ret;
+
+ mem = mmap((void *)fixAddr, len, PROT_READ | PROT_WRITE, flags | MAP_FIXED, -1, 0);
+ ICUNIT_GOTO_NOT_EQUAL(mem, MAP_FAILED, mem, EXIT);
+
+ memFix = mmap((void *)fixAddr, len, PROT_READ | PROT_WRITE, flags | MAP_FIXED, -1, 0);
+ ICUNIT_GOTO_NOT_EQUAL(memFix, MAP_FAILED, memFix, EXIT1);
+ ICUNIT_ASSERT_EQUAL(mem, memFix, mem);
+
+ memNoFix = mmap((void *)fixAddr, len, PROT_READ | PROT_WRITE, flags | MAP_FIXED_NOREPLACE, -1, 0);
+ ICUNIT_ASSERT_EQUAL(memNoFix, MAP_FAILED, memNoFix);
+
+ memNoFix = mmap((void *)(fixAddr - MAP_OFFSET), len, PROT_READ | PROT_WRITE, flags | MAP_FIXED_NOREPLACE, -1, 0);
+ ICUNIT_ASSERT_EQUAL(memNoFix, MAP_FAILED, memNoFix);
+
+ memNoFix = mmap((void *)(fixAddr + MAP_OFFSET), len, PROT_READ | PROT_WRITE, flags | MAP_FIXED_NOREPLACE, -1, 0);
+ ICUNIT_ASSERT_EQUAL(memNoFix, MAP_FAILED, memNoFix);
+
+ memNoFix = mmap((void *)(fixAddr - MAP_OFFSET), len + MAP_OFFSET, PROT_READ | PROT_WRITE,
+ flags | MAP_FIXED_NOREPLACE, -1, 0);
+ ICUNIT_ASSERT_EQUAL(memNoFix, MAP_FAILED, memNoFix);
+
+ ret = munmap(mem, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_OK;
+EXIT1:
+ ret = munmap(mem, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return LOS_NOK;
+EXIT:
+ return LOS_NOK;
+}
+
+void ItTestMmap008(void)
+{
+ TEST_ADD_CASE("IT_MEM_MMAP_008", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/mmap_test_009.cpp b/testsuites/unittest/mem/vm/smoke/mmap_test_009.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..57211386e10a1092d88bddf98fd2f0b29d40f712
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mmap_test_009.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "it_test_vm.h"
+
+#define INVALID_PROCESS_ID 100000
+#define MMAP_SIZE 0x1000
+#define PARAM_INIT 0x123
+
+/* Test PROT_NONE flag */
+static int Testcase(void)
+{
+ int ret, param;
+ int *ptr = NULL;
+ int status = 0;
+ pid_t pid = fork();
+ ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
+ if (pid == 0) {
+ ptr = (int *)mmap(0, MMAP_SIZE, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(ptr, MAP_FAILED, ptr);
+ printf("%d\n", *ptr);
+ exit(0);
+ }
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+ ret = WIFEXITED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = WIFSIGNALED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+ ret = WTERMSIG(status);
+ ICUNIT_ASSERT_EQUAL(ret, SIGUSR2, ret);
+
+ pid = fork();
+ ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
+ if (pid == 0) {
+ ptr = (int *)mmap(0, MMAP_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(ptr, MAP_FAILED, ptr);
+ *ptr = PARAM_INIT;
+ ret = mprotect(ptr, MMAP_SIZE, PROT_READ);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(*ptr, PARAM_INIT, *ptr);
+ ret = mprotect(ptr, MMAP_SIZE, PROT_NONE);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ printf("%d\n", *ptr);
+ exit(0);
+ }
+
+ ret = waitpid(pid, &status, 0);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+ ret = WIFEXITED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = WIFSIGNALED(status);
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+ ret = WTERMSIG(status);
+ ICUNIT_ASSERT_EQUAL(ret, SIGUSR2, ret);
+
+ return 0;
+}
+
+void ItTestMmap009(void)
+{
+ TEST_ADD_CASE("IT_MEM_MMAP_009", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/mem/vm/smoke/mmap_test_010.cpp b/testsuites/unittest/mem/vm/smoke/mmap_test_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d36890384acee113cd1c0b0147b19a27007f74a2
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mmap_test_010.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "it_test_vm.h"
+
+#define MMAP_SIZE 0x1000
+#define PARAM_INIT 0x123
+
+/* Test PROT_WRITE and PROT_EXEC flag only */
+static int Testcase(void)
+{
+ int ret;
+ int *ptr = NULL;
+
+ ptr = (int *)mmap(0, MMAP_SIZE, PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(ptr, MAP_FAILED, ptr);
+ *ptr = PARAM_INIT;
+ ICUNIT_ASSERT_EQUAL(*ptr, PARAM_INIT, *ptr);
+ ret = munmap(ptr, MMAP_SIZE);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ptr = (int *)mmap(0, MMAP_SIZE, PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(ptr, MAP_FAILED, ptr);
+ ICUNIT_ASSERT_EQUAL(*ptr, 0, *ptr);
+ ret = munmap(ptr, MMAP_SIZE);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+void ItTestMmap010(void)
+{
+ TEST_ADD_CASE("IT_MEM_MMAP_010", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
+
diff --git a/testsuites/unittest/mem/vm/smoke/mprotect_test_001.cpp b/testsuites/unittest/mem/vm/smoke/mprotect_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f700a8f2a9374f8d9d834958ab673db45ced6986
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mprotect_test_001.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_vm.h"
+
+static int Testcase(void)
+{
+ char *p = NULL;
+ int pageSize;
+ int ret;
+
+ pageSize = getpagesize();
+
+ ret = mprotect(0, pageSize, PROT_NONE);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ ret = mprotect(0, pageSize, 0xffff);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ ret = mprotect((void *)0x1000, pageSize, PROT_READ | PROT_WRITE);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ ret = mprotect((void *)0xffffff, pageSize, PROT_READ | PROT_WRITE);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ p = (char *)mmap(NULL, pageSize * 3, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(p, MAP_FAILED, p);
+
+ ret = mprotect(p, pageSize * 4, PROT_READ | PROT_WRITE);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ ret = mprotect(p, pageSize, PROT_READ | PROT_WRITE);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ (void)memset_s(p, pageSize, 0xf, pageSize);
+
+ ret = mprotect(p + pageSize * 2, pageSize, PROT_READ | PROT_WRITE);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ (void)memset_s(p + pageSize * 2, pageSize, 0xf, pageSize);
+
+ ret = munmap(p, pageSize);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+void ItTestMprotect001(void)
+{
+ TEST_ADD_CASE("IT_MEM_MPROTECT_001", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/mremap_test_001.cpp b/testsuites/unittest/mem/vm/smoke/mremap_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1f2344ed8c6090dd9b8369d7b9939a1d33e4f837
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/mremap_test_001.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_vm.h"
+
+static int Testcase(void)
+{
+ char *p = NULL;
+ void *newAddr = NULL;
+ int pageSize;
+ int size;
+ int ret;
+
+ pageSize = getpagesize();
+ size = pageSize << 1;
+
+ p = (char *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(p, MAP_FAILED, p);
+
+ /* Parameter check */
+ newAddr = mremap(0, 0, 0, 0, 0);
+ ICUNIT_ASSERT_EQUAL(newAddr, MAP_FAILED, newAddr);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ newAddr = mremap(p, size, size, MREMAP_FIXED, 0);
+ ICUNIT_ASSERT_EQUAL(newAddr, MAP_FAILED, newAddr);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ /* Shrink a region */
+ newAddr = mremap(p, size, pageSize, MREMAP_MAYMOVE, 0);
+ ICUNIT_ASSERT_EQUAL(newAddr, p, newAddr);
+
+ /* Remap a region by same size */
+ newAddr = mremap(p, pageSize, pageSize, MREMAP_MAYMOVE, 0);
+ ICUNIT_ASSERT_EQUAL(newAddr, p, newAddr);
+
+ /* Expand a region */
+ newAddr = mremap(p, pageSize, size, MREMAP_MAYMOVE, 0);
+ ICUNIT_ASSERT_EQUAL(newAddr, p, newAddr);
+
+ /* New region overlaping with the old one */
+ newAddr = mremap(p, size, pageSize, MREMAP_MAYMOVE | MREMAP_FIXED, p + pageSize);
+ ICUNIT_ASSERT_EQUAL(newAddr, MAP_FAILED, newAddr);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ newAddr = mremap(p, size, size, MREMAP_MAYMOVE | MREMAP_FIXED, p - pageSize);
+ ICUNIT_ASSERT_EQUAL(newAddr, MAP_FAILED, newAddr);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ newAddr = mremap(p, size, size + pageSize, MREMAP_MAYMOVE | MREMAP_FIXED, p - pageSize);
+ ICUNIT_ASSERT_EQUAL(newAddr, MAP_FAILED, newAddr);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ /* Remap to new addr */
+ newAddr = mremap(p, size, size, MREMAP_MAYMOVE | MREMAP_FIXED, p + size);
+ ICUNIT_ASSERT_EQUAL(newAddr, p + size, newAddr);
+
+ newAddr = mremap(newAddr, size, size, MREMAP_MAYMOVE | MREMAP_FIXED, (char *)newAddr - size);
+ ICUNIT_ASSERT_EQUAL(newAddr, p, newAddr);
+
+ ret = munmap(p, size);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return 0;
+}
+
+void ItTestMremap001(void)
+{
+ TEST_ADD_CASE("IT_MEM_MREMAP_001", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/oom_test_001.cpp b/testsuites/unittest/mem/vm/smoke/oom_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..adec8b50c996d58ae121be4f04e2b3047cdb2f33
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/oom_test_001.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_vm.h"
+
+#define MAX_MEM_SIZE 0x6000000
+/* test page fault oom */
+static int Testcase(void)
+{
+ int ret;
+ int status;
+ int pid;
+ unsigned int *ptr = NULL;
+
+ ret = fork();
+ if (ret == 0) {
+ ptr = (unsigned int *)mmap(0, MAX_MEM_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(ptr, MAP_FAILED, ptr);
+ /* expect oom */
+ for (int i = 0; i < MAX_MEM_SIZE / PAGE_SIZE; i++) {
+ *(ptr + i * PAGE_SIZE / sizeof(unsigned int)) = 0;
+ }
+
+ /* if we go here, phy mem is enough, should increase the MAX_MEM_SIZE and rerun */
+ ICUNIT_ASSERT_EQUAL(1, 0, 1);
+ } else {
+ pid = ret;
+ ret = waitpid(pid, &status, 0);
+ status = WIFSIGNALED(status);
+ ICUNIT_ASSERT_EQUAL(ret, pid, ret);
+ ICUNIT_ASSERT_EQUAL(status, 1, status);
+ }
+
+ return 0;
+}
+
+void ItTestOom001(void)
+{
+ TEST_ADD_CASE("IT_MEM_OOM_001", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/open_wmemstream_test_001.cpp b/testsuites/unittest/mem/vm/smoke/open_wmemstream_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cb1e222587ccd84f1b24e3cf6a2bfc3914f31c70
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/open_wmemstream_test_001.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "it_test_vm.h"
+#include "wchar.h"
+
+static int testcase(void)
+{
+ FILE *stream = nullptr;
+ wchar_t *buf = nullptr;
+ size_t len = 0;
+
+ stream = open_wmemstream(&buf, &len);
+ ICUNIT_ASSERT_NOT_EQUAL(stream, nullptr, stream);
+
+ fwprintf(stream, L"hello my world");
+ int ret = fflush(stream);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(len, 14, len);
+ off_t eob = ftello(stream);
+ ret = fseeko(stream, 0, SEEK_SET);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ fwprintf(stream, L"good-bye");
+ ret = fseeko(stream, eob, SEEK_SET);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = fclose(stream);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(len, 8, len);
+ free(buf);
+ return 0;
+}
+
+void open_wmemstream_test_001(void)
+{
+ TEST_ADD_CASE("OPEN_WMEMSTEAM_TEST_001", testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/mem/vm/smoke/user_copy_test_001.cpp b/testsuites/unittest/mem/vm/smoke/user_copy_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f506db0b68b4b3acfe016dc157bb2afa8739b0ce
--- /dev/null
+++ b/testsuites/unittest/mem/vm/smoke/user_copy_test_001.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "it_test_vm.h"
+#include "signal.h"
+
+#define INVALID_USER_VADDR 0x1200000
+
+static int Testcase(void)
+{
+ int ret;
+ sigset_t oldset;
+ const char *str = "Hi, OHOS.";
+
+ /* sigprocmask å†…æ ¸ç³»ç»Ÿè°ƒç”¨æŽ¥å£é€šè¿‡arch_copy_from_useræ‹·è´ç”¨æˆ·å‚æ•° */
+ ret = sigprocmask(SIG_BLOCK, (sigset_t *)1, &oldset);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
+
+ ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, &oldset);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
+
+ /* sigprocmask å†…æ ¸ç³»ç»Ÿè°ƒç”¨æŽ¥å£é€šè¿‡arch_copy_to_userå°†å†…æ ¸å‚æ•°æ‹·è´è‡³ç”¨æˆ· */
+ ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)1);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
+
+ ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)INVALID_USER_VADDR);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
+
+ ret = sigprocmask(SIG_BLOCK, (sigset_t *)INVALID_USER_VADDR, (sigset_t *)str);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
+
+ return 0;
+}
+
+void ItTestUserCopy001(void)
+{
+ TEST_ADD_CASE("IT_MEM_USER_COPY_001", Testcase, TEST_LOS, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/BUILD.gn b/testsuites/unittest/misc/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..63781029b0e4978783971e2d4bfd16f97035b120
--- /dev/null
+++ b/testsuites/unittest/misc/BUILD.gn
@@ -0,0 +1,73 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../config.gni")
+
+unittest("liteos_a_misc_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../common/include",
+ "../misc",
+ ]
+
+ sources = [
+ "../common/osTest.cpp",
+ "misc_test.cpp",
+ ]
+
+ if (LOSCFG_USER_TEST_FULL == true) {
+ sources_full = [
+ "full/misc_test_006.cpp",
+ "full/misc_test_007.cpp",
+ "full/misc_test_010.cpp",
+ "full/misc_test_011.cpp",
+ "full/misc_test_012.cpp",
+ "full/misc_test_013.cpp",
+ ]
+ sources += sources_full
+ }
+ if (LOSCFG_USER_TEST_SMOKE == true) {
+ sources_smoke = [
+ "smoke/misc_test_001.cpp",
+ "smoke/misc_test_002.cpp",
+ "smoke/misc_test_003.cpp",
+ "smoke/misc_test_004.cpp",
+ "smoke/misc_test_005.cpp",
+ "smoke/misc_test_008.cpp",
+ "smoke/misc_test_009.cpp",
+ "smoke/misc_test_014.cpp",
+ ]
+ sources += sources_smoke
+ }
+
+ configs = [ "..:public_config" ]
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+}
diff --git a/testsuites/unittest/misc/It_test_misc.h b/testsuites/unittest/misc/It_test_misc.h
new file mode 100644
index 0000000000000000000000000000000000000000..909c1c6d6d8e8411978adafe728e83c1fa2675e3
--- /dev/null
+++ b/testsuites/unittest/misc/It_test_misc.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _IT_TEST_MISC_H
+#define _IT_TEST_MISC_H
+
+#include "osTest.h"
+#include "getopt.h"
+#include "stdlib.h"
+#include "err.h"
+#include "unistd.h"
+#include "search.h"
+#define MISC_OK 0
+#define MISC_NOK -1
+
+extern VOID ItTestMisc001(VOID);
+extern VOID ItTestMisc002(VOID);
+extern VOID ItTestMisc003(VOID);
+extern VOID ItTestMisc004(VOID);
+extern VOID ItTestMisc005(VOID);
+extern VOID ItTestMisc006(VOID);
+extern VOID ItTestMisc007(VOID);
+extern VOID ItTestMisc008(VOID);
+extern VOID ItTestMisc009(VOID);
+extern VOID ItTestMisc010(VOID);
+extern VOID ItTestMisc011(VOID);
+extern VOID ItTestMisc012(VOID);
+extern VOID ItTestMisc013(VOID);
+extern VOID IT_TEST_MISC_014(VOID);
+
+#endif
diff --git a/testsuites/unittest/misc/full/misc_test_006.cpp b/testsuites/unittest/misc/full/misc_test_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..616edf51ac5e543e6ac2ec515d6f2f58fc6b3530
--- /dev/null
+++ b/testsuites/unittest/misc/full/misc_test_006.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+#include "sys/utsname.h"
+
+#define INVALID_ADDR_FIRST_PAGE ((struct utsname *)0x1200000)
+#define INVALID_ADDR_USER_ADDR ((struct utsname *)0x1000000)
+#define INVALID_ADDR_KERNEL_READONLY_ADDR ((struct utsname *)0x4016c75c)
+
+static UINT32 TestCase(VOID)
+{
+ int ret;
+ struct utsname name;
+
+ ret = uname((struct utsname *)NULL);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
+
+ ret = uname(INVALID_ADDR_FIRST_PAGE);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
+
+ ret = uname(INVALID_ADDR_USER_ADDR);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
+
+ ret = uname(INVALID_ADDR_KERNEL_READONLY_ADDR);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
+
+ ret = uname(&name);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ return 0;
+}
+
+VOID ItTestMisc006(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/full/misc_test_007.cpp b/testsuites/unittest/misc/full/misc_test_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c479cfcb00495575d3da1419f41826cf51dd1041
--- /dev/null
+++ b/testsuites/unittest/misc/full/misc_test_007.cpp
@@ -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.
+ */
+#include "It_test_misc.h"
+
+static UINT32 TestCase(VOID)
+{
+ int ret;
+
+ ret = sysconf(_SC_AIO_LISTIO_MAX);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = sysconf(_SC_ARG_MAX);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ ret = sysconf(_SC_ATEXIT_MAX);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, -1);
+
+ return 0;
+}
+
+VOID ItTestMisc007(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/full/misc_test_010.cpp b/testsuites/unittest/misc/full/misc_test_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ec0feb9d89b1c0dd89370e5b3e72a8b8967d5d8a
--- /dev/null
+++ b/testsuites/unittest/misc/full/misc_test_010.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+
+static UINT32 TestCase(VOID)
+{
+ int ret;
+ int rlimit = 512;
+
+ ret = getdtablesize();
+ ICUNIT_ASSERT_EQUAL(ret, rlimit, ret);
+
+ return 0;
+}
+
+VOID ItTestMisc010(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/full/misc_test_011.cpp b/testsuites/unittest/misc/full/misc_test_011.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1b849ab5d2d648da06ba269aadad4ebb91662ca4
--- /dev/null
+++ b/testsuites/unittest/misc/full/misc_test_011.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+
+static UINT32 TestCase(VOID)
+{
+ int ret;
+ struct rlimit rlim;
+ int limit = 512;
+
+ errno = 0;
+ ret = getrlimit(RLIMIT_NOFILE, &rlim);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(rlim.rlim_cur, limit, -1);
+ ret = getrlimit(RLIMIT_RSS, &rlim);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, -1);
+
+ return 0;
+}
+
+VOID ItTestMisc011(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/full/misc_test_012.cpp b/testsuites/unittest/misc/full/misc_test_012.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..32d5ac879072c3c2de81bd1a5c20bc61a4d8a332
--- /dev/null
+++ b/testsuites/unittest/misc/full/misc_test_012.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+
+static UINT32 TestCase(VOID)
+{
+ int ret;
+ struct rlimit rlim1;
+ struct rlimit rlim2 = {10, 10};
+
+ errno = 0;
+ ret = setrlimit(RLIMIT_NOFILE, &rlim2);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ ret = getrlimit(RLIMIT_NOFILE, &rlim1);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(rlim1.rlim_cur, rlim2.rlim_cur, ret);
+ ICUNIT_ASSERT_EQUAL(rlim1.rlim_max, rlim2.rlim_max, ret);
+
+ ret = setrlimit(RLIMIT_FSIZE, &rlim2);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ ret = getrlimit(RLIMIT_FSIZE, &rlim1);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(rlim1.rlim_cur, rlim2.rlim_cur, ret);
+ ICUNIT_ASSERT_EQUAL(rlim1.rlim_max, rlim2.rlim_max, ret);
+
+ ret = setrlimit(RLIMIT_AS, &rlim2);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, -1);
+
+ ret = setrlimit(RLIMIT_DATA, &rlim2);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, -1);
+
+ ret = setrlimit(-100, &rlim2);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, -1);
+
+ return 0;
+}
+
+VOID ItTestMisc012(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/full/misc_test_013.cpp b/testsuites/unittest/misc/full/misc_test_013.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..07fd2f4925b3c18fd0ed11c26a7d6922822eaf29
--- /dev/null
+++ b/testsuites/unittest/misc/full/misc_test_013.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+#include "ulimit.h"
+
+static UINT32 TestCase(VOID)
+{
+ long ret;
+ long size = 200;
+ long max = 0x7fffffff;
+
+ ret = ulimit(UL_SETFSIZE, size);
+ ICUNIT_ASSERT_EQUAL(ret, size, -1);
+
+ ret = ulimit(UL_GETFSIZE, size);
+ ICUNIT_ASSERT_EQUAL(ret, size, ret);
+
+ ret = ulimit(size, size);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, ret);
+
+ ret = ulimit(UL_SETFSIZE, max);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ ICUNIT_ASSERT_EQUAL(errno, EPERM, ret);
+ return 0;
+}
+
+VOID ItTestMisc013(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/misc_test.cpp b/testsuites/unittest/misc/misc_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2bcc66e19000e53b42ee2d0d24544bb0e0e53471
--- /dev/null
+++ b/testsuites/unittest/misc/misc_test.cpp
@@ -0,0 +1,170 @@
+/*
+ * 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 "stdio.h"
+#include
+#include
+
+#include "It_test_misc.h"
+
+using namespace testing::ext;
+namespace OHOS {
+class MiscTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_SMOKE)
+/* *
+ * @tc.name: IT_TEST_MISC_001
+ * @tc.desc: function for MiscTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MiscTest, ItTestMisc001, TestSize.Level0)
+{
+ ItTestMisc001();
+}
+
+/* *
+ * @tc.name: IT_TEST_MISC_002
+ * @tc.desc: function for MiscTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MiscTest, ItTestMisc002, TestSize.Level0)
+{
+ ItTestMisc002();
+}
+
+/* *
+ * @tc.name: IT_TEST_MISC_003
+ * @tc.desc: function for MiscTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MiscTest, ItTestMisc003, TestSize.Level0)
+{
+ ItTestMisc003();
+}
+
+/* *
+ * @tc.name: IT_TEST_MISC_004
+ * @tc.desc: function for MiscTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MiscTest, ItTestMisc004, TestSize.Level0)
+{
+ ItTestMisc004();
+}
+
+/* *
+ * @tc.name: IT_TEST_MISC_005
+ * @tc.desc: function for MiscTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MiscTest, ItTestMisc005, TestSize.Level0)
+{
+ ItTestMisc005();
+}
+
+/* *
+ * @tc.name: IT_TEST_MISC_014
+ * @tc.desc: function for tmpnam test
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MiscTest, IT_TEST_MISC_014, TestSize.Level0)
+{
+ IT_TEST_MISC_014();
+}
+#endif
+
+#if defined(LOSCFG_USER_TEST_FULL)
+/* *
+ * @tc.name: IT_TEST_MISC_006
+ * @tc.desc: function for MiscTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(MiscTest, ItTestMisc006, TestSize.Level0)
+{
+ ItTestMisc006();
+}
+
+/* *
+ * @tc.name: IT_TEST_MISC_007
+ * @tc.desc: function for MiscTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+/*HWTEST_F(MiscTest, ItTestMisc007, TestSize.Level0)
+{
+ ItTestMisc007();
+}*/
+
+/* *
+ * @tc.name: IT_TEST_MISC_010
+ * @tc.desc: function for MiscTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+/*HWTEST_F(MiscTest, ItTestMisc010, TestSize.Level0)
+{
+ ItTestMisc010();
+}*/
+
+/* *
+ * @tc.name: IT_TEST_MISC_011
+ * @tc.desc: function for MiscTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+/*HWTEST_F(MiscTest, ItTestMisc011, TestSize.Level0)
+{
+ ItTestMisc011();
+}*/
+
+/* *
+ * @tc.name: IT_TEST_MISC_013
+ * @tc.desc: function for MiscTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+/*HWTEST_F(MiscTest, ItTestMisc013, TestSize.Level0)
+{
+ ItTestMisc013();
+}*/
+#endif
+
+} // namespace OHOS
diff --git a/testsuites/unittest/misc/smoke/misc_test_001.cpp b/testsuites/unittest/misc/smoke/misc_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a2d2a75e25b0fe2509b22212094c39ce4a694a16
--- /dev/null
+++ b/testsuites/unittest/misc/smoke/misc_test_001.cpp
@@ -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.
+ */
+#include "It_test_misc.h"
+
+#define TEST_MEMSIZE 8
+static UINT32 TestCase(VOID)
+{
+ VOID *ptr = NULL;
+
+ ptr = valloc(TEST_MEMSIZE);
+ ICUNIT_GOTO_NOT_EQUAL(ptr, NULL, ptr, EXIT);
+
+ free(ptr);
+
+ return MISC_OK;
+EXIT:
+ free(ptr);
+ return MISC_NOK;
+}
+
+VOID ItTestMisc001(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/smoke/misc_test_002.cpp b/testsuites/unittest/misc/smoke/misc_test_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4468038157457d3ee6e0f850cdd41bbdfd7f4822
--- /dev/null
+++ b/testsuites/unittest/misc/smoke/misc_test_002.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+
+#define TEST_OK "success"
+#define STR_LEN 20
+
+static VOID Vwarnfuc(const char *format, ...)
+{
+ va_list arglist;
+
+ va_start(arglist, format);
+ vwarn(format, arglist);
+ va_end(arglist);
+}
+
+static UINT32 TestCase(VOID)
+{
+ CHAR ptr[STR_LEN] = TEST_OK;
+ Vwarnfuc("%s", ptr);
+ return 0;
+}
+
+VOID ItTestMisc002(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/smoke/misc_test_003.cpp b/testsuites/unittest/misc/smoke/misc_test_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1269a61c536924f6d9e400a480f08e5689acdf81
--- /dev/null
+++ b/testsuites/unittest/misc/smoke/misc_test_003.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+
+#define TEST_OK "success"
+#define STR_LEN 20
+
+static VOID Vwarnxfuc(const char *format, ...)
+{
+ va_list arglist;
+
+ va_start(arglist, format);
+ vwarnx(format, arglist);
+ va_end(arglist);
+}
+
+static UINT32 TestCase(VOID)
+{
+ CHAR ptr[STR_LEN] = TEST_OK;
+ Vwarnxfuc("%s", ptr);
+ return 0;
+}
+
+VOID ItTestMisc003(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/smoke/misc_test_004.cpp b/testsuites/unittest/misc/smoke/misc_test_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f692d95f16809686084c406c5b28ae488f5d025a
--- /dev/null
+++ b/testsuites/unittest/misc/smoke/misc_test_004.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+
+#define TEST_OK "success"
+#define STR_LEN 20
+
+static VOID Verrfuc(INT32 fpid, const char *format, ...)
+{
+ va_list arglist;
+
+ va_start(arglist, format);
+ verr(fpid, format, arglist);
+ va_end(arglist);
+}
+
+static UINT32 TestCase(VOID)
+{
+ CHAR ptr[STR_LEN] = TEST_OK;
+ INT32 fpid;
+
+ fpid = fork();
+ if (fpid == 0) {
+ Verrfuc(fpid, "%s", ptr);
+ }
+ usleep(20);
+ return 0;
+}
+
+VOID ItTestMisc004(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/smoke/misc_test_005.cpp b/testsuites/unittest/misc/smoke/misc_test_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e377ae487cee9a64f310623373cd67e0ac76041d
--- /dev/null
+++ b/testsuites/unittest/misc/smoke/misc_test_005.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+
+#define TEST_OK "success"
+#define STR_LEN 20
+
+static VOID Verrxfuc(INT32 fpid, const char *format, ...)
+{
+ va_list arglist;
+
+ va_start(arglist, format);
+ verrx(fpid, format, arglist);
+ va_end(arglist);
+}
+
+static UINT32 TestCase(VOID)
+{
+ CHAR ptr[STR_LEN] = TEST_OK;
+ INT32 fpid;
+
+ fpid = fork();
+ if (fpid == 0) {
+ Verrxfuc(fpid, "%s", ptr);
+ }
+ usleep(20);
+ return 0;
+}
+
+VOID ItTestMisc005(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/smoke/misc_test_008.cpp b/testsuites/unittest/misc/smoke/misc_test_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a2ec7a8bbd760a15267f1198e09121a86b23e4e4
--- /dev/null
+++ b/testsuites/unittest/misc/smoke/misc_test_008.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+
+static UINT32 TestCase(VOID)
+{
+ char host[100] = {0};
+ int ret = 0;
+
+ ret = gethostname(host, sizeof(host));
+
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ printf("host = %s\n", host);
+
+ return 0;
+}
+
+VOID ItTestMisc008(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/smoke/misc_test_009.cpp b/testsuites/unittest/misc/smoke/misc_test_009.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c8dcf10e6f836ce513b99262acfb3a7ad8376e1b
--- /dev/null
+++ b/testsuites/unittest/misc/smoke/misc_test_009.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+
+static UINT32 TestCase(VOID)
+{
+ long ret;
+
+ ret = gethostid();
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ return 0;
+}
+
+VOID ItTestMisc009(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/misc/smoke/misc_test_014.cpp b/testsuites/unittest/misc/smoke/misc_test_014.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1dffbe51393ecc52d20a0038c2116ddc4b471385
--- /dev/null
+++ b/testsuites/unittest/misc/smoke/misc_test_014.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "It_test_misc.h"
+
+static UINT32 TestCase(VOID)
+{
+ char *name1 = nullptr;
+ char name2[100] = { 0 };
+ char name3[100] = "hello";
+ int ret;
+
+ name1 = tmpnam(NULL);
+ ICUNIT_ASSERT_NOT_EQUAL(name1, nullptr, -1);
+ ret = strncmp(name1, "/tmp/tmpnam_", 12);
+ ICUNIT_ASSERT_EQUAL(ret, 0, -1);
+
+ tmpnam(name2);
+ ICUNIT_ASSERT_NOT_EQUAL(name2[0], 0, -1);
+ ret = strncmp(name2, "/tmp/tmpnam_", 12);
+ ICUNIT_ASSERT_EQUAL(ret, 0, -1);
+
+ tmpnam(name2);
+ ret = strncmp(name2, "/tmp/tmpnam_", 12);
+ ICUNIT_ASSERT_EQUAL(ret, 0, -1);
+
+ return LOS_OK;
+}
+
+VOID IT_TEST_MISC_014(VOID)
+{
+ TEST_ADD_CASE(__FUNCTION__, TestCase, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/BUILD.gn b/testsuites/unittest/net/netdb/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..7f34d79bc938ddde59965f0c3392c6283868c377
--- /dev/null
+++ b/testsuites/unittest/net/netdb/BUILD.gn
@@ -0,0 +1,82 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../../config.gni")
+
+config("net_local_config") {
+ if (LOSCFG_USER_TEST_NET_NETDB == true) {
+ cflags = [ "-DLOSCFG_USER_TEST_NET_NETDB" ]
+ cflags_cc = cflags
+ }
+}
+
+unittest("liteos_a_net_netdb_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../../common/include",
+ "./",
+ ]
+ sources = [
+ "../../common/osTest.cpp",
+ "net_netdb_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_FULL == true) {
+ sources_full = [
+ "full/net_netdb_test_001.cpp",
+ "full/net_netdb_test_002.cpp",
+ "full/net_netdb_test_003.cpp",
+ "full/net_netdb_test_004.cpp",
+ "full/net_netdb_test_005.cpp",
+ "full/net_netdb_test_006.cpp",
+ "full/net_netdb_test_007.cpp",
+ "full/net_netdb_test_008.cpp",
+ "full/net_netdb_test_009.cpp",
+ "full/net_netdb_test_010.cpp",
+ "full/net_netdb_test_011.cpp",
+ "full/net_netdb_test_012.cpp",
+ "full/net_netdb_test_013.cpp",
+ "full/net_netdb_test_014.cpp",
+ "full/net_netdb_test_015.cpp",
+ "full/net_netdb_test_016.cpp",
+ "full/net_netdb_test_017.cpp",
+ "full/net_netdb_test_018.cpp",
+ "full/net_netdb_test_019.cpp",
+ "full/net_netdb_test_020.cpp",
+ "full/net_netdb_test_021.cpp",
+ "full/net_netdb_test_022.cpp",
+ ]
+ sources += sources_full
+ }
+ configs = [
+ "../..:public_config",
+ ":net_local_config",
+ ]
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_001.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1e0b53af06e45dc5d10609085335101329b0fca3
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_001.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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 "lt_net_netdb.h"
+
+static int ProtoentTest(void)
+{
+ setprotoent(1);
+
+ // refer to the `/etc/protocols' file.
+ struct protoent *prot = getprotobyname("icmp");
+ ICUNIT_ASSERT_NOT_EQUAL(prot, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(prot->p_proto, 1, prot->p_proto);
+
+ prot = getprotobynumber(1);
+ ICUNIT_ASSERT_NOT_EQUAL(prot, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(strcmp(prot->p_name, "icmp"), 0, -1);
+
+ prot = getprotoent();
+ ICUNIT_ASSERT_NOT_EQUAL(prot, NULL, -1);
+
+ endprotoent();
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, ProtoentTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_002.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bb124c5c364b34026fea8f1c4dc3d67a04e76aa4
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_002.cpp
@@ -0,0 +1,59 @@
+/*
+ * 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 "lt_net_netdb.h"
+
+static int AddrInfoTest(void)
+{
+ // Prerequisite: correct DNS servers must be configured.
+ struct addrinfo *addr = NULL;
+ int ret = getaddrinfo("example.com", "ftp", NULL, &addr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ freeaddrinfo(addr);
+
+ ret = getaddrinfo("local", "ftp", NULL, &addr);
+ ICUNIT_ASSERT_EQUAL(ret, EAI_AGAIN, ret);
+
+ ret = getaddrinfo("localhost", "fp", NULL, &addr);
+ ICUNIT_ASSERT_EQUAL(ret, EAI_SERVICE, ret);
+
+ const char *p = gai_strerror(EAI_AGAIN);
+ ICUNIT_ASSERT_NOT_EQUAL(p, NULL, -1);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest002(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, AddrInfoTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_003.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..229c3ad5d784c08dbd203957eff63500b22f2ab6
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_003.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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 "lt_net_netdb.h"
+
+static int IfAddrsTest(void)
+{
+ // Prerequisite: correct DNS servers must be configured.
+ struct ifaddrs *addr = NULL;
+ int ret = getifaddrs(&addr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_NOT_EQUAL(addr, NULL, -1);
+
+ freeifaddrs(addr);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest003(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, IfAddrsTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_004.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..aeea1cc32037d724a828599edc9c7e5752f4eb2c
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_004.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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 "lt_net_netdb.h"
+
+static int GetHostByAddrTest(void)
+{
+ struct in_addr ia;
+ int length = 4;
+ ia.s_addr = inet_addr("127.0.0.1");
+ struct hostent *addr = gethostbyaddr(&ia, sizeof ia, AF_INET);
+ ICUNIT_ASSERT_NOT_EQUAL(addr, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(addr->h_addrtype, AF_INET, addr->h_addrtype);
+ ICUNIT_ASSERT_STRING_EQUAL(addr->h_name, "localhost", -1);
+ ICUNIT_ASSERT_EQUAL(addr->h_length, length, -1);
+
+ ia.s_addr = inet_addr("100.109.180.184");
+ addr = gethostbyaddr(&ia, sizeof ia, AF_INET);
+ ICUNIT_ASSERT_NOT_EQUAL(addr, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(addr->h_addrtype, AF_INET, addr->h_addrtype);
+ ICUNIT_ASSERT_STRING_EQUAL(addr->h_name, "szvphisprb93341", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(addr->h_aliases[0], "szvphisprb93341", -1);
+
+ errno = 0;
+ ia.s_addr = inet_addr("127.0.0.0");
+ addr = gethostbyaddr(&ia, sizeof ia, AF_INET);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ return ICUNIT_SUCCESS;
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest004(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetHostByAddrTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_005.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7fe49c768aa1d567d80e6a64cef5b4794619d089
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_005.cpp
@@ -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.
+ */
+
+#include "lt_net_netdb.h"
+
+static int GetHostByAddrRTest(void)
+{
+ struct in_addr ia;
+ struct hostent addr, *result = NULL;
+ char buf[1024];
+ char buf1[1];
+ int err, ret;
+ int length = 4;
+
+ ia.s_addr = inet_addr("127.0.0.1");
+ ret = gethostbyaddr_r(&ia, sizeof ia, AF_INET, &addr, buf, sizeof buf, &result, &err);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_NOT_EQUAL(result, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(result->h_addrtype, AF_INET, result->h_addrtype);
+ ICUNIT_ASSERT_STRING_EQUAL(result->h_name, "localhost", -1);
+ ICUNIT_ASSERT_EQUAL(result->h_length, length, -1);
+
+ errno = 0;
+ ia.s_addr = inet_addr("127.0.0.0");
+ ret = gethostbyaddr_r(&ia, sizeof ia, AF_INET, &addr, buf, sizeof buf, &result, &err);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ ret = gethostbyaddr_r(&ia, sizeof ia, AF_INET, &addr, buf, sizeof buf, &result, &err);
+ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
+
+ ret = gethostbyaddr_r(&ia, sizeof ia, AF_INET, &addr, buf1, sizeof buf1, &result, &err);
+ ICUNIT_ASSERT_EQUAL(ret, ERANGE, ret);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest005(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetHostByAddrRTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_006.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b9932e8105d80fa93ebc0e85148c7f6f76dacb8c
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_006.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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 "lt_net_netdb.h"
+
+static int GetHostByNameTest(void)
+{
+ struct hostent *addr = gethostbyname("localhost");
+ ICUNIT_ASSERT_NOT_EQUAL(addr, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(strcmp(addr->h_name, "localhost"), 0, -1);
+ ICUNIT_ASSERT_EQUAL(addr->h_addrtype, AF_INET, addr->h_addrtype);
+ ICUNIT_ASSERT_NOT_EQUAL(addr->h_length, 0, addr->h_length);
+
+ addr = gethostbyname("127.0.0.1");
+ ICUNIT_ASSERT_NOT_EQUAL(addr, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(strcmp(addr->h_name, "127.0.0.1"), 0, -1);
+ ICUNIT_ASSERT_EQUAL(addr->h_addrtype, AF_INET, addr->h_addrtype);
+ ICUNIT_ASSERT_NOT_EQUAL(addr->h_length, 0, addr->h_length);
+
+ addr = gethostbyname("lo");
+ ICUNIT_ASSERT_EQUAL(addr, NULL, -1);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest006(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetHostByNameTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_007.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..712e5b97b2089ea6aef55790c2ab28788d092715
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_007.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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 "lt_net_netdb.h"
+
+static int GetHostByNameRTest(void)
+{
+ struct hostent addr, *result = NULL;
+ char buf[1024];
+ char buf1[1];
+ int err, ret;
+
+ ret = gethostbyname_r("localhost", &addr, buf, sizeof buf, &result, &err);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_NOT_EQUAL(result, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(strcmp(result->h_name, "localhost"), 0, -1);
+ ICUNIT_ASSERT_EQUAL(result->h_addrtype, AF_INET, result->h_addrtype);
+ ICUNIT_ASSERT_NOT_EQUAL(result->h_length, 0, result->h_length);
+
+ ret = gethostbyname_r("127.0.0.1", &addr, buf, sizeof buf, &result, &err);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_NOT_EQUAL(result, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(strcmp(result->h_name, "127.0.0.1"), 0, -1);
+ ICUNIT_ASSERT_EQUAL(result->h_addrtype, AF_INET, result->h_addrtype);
+ ICUNIT_ASSERT_NOT_EQUAL(result->h_length, 0, result->h_length);
+
+ ret = gethostbyname_r("127.0.0.1", &addr, buf1, sizeof buf1, &result, &err);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+ ret = gethostbyname_r("127.0.0.0.0", &addr, buf, sizeof buf, &result, &err);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+ ret = gethostbyname_r("lo", &addr, buf, sizeof buf, &result, &err);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest007(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetHostByNameRTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_008.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6a9d44e6a003b1abb318ae2fc34b028f7baceff6
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_008.cpp
@@ -0,0 +1,60 @@
+/*
+ * 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 "lt_net_netdb.h"
+
+static int GetHostByName2Test(void)
+{
+ struct hostent *addr = gethostbyname2("localhost", AF_INET);
+ ICUNIT_ASSERT_NOT_EQUAL(addr, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(strcmp(addr->h_name, "localhost"), 0, -1);
+ ICUNIT_ASSERT_EQUAL(addr->h_addrtype, AF_INET, addr->h_addrtype);
+ ICUNIT_ASSERT_NOT_EQUAL(addr->h_length, 0, addr->h_length);
+
+ addr = gethostbyname2("127.0.0.1", AF_INET);
+ ICUNIT_ASSERT_NOT_EQUAL(addr, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(strcmp(addr->h_name, "127.0.0.1"), 0, -1);
+ ICUNIT_ASSERT_EQUAL(addr->h_addrtype, AF_INET, addr->h_addrtype);
+ ICUNIT_ASSERT_NOT_EQUAL(addr->h_length, 0, addr->h_length);
+
+ addr = gethostbyname2("127.0.0.1", AF_INET6);
+ ICUNIT_ASSERT_EQUAL(addr, NULL, -1);
+ addr = gethostbyname2("localh", AF_INET);
+ ICUNIT_ASSERT_EQUAL(addr, NULL, -1);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest008(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetHostByName2Test, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_009.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_009.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c14bc9b7d196e4109aca86943c04ee1a070f7dfe
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_009.cpp
@@ -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.
+ */
+
+#include "lt_net_netdb.h"
+
+static int GetHostByName2RTest(void)
+{
+ struct hostent addr, *result = NULL;
+ char buf[1024];
+ char buf1[1];
+ int err, ret;
+
+ ret = gethostbyname2_r("localhost", AF_INET, &addr, buf, sizeof buf, &result, &err);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_NOT_EQUAL(result, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(strcmp(result->h_name, "localhost"), 0, -1);
+ ICUNIT_ASSERT_EQUAL(result->h_addrtype, AF_INET, result->h_addrtype);
+ ICUNIT_ASSERT_NOT_EQUAL(result->h_length, 0, result->h_length);
+
+ ret = gethostbyname2_r("127.0.0.1", AF_INET, &addr, buf, sizeof buf, &result, &err);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_NOT_EQUAL(result, NULL, -1);
+ ICUNIT_ASSERT_EQUAL(strcmp(result->h_name, "127.0.0.1"), 0, -1);
+ ICUNIT_ASSERT_EQUAL(result->h_addrtype, AF_INET, result->h_addrtype);
+ ICUNIT_ASSERT_NOT_EQUAL(result->h_length, 0, result->h_length);
+
+ ret = gethostbyname2_r("127.0.0.1", AF_INET, &addr, buf1, sizeof buf1, &result, &err);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+ ret = gethostbyname2_r("127.0.0.1.1", AF_INET, &addr, buf, sizeof buf, &result, &err);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+ ret = gethostbyname2_r("lo", AF_INET, &addr, buf, sizeof buf, &result, &err);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest009(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetHostByName2RTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_010.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..efd6b88b3b44eac0a163dc9acacab2b4912a72a9
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_010.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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 "lt_net_netdb.h"
+
+static int NameInfoTest(void)
+{
+ char host[256], serv[256];
+ struct sockaddr_in addr;
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(22);
+ addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+ int ret = getnameinfo((struct sockaddr*)&addr, sizeof addr, host, sizeof host, serv, sizeof serv, 0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest010(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, NameInfoTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_011.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_011.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b6b7f191ed62b270cf74982f1ba55b6647e4e35f
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_011.cpp
@@ -0,0 +1,54 @@
+/*
+ * 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 "lt_net_netdb.h"
+
+static int GetServByPortTest(void)
+{
+ // refer to the `/etc/services' file.
+ struct servent *se1 = nullptr;
+ struct servent *se = getservbyport(htons(22), "tcp");
+ ICUNIT_ASSERT_NOT_EQUAL(se, NULL, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se->s_name, "ssh", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se->s_proto, "tcp", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se->s_aliases[0], "ssh", -1);
+
+ se1 = getservbyport(htons(22), "tp");
+ ICUNIT_ASSERT_EQUAL(se1, nullptr, -1);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest011(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetServByPortTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_012.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_012.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0e9ad90e2e7afa4b4bb9549b04c48d8602aa19b9
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_012.cpp
@@ -0,0 +1,64 @@
+/*
+ * 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 "lt_net_netdb.h"
+
+static int GetServByPortRTest(void)
+{
+ // refer to the `/etc/services' file.
+ struct servent se, *result = NULL;
+ char buf[1024];
+ char buf1[2];
+
+ int ret = getservbyport_r(htons(22), "udp", &se, buf, sizeof buf, &result);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_NOT_EQUAL(result, NULL, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se.s_name, "ssh", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se.s_proto, "udp", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se.s_aliases[0], "ssh", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(result->s_name, "ssh", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(result->s_proto, "udp", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(result->s_aliases[0], "ssh", -1);
+
+ ret = getservbyport_r(htons(22), "udp", &se, buf1, sizeof buf1, &result);
+ ICUNIT_ASSERT_EQUAL(ret, ERANGE, ret);
+
+ ret = getservbyport_r(htons(22), "ud", &se, buf, sizeof buf, &result);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest012(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetServByPortRTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_013.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_013.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b713849d7f3405a715f97e848b6b5fef521197d4
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_013.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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 "lt_net_netdb.h"
+
+static int HerrorTest(void)
+{
+ const char *err = hstrerror(TRY_AGAIN);
+ ICUNIT_ASSERT_NOT_EQUAL(err, NULL, -1);
+
+ herror(err);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest013(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, HerrorTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_014.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_014.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d4f0caaa932c0eda4f588117b4c1e26d0f7f25ee
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_014.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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 "lt_net_netdb.h"
+#include
+
+static int IfNameIndexTest(void)
+{
+ struct if_nameindex *idx = if_nameindex();
+ ICUNIT_ASSERT_NOT_EQUAL(idx, NULL, -1);
+
+ if_freenameindex(idx);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest014(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, IfNameIndexTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_015.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_015.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..95e675b4221b93cca5c3df9234f0c51673da5c84
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_015.cpp
@@ -0,0 +1,61 @@
+/*
+ * opyright (c) 2021-2021, 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
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lt_net_netdb.h"
+#include
+
+static int IfNameToIndexTest(void)
+{
+ int ret;
+ char if_name[20];
+ char *str = nullptr;
+
+ ret = if_nametoindex("lo");
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, -1);
+
+ str = if_indextoname(ret, if_name);
+ ICUNIT_ASSERT_NOT_EQUAL(str, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(if_name, "lo", -1);
+
+ str = if_indextoname(3, if_name);
+ ICUNIT_ASSERT_EQUAL(str, nullptr, -1);
+ ICUNIT_ASSERT_EQUAL(errno, ENXIO, errno);
+
+ ret = if_nametoindex("eth1");
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(errno, ENODEV, errno);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest015(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, IfNameToIndexTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_016.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_016.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..652db1ed3861cf48a693d7efd26c1d68a9f53a85
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_016.cpp
@@ -0,0 +1,62 @@
+/*
+ * opyright (c) 2021-2021, 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
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lt_net_netdb.h"
+
+static int GetServByNameTest(void)
+{
+ struct servent *se1 = nullptr;
+ struct servent *se2 = nullptr;
+
+ se1 = getservbyname("discard", "tcp");
+ ICUNIT_ASSERT_NOT_EQUAL(se1, NULL, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_name, "discard", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_proto, "tcp", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_aliases[0], "discard", -1);
+
+ se1 = getservbyname("ssh", "tcp");
+ ICUNIT_ASSERT_NOT_EQUAL(se1, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_name, "ssh", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_proto, "tcp", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_aliases[0], "ssh", -1);
+
+ se2 = getservbyname("cho", "udp");
+ ICUNIT_ASSERT_EQUAL(se2, nullptr, -1);
+
+ se2 = getservbyname("systat", "udp");
+ ICUNIT_ASSERT_EQUAL(se2, nullptr, -1);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest016(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetServByNameTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_017.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_017.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..81908c5599b68019384167b4febf7b5586bd3710
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_017.cpp
@@ -0,0 +1,67 @@
+/*
+ * opyright (c) 2021-2021, 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
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lt_net_netdb.h"
+
+static int GetServByNameRTest(void)
+{
+ struct servent se;
+ struct servent *result = NULL;
+ char buf1[1024] = { 0 };
+ char buf2[2] = { 0 };
+ int ret;
+
+ errno = 0;
+ ret = getservbyname_r("ssh", "tcp", &se, buf1, sizeof buf1, &result);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_NOT_EQUAL(result, NULL, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se.s_name, "ssh", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se.s_proto, "tcp", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se.s_aliases[0], "ssh", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(result->s_name, "ssh", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(result->s_proto, "tcp", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(result->s_aliases[0], "ssh", -1);
+
+ ret = getservbyname_r("ssh", "tcp", &se, buf2, sizeof buf2, &result);
+ ICUNIT_ASSERT_EQUAL(ret, ERANGE, ret);
+
+ ret = getservbyname_r("ssh", "tp", &se, buf1, sizeof buf1, &result);
+ ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
+
+ ret = getservbyname_r("sh", "tcp", &se, buf1, sizeof buf1, &result);
+ ICUNIT_ASSERT_EQUAL(ret, ENOENT, ret);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest017(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetServByNameRTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_018.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_018.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3f816dc8d6f895bf7f510d8789512047d5b38b08
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_018.cpp
@@ -0,0 +1,83 @@
+/*
+ * opyright (c) 2021-2021, 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
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lt_net_netdb.h"
+
+static int GetServEntTest(void)
+{
+ struct servent *se1 = nullptr;
+ struct servent *se2 = nullptr;
+ struct servent *se3 = nullptr;
+
+ se1 = getservent();
+ ICUNIT_ASSERT_NOT_EQUAL(se1, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_name, "tcpmux", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_proto, "tcp", -1);
+ ICUNIT_ASSERT_EQUAL(se1->s_port, ntohs(1), -1);
+
+ endservent();
+ se2 = getservent();
+ ICUNIT_ASSERT_NOT_EQUAL(se2, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_name, se2->s_name, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_proto, se2->s_proto, -1);
+ ICUNIT_ASSERT_EQUAL(se1->s_port, se2->s_port, -1);
+
+ setservent(0);
+ se3 = getservent();
+ ICUNIT_ASSERT_NOT_EQUAL(se3, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_name, se3->s_name, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->s_proto, se3->s_proto, -1);
+ ICUNIT_ASSERT_EQUAL(se1->s_port, se3->s_port, -1);
+
+ se3 = getservent();
+ ICUNIT_ASSERT_NOT_EQUAL(se3, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se3->s_name, "echo", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se3->s_proto, "tcp", -1);
+ ICUNIT_ASSERT_EQUAL(se3->s_port, ntohs(7), -1);
+
+ se3 = getservent();
+ ICUNIT_ASSERT_NOT_EQUAL(se3, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se3->s_name, "echo", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se3->s_proto, "udp", -1);
+ ICUNIT_ASSERT_EQUAL(se3->s_port, ntohs(7), -1);
+
+ se3 = getservent();
+ ICUNIT_ASSERT_NOT_EQUAL(se3, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se3->s_name, "discard", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se3->s_proto, "tcp", -1);
+ ICUNIT_ASSERT_EQUAL(se3->s_port, ntohs(9), -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se3->s_aliases[0], "sink", -1);
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest018(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetServEntTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_019.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_019.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..53c9b08a7b6564d6ce7fd9c275e5a4e6c43f35eb
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_019.cpp
@@ -0,0 +1,80 @@
+/*
+ * opyright (c) 2021-2021, 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
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lt_net_netdb.h"
+
+static int GetHostEntTest(void)
+{
+ struct hostent *se1 = nullptr;
+ struct hostent *se2 = nullptr;
+ struct hostent *se3 = nullptr;
+ int type = 2;
+ int length1 = 4;
+ int length2 = 16;
+
+ se1 = gethostent();
+ ICUNIT_ASSERT_NOT_EQUAL(se1, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->h_name, "localhost", -1);
+ ICUNIT_ASSERT_EQUAL(se1->h_addrtype, type, -1);
+ ICUNIT_ASSERT_EQUAL(se1->h_length, length1, -1);
+
+ endhostent();
+ se2 = gethostent();
+ ICUNIT_ASSERT_NOT_EQUAL(se2, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->h_name, se2->h_name, -1);
+ ICUNIT_ASSERT_EQUAL(se1->h_addrtype, se2->h_addrtype, -1);
+ ICUNIT_ASSERT_EQUAL(se1->h_length, se2->h_length, -1);
+
+ sethostent(0);
+ se3 = gethostent();
+ ICUNIT_ASSERT_NOT_EQUAL(se3, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->h_name, se3->h_name, -1);
+ ICUNIT_ASSERT_EQUAL(se1->h_addrtype, se3->h_addrtype, -1);
+ ICUNIT_ASSERT_EQUAL(se1->h_length, se3->h_length, -1);
+
+ se3 = gethostent();
+ ICUNIT_ASSERT_NOT_EQUAL(se3, nullptr, -1);
+ ICUNIT_ASSERT_EQUAL(se3->h_addrtype, AF_INET6, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se3->h_name, "localhost", -1);
+ ICUNIT_ASSERT_EQUAL(se3->h_length, length2, -1);
+
+ se3 = gethostent();
+ ICUNIT_ASSERT_NOT_EQUAL(se3, nullptr, -1);
+ ICUNIT_ASSERT_EQUAL(se3->h_addrtype, AF_INET, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se3->h_name, "szvphisprb93341", -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se3->h_aliases[0], "szvphisprb93341.huawei.com", -1);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest019(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetHostEntTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_020.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_020.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a08a22f0770df200f9055e890383c66226f72023
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_020.cpp
@@ -0,0 +1,65 @@
+/*
+ * opyright (c) 2021-2021, 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
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lt_net_netdb.h"
+
+static int GetNetEntTest(void)
+{
+ struct netent *se1 = nullptr;
+ struct netent *se2 = nullptr;
+ struct netent *se3 = nullptr;
+
+ se1 = getnetent();
+ ICUNIT_ASSERT_NOT_EQUAL(se1, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->n_name, "link-local", -1);
+ ICUNIT_ASSERT_EQUAL(se1->n_addrtype, 2, -1);
+ ICUNIT_ASSERT_EQUAL(se1->n_net, inet_network("169.254.0.0"), -1);
+
+ endnetent();
+ se2 = getnetent();
+ ICUNIT_ASSERT_NOT_EQUAL(se2, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->n_name, se2->n_name, -1);
+ ICUNIT_ASSERT_EQUAL(se1->n_addrtype, se2->n_addrtype, -1);
+ ICUNIT_ASSERT_EQUAL(se1->n_net, se2->n_net, -1);
+
+ setnetent(0);
+ se3 = getnetent();
+ ICUNIT_ASSERT_NOT_EQUAL(se3, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->n_name, se3->n_name, -1);
+ ICUNIT_ASSERT_EQUAL(se1->n_addrtype, se3->n_addrtype, -1);
+ ICUNIT_ASSERT_EQUAL(se1->n_net, se3->n_net, -1);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest020(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetNetEntTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_021.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_021.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0e4254b3932ac15f69be598520d3a30932a7f577
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_021.cpp
@@ -0,0 +1,57 @@
+/*
+ * opyright (c) 2021-2021, 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
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lt_net_netdb.h"
+
+static int GetNetBynametTest(void)
+{
+ struct netent *se1 = nullptr;
+ struct netent *se2 = nullptr;
+ struct netent *se3 = nullptr;
+
+ se1 = getnetbyname("link-local");
+ ICUNIT_ASSERT_NOT_EQUAL(se1, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->n_name, "link-local", -1);
+ ICUNIT_ASSERT_EQUAL(se1->n_addrtype, 2, -1);
+ ICUNIT_ASSERT_EQUAL(se1->n_net, inet_network("169.254.0.0"), -1);
+
+ se2 = getnetbyname("link");
+ ICUNIT_ASSERT_EQUAL(se2, nullptr, -1);
+
+ se3 = getnetbyname("hs");
+ ICUNIT_ASSERT_EQUAL(se3, nullptr, -1);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest021(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetNetBynametTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/full/net_netdb_test_022.cpp b/testsuites/unittest/net/netdb/full/net_netdb_test_022.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3bf0f9b11a39c0e4325073e8486458d18d3474a6
--- /dev/null
+++ b/testsuites/unittest/net/netdb/full/net_netdb_test_022.cpp
@@ -0,0 +1,57 @@
+/*
+ * opyright (c) 2021-2021, 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
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lt_net_netdb.h"
+
+static int GetNetByAddrtTest(void)
+{
+ struct netent *se1 = nullptr;
+ struct netent *se2 = nullptr;
+ struct netent *se3 = nullptr;
+
+ se1 = getnetbyaddr(inet_network("169.254.0.0"), AF_INET);
+ ICUNIT_ASSERT_NOT_EQUAL(se1, nullptr, -1);
+ ICUNIT_ASSERT_STRING_EQUAL(se1->n_name, "link-local", -1);
+ ICUNIT_ASSERT_EQUAL(se1->n_addrtype, 2, -1);
+ ICUNIT_ASSERT_EQUAL(se1->n_net, inet_network("169.254.0.0"), -1);
+
+ se2 = getnetbyaddr(inet_network("169.254.0.1"), AF_INET);
+ ICUNIT_ASSERT_EQUAL(se2, nullptr, -1);
+
+ se3 = getnetbyaddr(inet_network("169.254.0.1"), AF_INET6);
+ ICUNIT_ASSERT_EQUAL(se3, nullptr, -1);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetNetDbTest022(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, GetNetByAddrtTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/netdb/lt_net_netdb.h b/testsuites/unittest/net/netdb/lt_net_netdb.h
new file mode 100644
index 0000000000000000000000000000000000000000..d60a83cc7e19d6dd0efb61bde09cf8ac5428f234
--- /dev/null
+++ b/testsuites/unittest/net/netdb/lt_net_netdb.h
@@ -0,0 +1,65 @@
+/*
+ * 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 NET_RESOLV_LT_NET_NETDB_H_
+#define NET_RESOLV_LT_NET_NETDB_H_
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+void NetNetDbTest001(void);
+void NetNetDbTest002(void);
+void NetNetDbTest003(void);
+void NetNetDbTest004(void);
+void NetNetDbTest005(void);
+void NetNetDbTest006(void);
+void NetNetDbTest007(void);
+void NetNetDbTest008(void);
+void NetNetDbTest009(void);
+void NetNetDbTest010(void);
+void NetNetDbTest011(void);
+void NetNetDbTest012(void);
+void NetNetDbTest013(void);
+void NetNetDbTest014(void);
+void NetNetDbTest015(void);
+void NetNetDbTest016(void);
+void NetNetDbTest017(void);
+void NetNetDbTest018(void);
+void NetNetDbTest019(void);
+void NetNetDbTest020(void);
+void NetNetDbTest021(void);
+void NetNetDbTest022(void);
+
+#endif /* NET_RESOLV_LT_NET_NETDB_H_ */
diff --git a/testsuites/unittest/net/netdb/net_netdb_test.cpp b/testsuites/unittest/net/netdb/net_netdb_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7f50082baf612ed39010aa703689b3d9d3745dfc
--- /dev/null
+++ b/testsuites/unittest/net/netdb/net_netdb_test.cpp
@@ -0,0 +1,76 @@
+/*
+ * 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 "stdio.h"
+#include
+#include
+
+#include "lt_net_netdb.h"
+
+using namespace testing::ext;
+namespace OHOS {
+class NetDbTest : public testing::Test {
+public:
+ static void SetUpTestCase(void)
+ {
+ struct sched_param param = { 0 };
+ int currThreadPolicy, ret;
+ ret = pthread_getschedparam(pthread_self(), &currThreadPolicy, ¶m);
+ param.sched_priority = TASK_PRIO_TEST;
+ ret = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m);
+ }
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_FULL) && defined(LOSCFG_USER_TEST_NET_NETDB)
+/* *
+ * @tc.name: NetNetDbTest001
+ * @tc.desc: function for NetDbTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetDbTest, NetNetDbTest001, TestSize.Level0)
+{
+ NetNetDbTest001();
+}
+
+/* *
+ * @tc.name: NetNetDbTest013
+ * @tc.desc: function for NetDbTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetDbTest, NetNetDbTest013, TestSize.Level0)
+{
+ NetNetDbTest013();
+}
+
+#endif
+}
diff --git a/testsuites/unittest/net/resolv/BUILD.gn b/testsuites/unittest/net/resolv/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..c621e0b9bed8e0219d9a9757495d547feb27ca4e
--- /dev/null
+++ b/testsuites/unittest/net/resolv/BUILD.gn
@@ -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.
+
+import("//build/lite/config/test.gni")
+import("../../config.gni")
+
+config("net_local_config") {
+ if (LOSCFG_USER_TEST_NET_RESOLV == true) {
+ cflags = [ "-DLOSCFG_USER_TEST_NET_RESOLV" ]
+ cflags_cc = cflags
+ }
+}
+
+unittest("liteos_a_net_resolv_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../../common/include",
+ "./",
+ ]
+ sources = [
+ "../../common/osTest.cpp",
+ "net_resolv_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_FULL == true) {
+ sources_full = [
+ "full/net_resolv_test_001.cpp",
+ "full/net_resolv_test_002.cpp",
+ "full/net_resolv_test_003.cpp",
+ "full/net_resolv_test_004.cpp",
+ "full/net_resolv_test_005.cpp",
+ "full/net_resolv_test_006.cpp",
+ "full/net_resolv_test_007.cpp",
+ "full/net_resolv_test_008.cpp",
+ ]
+ sources += sources_full
+ }
+ configs = [
+ "../..:public_config",
+ ":net_local_config",
+ ]
+}
diff --git a/testsuites/unittest/net/resolv/full/net_resolv_test_001.cpp b/testsuites/unittest/net/resolv/full/net_resolv_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3a41448d4e9bb82abd3e0bb38c9309f4c0807ead
--- /dev/null
+++ b/testsuites/unittest/net/resolv/full/net_resolv_test_001.cpp
@@ -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
+#include
+static void dump(unsigned char *s, int len) {
+ if (!s) return;
+ for (int i = 0; i < len; ++i) {
+ printf("%02x ", s[i]);
+ }
+ printf("\n");
+}
+
+static int DnCompTest(void)
+{
+ unsigned char comp_dn[100] = "example";
+ unsigned char *dnptrs[6] = {comp_dn, 0};
+ unsigned char **lastdnptr = &dnptrs[6];
+ int offset, ret;
+
+ offset = strlen((const char *)dnptrs[0])+1;
+ ret = dn_comp("x.y.z.example.com", comp_dn+offset, sizeof(comp_dn)-offset, dnptrs, lastdnptr);
+ dump(comp_dn+offset, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 19, ret);
+ ICUNIT_ASSERT_EQUAL(dnptrs[1], comp_dn+offset, dnptrs[1]);
+
+ offset += ret+1;
+ ret = dn_comp("zz.example.com", comp_dn+offset, sizeof(comp_dn)-offset, dnptrs, lastdnptr);
+ dump(comp_dn+offset, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 5, ret);
+ ICUNIT_ASSERT_EQUAL(dnptrs[2], comp_dn+offset, dnptrs[2]);
+
+ offset += ret+1;
+ ret = dn_comp("a.example.com", comp_dn+offset, sizeof(comp_dn)-offset, dnptrs, lastdnptr);
+ dump(comp_dn+offset, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 4, ret);
+ ICUNIT_ASSERT_EQUAL(dnptrs[3], comp_dn+offset, dnptrs[3]);
+
+ offset += ret+1;
+ ret = dn_comp("example.com.cn", comp_dn+offset, sizeof(comp_dn)-offset, dnptrs, lastdnptr);
+ dump(comp_dn+offset, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 16, ret);
+ ICUNIT_ASSERT_EQUAL(dnptrs[4], comp_dn+offset, dnptrs[4]);
+
+ offset += ret+1;
+ ret = dn_comp("2example.com", comp_dn+offset, sizeof(comp_dn)-offset, dnptrs, lastdnptr);
+ dump(comp_dn+offset, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 11, ret);
+ ICUNIT_ASSERT_EQUAL(dnptrs[5], /*comp_dn+offset*/ NULL, dnptrs[5]); //last one is always NULL
+
+ for (int i = 0; i < 6; ++i) {
+ printf("%p: %s\n", dnptrs[i], dnptrs[i]);
+ }
+ ICUNIT_ASSERT_EQUAL(offset+ret<100, 1, ret);
+ return ICUNIT_SUCCESS;
+}
+
+void NetResolvTest001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, DnCompTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/resolv/full/net_resolv_test_002.cpp b/testsuites/unittest/net/resolv/full/net_resolv_test_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0419b61547ea4eeb8c40abb7aad5f4a17aa4faca
--- /dev/null
+++ b/testsuites/unittest/net/resolv/full/net_resolv_test_002.cpp
@@ -0,0 +1,57 @@
+/*
+ * 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
+
+static int EtherAtonTest(void)
+{
+ struct ether_addr *eaddr = ether_aton("01::EF");
+
+ ICUNIT_ASSERT_EQUAL(eaddr, NULL, -1);
+
+ eaddr = ether_aton("2C:9D:1E:4A:41:55");
+ ICUNIT_ASSERT_NOT_EQUAL(eaddr, NULL, -1);
+
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[0], 0x2C, eaddr->ether_addr_octet[0]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[1], 0x9D, eaddr->ether_addr_octet[1]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[2], 0x1E, eaddr->ether_addr_octet[2]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[3], 0x4A, eaddr->ether_addr_octet[3]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[4], 0x41, eaddr->ether_addr_octet[4]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[5], 0x55, eaddr->ether_addr_octet[5]);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetResolvTest002(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, EtherAtonTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/resolv/full/net_resolv_test_003.cpp b/testsuites/unittest/net/resolv/full/net_resolv_test_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..eeb8eeb96532647aa5a255fd847f25ea86484015
--- /dev/null
+++ b/testsuites/unittest/net/resolv/full/net_resolv_test_003.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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
+
+static int EtherAtonrTest(void)
+{
+ struct ether_addr addr;
+ struct ether_addr *eaddr = ether_aton_r("::01:EF", &addr);
+
+ ICUNIT_ASSERT_EQUAL(eaddr, NULL, -1);
+
+ eaddr = ether_aton_r("2c:9d:1e:4A:41:55", &addr);
+
+ ICUNIT_ASSERT_EQUAL(eaddr, &addr, -1);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[0], 0x2c, eaddr->ether_addr_octet[0]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[1], 0x9d, eaddr->ether_addr_octet[1]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[2], 0x1e, eaddr->ether_addr_octet[2]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[3], 0x4a, eaddr->ether_addr_octet[3]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[4], 0x41, eaddr->ether_addr_octet[4]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[5], 0x55, eaddr->ether_addr_octet[5]);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetResolvTest003(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, EtherAtonrTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/resolv/full/net_resolv_test_004.cpp b/testsuites/unittest/net/resolv/full/net_resolv_test_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e8cb672afd1a8ab6f5f12d303e57d718cc3eca8f
--- /dev/null
+++ b/testsuites/unittest/net/resolv/full/net_resolv_test_004.cpp
@@ -0,0 +1,54 @@
+/*
+ * 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
+
+static int EtherHosttonTest(void)
+{
+ // suppose "0:0:0:0:0:0 localhost" in `/etc/ethers' file.
+ struct ether_addr addr, *eaddr = &addr;
+ int ret = ether_hostton("localhost", eaddr);
+
+ ICUNIT_ASSERT_EQUAL(ret, 0, -1);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[0], 0x00, eaddr->ether_addr_octet[0]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[1], 0x00, eaddr->ether_addr_octet[1]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[2], 0x00, eaddr->ether_addr_octet[2]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[3], 0x00, eaddr->ether_addr_octet[3]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[4], 0x00, eaddr->ether_addr_octet[4]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[5], 0x00, eaddr->ether_addr_octet[5]);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetResolvTest004(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, EtherHosttonTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/resolv/full/net_resolv_test_005.cpp b/testsuites/unittest/net/resolv/full/net_resolv_test_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..abb18b64e84292f9f6f9fb8f2b31cce0c0dd6eaa
--- /dev/null
+++ b/testsuites/unittest/net/resolv/full/net_resolv_test_005.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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
+
+static int EtherLineTest(void)
+{
+ struct ether_addr addr, *eaddr = &addr;
+ char buf[100];
+ int ret;
+
+ ret = ether_line("localhost 01:02:03:04:05:06", eaddr, buf);
+ ICUNIT_ASSERT_EQUAL(ret, -1, -1);
+
+ ret = ether_line("01:02:03:04:05:06 localhost", eaddr, buf);
+ ICUNIT_ASSERT_EQUAL(ret, 0, -1);
+
+ ICUNIT_ASSERT_EQUAL(strcmp("localhost", buf), 0, -1);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[0], 0x01, eaddr->ether_addr_octet[0]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[1], 0x02, eaddr->ether_addr_octet[1]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[2], 0x03, eaddr->ether_addr_octet[2]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[3], 0x04, eaddr->ether_addr_octet[3]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[4], 0x05, eaddr->ether_addr_octet[4]);
+ ICUNIT_ASSERT_EQUAL(eaddr->ether_addr_octet[5], 0x06, eaddr->ether_addr_octet[5]);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetResolvTest005(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, EtherLineTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/resolv/full/net_resolv_test_006.cpp b/testsuites/unittest/net/resolv/full/net_resolv_test_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d60d950a9d96172b5f7201f19473d27f00ba55d8
--- /dev/null
+++ b/testsuites/unittest/net/resolv/full/net_resolv_test_006.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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
+
+static int EtherNtoaTest(void)
+{
+ struct ether_addr addr = {{11,12,13,14,15,16}}, *eaddr = &addr;
+ char *buf = ether_ntoa(eaddr);
+
+ ICUNIT_ASSERT_NOT_EQUAL(buf, 0, -1);
+ ICUNIT_ASSERT_EQUAL((stricmp("b:c:d:e:f:10", buf) == 0 || stricmp("0b:0c:0d:0e:0f:10", buf) == 0), 1, printf("%s\n", buf));
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetResolvTest006(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, EtherNtoaTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/resolv/full/net_resolv_test_007.cpp b/testsuites/unittest/net/resolv/full/net_resolv_test_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a509c97a403ad98b99bd8b4eed490992a3db5a00
--- /dev/null
+++ b/testsuites/unittest/net/resolv/full/net_resolv_test_007.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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
+
+static int EtherNtoarTest(void)
+{
+ struct ether_addr addr = {{11,12,13,4,15,16}}, *eaddr = &addr;
+ char buf[100], *p = ether_ntoa_r(eaddr, buf);
+
+ ICUNIT_ASSERT_EQUAL(p, buf, (intptr_t)p);
+ ICUNIT_ASSERT_EQUAL((stricmp("b:c:d:4:f:10", buf) == 0 || stricmp("0b:0c:0d:04:0f:10", buf) == 0), 1, printf("%s\n", p));
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetResolvTest007(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, EtherNtoarTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/resolv/full/net_resolv_test_008.cpp b/testsuites/unittest/net/resolv/full/net_resolv_test_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..baf77fbefb73b16a3158392137121ba2469bace9
--- /dev/null
+++ b/testsuites/unittest/net/resolv/full/net_resolv_test_008.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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
+
+static int EtherNtohostTest(void)
+{
+ // suppose "0:0:0:0:0:0 localhost" in `/etc/ethers' file.
+ struct ether_addr addr = {{0,0,0,0,0,0}}, *eaddr = &addr;
+ char buf[100];
+ int ret = ether_ntohost(buf, eaddr);
+
+ ICUNIT_ASSERT_EQUAL(ret, 0, -1);
+ ICUNIT_ASSERT_EQUAL(strcmp("localhost", buf), 0, -1);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetResolvTest008(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, EtherNtohostTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/resolv/lt_net_resolv.h b/testsuites/unittest/net/resolv/lt_net_resolv.h
new file mode 100644
index 0000000000000000000000000000000000000000..26b25985c48ffc2adb08bd5f57ee6f0dcc2f4b22
--- /dev/null
+++ b/testsuites/unittest/net/resolv/lt_net_resolv.h
@@ -0,0 +1,51 @@
+/*
+ * 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 NET_RESOLV_LT_NET_RESOLV_H_
+#define NET_RESOLV_LT_NET_RESOLV_H_
+
+#include
+#include
+#include
+#include
+
+int stricmp(const char *s1, const char *s2);
+
+void NetResolvTest001(void);
+void NetResolvTest002(void);
+void NetResolvTest003(void);
+void NetResolvTest004(void);
+void NetResolvTest005(void);
+void NetResolvTest006(void);
+void NetResolvTest007(void);
+void NetResolvTest008(void);
+
+#endif /* NET_RESOLV_LT_NET_RESOLV_H_ */
diff --git a/testsuites/unittest/net/resolv/net_resolv_test.cpp b/testsuites/unittest/net/resolv/net_resolv_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..aaee3241ebe38b5bd8ad3c28edb2bd4a2e04d475
--- /dev/null
+++ b/testsuites/unittest/net/resolv/net_resolv_test.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "stdio.h"
+#include
+#include
+
+#include "lt_net_resolv.h"
+
+int stricmp(const char *s1, const char *s2)
+{
+ for (; *s1 && *s2; s1++, s2++) {
+ if (*s1 == *s2) continue;
+ if ((*s1 ^ *s2) == 0x20 && (*s2 | 0x20) >= 'a' && (*s2 | 0x20) <= 'z') continue;
+ break;
+ }
+ return *s1 - *s2;
+}
+
+using namespace testing::ext;
+namespace OHOS {
+class NetResolvTest : public testing::Test {
+public:
+ static void SetUpTestCase(void) {}
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_FULL) && defined(LOSCFG_USER_TEST_NET_RESOLV)
+/* *
+ * @tc.name: NetResolvTest001
+ * @tc.desc: function for NetResolvTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetResolvTest, NetResolvTest001, TestSize.Level0)
+{
+ NetResolvTest001();
+}
+
+/* *
+ * @tc.name: NetResolvTest002
+ * @tc.desc: function for NetResolvTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetResolvTest, NetResolvTest002, TestSize.Level0)
+{
+ NetResolvTest002();
+}
+
+/* *
+ * @tc.name: NetResolvTest003
+ * @tc.desc: function for NetResolvTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetResolvTest, NetResolvTest003, TestSize.Level0)
+{
+ NetResolvTest003();
+}
+
+/* *
+ * @tc.name: NetResolvTest006
+ * @tc.desc: function for NetResolvTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetResolvTest, NetResolvTest006, TestSize.Level0)
+{
+ NetResolvTest006();
+}
+
+/* *
+ * @tc.name: NetResolvTest007
+ * @tc.desc: function for NetResolvTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetResolvTest, NetResolvTest007, TestSize.Level0)
+{
+ NetResolvTest007();
+}
+
+#endif
+}
diff --git a/testsuites/unittest/net/socket/BUILD.gn b/testsuites/unittest/net/socket/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..37e18c9bb01aed1ca6f5f59d39e046ae24c11432
--- /dev/null
+++ b/testsuites/unittest/net/socket/BUILD.gn
@@ -0,0 +1,74 @@
+# 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.
+
+import("//build/lite/config/test.gni")
+import("../../config.gni")
+
+config("net_local_config") {
+ if (LOSCFG_USER_TEST_NET_SOCKET == true) {
+ cflags = [ "-DLOSCFG_USER_TEST_NET_SOCKET" ]
+ cflags_cc = cflags
+ }
+}
+
+unittest("liteos_a_net_socket_unittest") {
+ output_extension = "bin"
+ output_dir = "$root_out_dir/test/unittest/kernel"
+ include_dirs = [
+ "../../common/include",
+ "../../net/socket",
+ ]
+ sources = [
+ "../../common/osTest.cpp",
+ "net_socket_test.cpp",
+ ]
+ if (LOSCFG_USER_TEST_SMOKE == true) {
+ sources_smoke = [
+ "smoke/net_socket_test_001.cpp",
+ "smoke/net_socket_test_002.cpp",
+ "smoke/net_socket_test_003.cpp",
+ "smoke/net_socket_test_004.cpp",
+ "smoke/net_socket_test_005.cpp",
+ "smoke/net_socket_test_006.cpp",
+ "smoke/net_socket_test_007.cpp",
+ "smoke/net_socket_test_008.cpp",
+ "smoke/net_socket_test_009.cpp",
+ "smoke/net_socket_test_010.cpp",
+ "smoke/net_socket_test_011.cpp",
+ "smoke/net_socket_test_012.cpp",
+ "smoke/net_socket_test_013.cpp",
+ ]
+ sources += sources_smoke
+ }
+ deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
+ configs = [
+ "../../:public_config",
+ ":net_local_config",
+ ]
+}
diff --git a/testsuites/unittest/net/socket/lt_net_socket.h b/testsuites/unittest/net/socket/lt_net_socket.h
new file mode 100644
index 0000000000000000000000000000000000000000..04d027c6b5c01560f6bd4904d87be54df8e3d0d7
--- /dev/null
+++ b/testsuites/unittest/net/socket/lt_net_socket.h
@@ -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 NET_SOCKET_LT_NET_SOCKET_H_
+#define NET_SOCKET_LT_NET_SOCKET_H_
+
+#include
+#include
+
+void NetSocketTest001(void);
+void NetSocketTest002(void);
+void NetSocketTest003(void);
+void NetSocketTest004(void);
+void NetSocketTest005(void);
+void NetSocketTest006(void);
+void NetSocketTest007(void);
+void NetSocketTest008(void);
+void NetSocketTest009(void);
+void NetSocketTest010(void);
+void NetSocketTest011(void);
+void NetSocketTest012(void);
+void NetSocketTest013(void);
+
+#endif /* NET_SOCKET_LT_NET_SOCKET_H_ */
diff --git a/testsuites/unittest/net/socket/net_socket_test.cpp b/testsuites/unittest/net/socket/net_socket_test.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b28b9f8b980a2a578175eb950f3bc92e749cf56c
--- /dev/null
+++ b/testsuites/unittest/net/socket/net_socket_test.cpp
@@ -0,0 +1,204 @@
+/*
+ * 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 "stdio.h"
+#include
+#include
+
+#include "lt_net_socket.h"
+
+using namespace testing::ext;
+namespace OHOS {
+class NetSocketTest : public testing::Test {
+public:
+ static void SetUpTestCase(void)
+ {
+ struct sched_param param = { 0 };
+ int currThreadPolicy, ret;
+ ret = pthread_getschedparam(pthread_self(), &currThreadPolicy, ¶m);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0, -ret);
+ param.sched_priority = TASK_PRIO_TEST;
+ ret = pthread_setschedparam(pthread_self(), SCHED_RR, ¶m);
+ ICUNIT_ASSERT_EQUAL_VOID(ret, 0, -ret);
+ }
+ static void TearDownTestCase(void) {}
+};
+
+#if defined(LOSCFG_USER_TEST_SMOKE) && defined(LOSCFG_USER_TEST_NET_SOCKET)
+/* *
+ * @tc.name: NetSocketTest001
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest001, TestSize.Level0)
+{
+ NetSocketTest001();
+}
+
+/* *
+ * @tc.name: NetSocketTest002
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest002, TestSize.Level0)
+{
+ NetSocketTest002();
+}
+
+#if TEST_ON_LINUX
+/* *
+ * @tc.name: NetSocketTest003
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest003, TestSize.Level0)
+{
+ NetSocketTest003(); // getifaddrs need PF_NETLINK which was not supported by lwip currently
+}
+#endif
+
+/* *
+ * @tc.name: NetSocketTest004
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest004, TestSize.Level0)
+{
+ NetSocketTest004();
+}
+
+/* *
+ * @tc.name: NetSocketTest005
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest005, TestSize.Level0)
+{
+ NetSocketTest005();
+}
+
+/* *
+ * @tc.name: NetSocketTest006
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest006, TestSize.Level0)
+{
+ NetSocketTest006();
+}
+
+#if TEST_ON_LINUX
+/* *
+ * @tc.name: NetSocketTest007
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest007, TestSize.Level0)
+{
+ NetSocketTest007();
+}
+#endif
+
+/* *
+ * @tc.name: NetSocketTest008
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest008, TestSize.Level0)
+{
+ NetSocketTest008();
+}
+
+/* *
+ * @tc.name: NetSocketTest009
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest009, TestSize.Level0)
+{
+ NetSocketTest009();
+}
+
+/* *
+ * @tc.name: NetSocketTest010
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest010, TestSize.Level0)
+{
+ NetSocketTest010();
+}
+
+/* *
+ * @tc.name: NetSocketTest011
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest011, TestSize.Level0)
+{
+ NetSocketTest011();
+}
+
+/* *
+ * @tc.name: NetSocketTest012
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+HWTEST_F(NetSocketTest, NetSocketTest012, TestSize.Level0)
+{
+ NetSocketTest012();
+}
+
+/* *
+ * @tc.name: NetSocketTest013
+ * @tc.desc: function for NetSocketTest
+ * @tc.type: FUNC
+ * @tc.require: AR000EEMQ9
+ */
+/*
+HWTEST_F(NetSocketTest, NetSocketTest013, TestSize.Level0)
+{
+ //NetSocketTest013(); // broadcast to self to be supported.
+}
+*/
+#endif
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_001.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_001.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1fc958389502a5e9981841122ce21cc1932832f8
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_001.cpp
@@ -0,0 +1,45 @@
+/*
+ * 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
+#include
+
+static int SocketTest(void)
+{
+ int fd = socket(0, 0, 0);
+ ICUNIT_ASSERT_EQUAL(fd, -1, fd);
+ return ICUNIT_SUCCESS;
+}
+
+void NetSocketTest001(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, SocketTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_002.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_002.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..20d2193c8a15896f9f375916e4a49644e1706b6e
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_002.cpp
@@ -0,0 +1,131 @@
+/*
+ * 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
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define localhost "127.0.0.1"
+#define STACK_IP localhost
+#define STACK_PORT 2277
+#define PEER_PORT STACK_PORT
+#define PEER_IP localhost
+#define MSG "Hi, I am UDP"
+#define BUF_SIZE (1024 * 8)
+
+static char g_buf[BUF_SIZE + 1] = { 0 };
+
+static int UdpTest(void)
+{
+ int sfd;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ int ret = 0, i = 0;
+ struct msghdr msg = { 0 };
+ struct iovec iov[2] = { };
+
+ /* socket creation */
+ sfd = socket(AF_INET, SOCK_DGRAM, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, sfd);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
+ srvAddr.sin_port = htons(STACK_PORT);
+ ret = bind(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ /* send */
+ clnAddr.sin_family = AF_INET;
+ clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ clnAddr.sin_port = htons(PEER_PORT);
+ ret = memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = strcpy_s(g_buf, BUF_SIZE, MSG);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = sendto(sfd, g_buf, strlen(MSG), 0, (struct sockaddr*)&clnAddr,
+ (socklen_t)sizeof(clnAddr));
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+
+ /* recv */
+ ret = memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = recvfrom(sfd, g_buf, sizeof(g_buf), 0, (struct sockaddr*)&clnAddr,
+ &clnAddrLen);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(MSG), ret);
+
+ /* sendmsg */
+ clnAddr.sin_family = AF_INET;
+ clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ clnAddr.sin_port = htons(PEER_PORT);
+ ret = memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = strcpy_s(g_buf, BUF_SIZE, MSG);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 2;
+ iov[0].iov_base = g_buf;
+ iov[0].iov_len = strlen(MSG);
+ iov[1].iov_base = g_buf;
+ iov[1].iov_len = strlen(MSG);
+ ret = sendmsg(sfd, &msg, 0);
+ ICUNIT_ASSERT_EQUAL(ret, 2 * strlen(MSG), ret);
+
+ /* recvmsg */
+ ret = memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = memset_s(&msg, sizeof(msg), 0, sizeof(msg));
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+ iov[0].iov_base = g_buf;
+ iov[0].iov_len = sizeof(g_buf);
+ ret = recvmsg(sfd, &msg, 0);
+ ICUNIT_ASSERT_EQUAL(ret, 2 * strlen(MSG), ret);
+
+ /* close socket */
+ ret = close(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret);
+ return 0;
+}
+
+void NetSocketTest002(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, UdpTest, TEST_POSIX, TEST_UDP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_003.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_003.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6dbcab642be2df654e14fadd1fcc0c82d552d286
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_003.cpp
@@ -0,0 +1,321 @@
+/*
+ * 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
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define localhost "127.0.0.1"
+#define STACK_IP localhost
+#define STACK_PORT 2277
+#define PEER_PORT STACK_PORT
+#define PEER_IP localhost
+#define BUF_SIZE (1024 * 8)
+#define SRV_MSG "Hi, I am TCP server"
+#define CLI_MSG "Hi, I am TCP client"
+
+static pthread_barrier_t gBarrier;
+#define Wait() pthread_barrier_wait(&gBarrier)
+
+static int SampleTcpServer()
+{
+ static char gBuf[BUF_SIZE + 1] = { 0 };
+ int sfd = -1, lsfd = -1;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ struct msghdr msg = { 0 };
+ struct iovec iov[2] = { };
+ int ret = 0, i = 0;
+
+ /* tcp server */
+ lsfd = socket(AF_INET, SOCK_STREAM, 0);
+ LogPrintln("create listen socket inet stream: %d", lsfd);
+ ICUNIT_ASSERT_NOT_EQUAL(lsfd, -1, lsfd);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
+ srvAddr.sin_port = htons(STACK_PORT);
+ ret = bind(lsfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LogPrintln("bind socket %d to %s:%d: %d", lsfd, inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, Wait() + ret);
+
+ ret = listen(lsfd, 0);
+ LogPrintln("listen socket %d: %d", lsfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ Wait();
+
+ sfd = accept(lsfd, (struct sockaddr*)&clnAddr, &clnAddrLen);
+ LogPrintln("accept socket %d: %d <%s:%d>", lsfd, sfd, inet_ntoa(clnAddr.sin_addr), ntohs(clnAddr.sin_port));
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, sfd);
+
+ /* send */
+ ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ ret = strcpy_s(gBuf, BUF_SIZE - 1, SRV_MSG);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ ret = send(sfd, gBuf, strlen(SRV_MSG), 0);
+ LogPrintln("send on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(SRV_MSG), ret);
+
+ /* recv */
+ ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ ret = recv(sfd, gBuf, sizeof(gBuf), 0);
+ LogPrintln("recv on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(CLI_MSG), ret);
+
+ Wait();
+
+ /* sendmsg */
+ clnAddr.sin_family = AF_INET;
+ clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ clnAddr.sin_port = htons(PEER_PORT);
+ ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ ret = strcpy_s(gBuf, BUF_SIZE - 1, SRV_MSG);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 2;
+ iov[0].iov_base = gBuf;
+ iov[0].iov_len = strlen(SRV_MSG);
+ iov[1].iov_base = gBuf;
+ iov[1].iov_len = strlen(SRV_MSG);
+ ret = sendmsg(sfd, &msg, 0);
+ LogPrintln("sendmsg on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 2 * strlen(SRV_MSG), ret);
+
+ Wait();
+
+ /* recvmsg */
+ ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ ret = memset_s(&msg, sizeof(msg), 0, sizeof(msg));
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+ iov[0].iov_base = gBuf;
+ iov[0].iov_len = sizeof(gBuf);
+ ret = recvmsg(sfd, &msg, 0);
+ LogPrintln("recvmsg on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 2 * strlen(CLI_MSG), ret);
+
+ ret = shutdown(sfd, SHUT_RDWR);
+ LogPrintln("shutdown socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ close(sfd);
+ close(lsfd);
+ return 0;
+}
+
+static int SampleTcpClient()
+{
+ static char gBuf[BUF_SIZE + 1] = { 0 };
+ int sfd = -1;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ int ret = 0, i = 0;
+ struct msghdr msg = { 0 };
+ struct iovec iov[2] = { };
+ struct sockaddr addr;
+ socklen_t addrLen = sizeof(addr);
+
+ /* tcp client connection */
+ sfd = socket(AF_INET, SOCK_STREAM, 0);
+ LogPrintln("create client socket inet stream: %d", sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, sfd);
+
+ Wait();
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ srvAddr.sin_port = htons(PEER_PORT);
+ ret = connect(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LogPrintln("connect socket %d to %s:%d: %d", sfd, inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ /* test getpeername */
+ ret = getpeername(sfd, &addr, &addrLen);
+ LogPrintln("getpeername %d %s:%d: %d", sfd, inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr), ntohs(((struct sockaddr_in*)&addr)->sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(addrLen, sizeof(struct sockaddr_in), addrLen);
+ ICUNIT_ASSERT_EQUAL(((struct sockaddr_in*)&addr)->sin_addr.s_addr,
+ inet_addr(PEER_IP), ((struct sockaddr_in*)&addr)->sin_addr.s_addr);
+
+ /* test getsockname */
+ ret = getsockname(sfd, &addr, &addrLen);
+ LogPrintln("getsockname %d %s:%d: %d", sfd, inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr), ntohs(((struct sockaddr_in*)&addr)->sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(addrLen, sizeof(struct sockaddr_in), addrLen);
+ ICUNIT_ASSERT_EQUAL(((struct sockaddr_in*)&addr)->sin_addr.s_addr,
+ inet_addr(STACK_IP), ((struct sockaddr_in*)&addr)->sin_addr.s_addr);
+
+ /* send */
+ ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ ret = strcpy_s(gBuf, BUF_SIZE - 1, CLI_MSG);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ ret = send(sfd, gBuf, strlen(CLI_MSG), 0);
+ LogPrintln("send on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(CLI_MSG), ret);
+
+ /* recv */
+ ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ ret = recv(sfd, gBuf, sizeof(gBuf), 0);
+ LogPrintln("recv on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(SRV_MSG), ret);
+
+ Wait();
+
+ /* sendmsg */
+ clnAddr.sin_family = AF_INET;
+ clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ clnAddr.sin_port = htons(PEER_PORT);
+ ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ ret = strcpy_s(gBuf, BUF_SIZE - 1, CLI_MSG);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 2;
+ iov[0].iov_base = gBuf;
+ iov[0].iov_len = strlen(CLI_MSG);
+ iov[1].iov_base = gBuf;
+ iov[1].iov_len = strlen(CLI_MSG);
+ ret = sendmsg(sfd, &msg, 0);
+ LogPrintln("sendmsg on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 2 * strlen(CLI_MSG), ret);
+
+ Wait();
+
+ /* recvmsg */
+ ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gBuf[BUF_SIZE - 1] = '\0';
+ ret = memset_s(&msg, sizeof(msg), 0, sizeof(msg));
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+ iov[0].iov_base = gBuf;
+ iov[0].iov_len = sizeof(gBuf);
+ ret = recvmsg(sfd, &msg, 0);
+ LogPrintln("recvmsg on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 2 * strlen(SRV_MSG), ret);
+
+ ret = shutdown(sfd, SHUT_RDWR);
+ LogPrintln("shutdown socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ close(sfd);
+ return 0;
+}
+
+static void* TcpServerRoutine(void *p)
+{
+ int ret = SampleTcpServer();
+ return (void*)(intptr_t)ret;
+}
+
+static void* TcpClientRoutine(void *p)
+{
+ int ret = SampleTcpClient();
+ return (void*)(intptr_t)ret;
+}
+
+static int TcpTest()
+{
+ int ret;
+ void *sret = NULL;
+ void *cret = NULL;
+ pthread_t srv, cli;
+ pthread_attr_t attr;
+
+ ret = pthread_barrier_init(&gBarrier, 0, 2);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&srv, &attr, TcpServerRoutine, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&cli, &attr, TcpClientRoutine, NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_join(cli, &cret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LogPrintln("client finish");
+
+ ret = pthread_join(srv, &sret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ LogPrintln("server finish");
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_barrier_destroy(&gBarrier);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return (int)(intptr_t)(sret) + (int)(intptr_t)(cret);
+}
+
+void NetSocketTest003(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, TcpTest, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_004.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_004.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..81e2ac371885d4955878cab3354bf229b677b9af
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_004.cpp
@@ -0,0 +1,89 @@
+/*
+ * 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
+#include
+#include
+#include
+
+static int SockOptTest(void)
+{
+ int ret, error, flag;
+ struct timeval timeout;
+ socklen_t len;
+
+ int fd = socket(AF_INET, SOCK_STREAM, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd);
+
+ error = -1;
+ len = sizeof(error);
+ ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
+ LogPrintln("getsockopt(%d, SOL_SOCKET, SO_ERROR, &error, &len)=%d, error=%d, len=%d, errno=%d", fd, ret, error, len, errno);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(error, 0, error);
+
+ len = sizeof(timeout);
+ ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ timeout.tv_sec = 1000;
+ len = sizeof(timeout);
+ ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = memset_s(&timeout, len, 0, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(timeout.tv_sec, 1000, ret);
+
+ error = -1;
+ len = sizeof(error);
+ ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
+ LogPrintln("getsockopt(%d, SOL_SOCKET, SO_ERROR, &error, &len)=%d, error=%d, len=%d, errno=%d", fd, ret, error, len, errno);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ICUNIT_ASSERT_EQUAL(error, 0, error);
+
+ flag=1;
+ ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
+ LogPrintln("setsockopt(TCP_NODELAY) ret=%d", ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = close(fd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetSocketTest004(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, SockOptTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_005.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_005.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3cf7f89521030f6d5119c66a37c7230787f30fa1
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_005.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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
+#include
+#include
+
+static int ByteOrderTest(void)
+{
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ uint32_t hl = ntohl(0x12345678);
+ ICUNIT_ASSERT_EQUAL(hl, 0x78563412, hl);
+
+ uint32_t nl = htonl(0x12345678);
+ ICUNIT_ASSERT_EQUAL(nl, 0x78563412, nl);
+
+ uint16_t hs = ntohs(0x1234);
+ ICUNIT_ASSERT_EQUAL(hs, 0x3412, hs);
+
+ uint16_t ns = htons(0x1234);
+ ICUNIT_ASSERT_EQUAL(ns, 0x3412, ns);
+#else
+ uint32_t hl = ntohl(0x12345678);
+ ICUNIT_ASSERT_EQUAL(hl, 0x12345678, hl);
+
+ uint32_t nl = htonl(0x12345678);
+ ICUNIT_ASSERT_EQUAL(nl, 0x12345678, nl);
+
+ uint16_t hs = ntohs(0x1234);
+ ICUNIT_ASSERT_EQUAL(hs, 0x1234, hs);
+
+ uint16_t ns = htons(0x1234);
+ ICUNIT_ASSERT_EQUAL(ns, 0x1234, ns);
+#endif
+ return ICUNIT_SUCCESS;
+}
+
+void NetSocketTest005(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, ByteOrderTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_006.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_006.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4c3485025c623009654c482cba5ecdfa7a68f37c
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_006.cpp
@@ -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
+#include
+#include
+#include
+
+static int InetTest(void)
+{
+ struct in_addr in;
+ int ret = inet_pton(AF_INET, "300.10.10.10", &in);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = inet_pton(AF_INET, "10.11.12.13", &in);
+ ICUNIT_ASSERT_EQUAL(ret, 1, ret);
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ ICUNIT_ASSERT_EQUAL(in.s_addr, 0x0d0c0b0a, in.s_addr);
+#else
+ ICUNIT_ASSERT_EQUAL(in.s_addr, 0x0a0b0c0d, in.s_addr);
+#endif
+
+ // host order
+ in_addr_t lna = inet_lnaof(in);
+ ICUNIT_ASSERT_EQUAL(lna, 0x000b0c0d, lna);
+
+ // host order
+ in_addr_t net = inet_netof(in);
+ ICUNIT_ASSERT_EQUAL(net, 0x0000000a, net);
+
+ in = inet_makeaddr(net, lna);
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ ICUNIT_ASSERT_EQUAL(in.s_addr, 0x0d0c0b0a, in.s_addr);
+#else
+ ICUNIT_ASSERT_EQUAL(in.s_addr, 0x0a0b0c0d, in.s_addr);
+#endif
+
+ net = inet_network("300.10.10.10");
+ ICUNIT_ASSERT_EQUAL(net, -1, net);
+
+ // host order
+ net = inet_network("10.11.12.13");
+ ICUNIT_ASSERT_EQUAL(net, 0x0a0b0c0d, net);
+
+ const char *p = inet_ntoa(in);
+ ICUNIT_ASSERT_EQUAL(strcmp(p, "10.11.12.13"), 0, -1);
+
+ char buf[32];
+ p = inet_ntop(AF_INET, &in, buf, sizeof(buf));
+ ICUNIT_ASSERT_EQUAL(p, buf, -1);
+ ICUNIT_ASSERT_EQUAL(strcmp(p, "10.11.12.13"), 0, -1);
+
+ return ICUNIT_SUCCESS;
+}
+
+void NetSocketTest006(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, InetTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_007.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_007.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f3418093b412e1e6168fd14771e460831ba2f767
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_007.cpp
@@ -0,0 +1,156 @@
+/*
+ * 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
+#include
+
+#define SRV_MSG "Hi, I am TCP server"
+#define INVALID_USER_ADDR 0X1200000
+#define INVALID_KERNEL_ADDR 0x48000000
+
+static int TcpTest()
+{
+ int ret;
+ int lsfd = -1;
+ struct msghdr msg = { 0 };
+
+ lsfd = socket(AF_INET, SOCK_STREAM, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(lsfd, -1, lsfd);
+
+ ret = bind(lsfd, (const struct sockaddr *)INVALID_USER_ADDR, sizeof(struct sockaddr_in));
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = bind(lsfd, (const struct sockaddr *)INVALID_KERNEL_ADDR, sizeof(struct sockaddr_in));
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = connect(lsfd, (struct sockaddr*)INVALID_USER_ADDR, sizeof(struct sockaddr_in));
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = connect(lsfd, (struct sockaddr*)INVALID_KERNEL_ADDR, sizeof(struct sockaddr_in));
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = accept(lsfd, (struct sockaddr*)INVALID_USER_ADDR, (socklen_t *)INVALID_USER_ADDR);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = accept(lsfd, (struct sockaddr*)INVALID_KERNEL_ADDR, (socklen_t *)INVALID_KERNEL_ADDR);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = getsockname(lsfd, (struct sockaddr*)INVALID_USER_ADDR, (socklen_t *)INVALID_USER_ADDR);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = getsockname(lsfd, (struct sockaddr*)INVALID_KERNEL_ADDR, (socklen_t *)INVALID_KERNEL_ADDR);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = getpeername(lsfd, (struct sockaddr*)INVALID_USER_ADDR, (socklen_t *)INVALID_USER_ADDR);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = getpeername(lsfd, (struct sockaddr*)INVALID_KERNEL_ADDR, (socklen_t *)INVALID_KERNEL_ADDR);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = send(lsfd, (char *)INVALID_USER_ADDR, strlen(SRV_MSG), 0);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = send(lsfd, (char *)INVALID_KERNEL_ADDR, strlen(SRV_MSG), 0);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = sendto(lsfd, (char *)INVALID_USER_ADDR, strlen(SRV_MSG), 0, (struct sockaddr*)INVALID_USER_ADDR,
+ (socklen_t)sizeof(struct sockaddr_in));
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = sendto(lsfd, (char *)INVALID_KERNEL_ADDR, strlen(SRV_MSG), 0, (struct sockaddr*)INVALID_KERNEL_ADDR,
+ (socklen_t)sizeof(struct sockaddr_in));
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = recv(lsfd, (char *)INVALID_USER_ADDR, sizeof(SRV_MSG), 0);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = recv(lsfd, (char *)INVALID_KERNEL_ADDR, sizeof(SRV_MSG), 0);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = recvfrom(lsfd, (char *)INVALID_USER_ADDR, sizeof(SRV_MSG), 0, (struct sockaddr*)INVALID_USER_ADDR,
+ (socklen_t *)INVALID_USER_ADDR);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = recvfrom(lsfd, (char *)INVALID_KERNEL_ADDR, sizeof(SRV_MSG), 0, (struct sockaddr*)INVALID_KERNEL_ADDR,
+ (socklen_t *)INVALID_KERNEL_ADDR);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = setsockopt(lsfd, SOL_SOCKET, SO_RCVTIMEO, (struct timeval *)INVALID_USER_ADDR, (socklen_t)sizeof(struct timeval));
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = setsockopt(lsfd, SOL_SOCKET, SO_RCVTIMEO, (struct timeval *)INVALID_KERNEL_ADDR, (socklen_t)sizeof(struct timeval));
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = getsockopt(lsfd, SOL_SOCKET, SO_RCVTIMEO, (struct timeval *)INVALID_USER_ADDR, (socklen_t*)sizeof(struct timeval));
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = getsockopt(lsfd, SOL_SOCKET, SO_RCVTIMEO, (struct timeval *)INVALID_KERNEL_ADDR, (socklen_t*)sizeof(struct timeval));
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = sendmsg(lsfd, (struct msghdr *)INVALID_USER_ADDR, 0);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = sendmsg(lsfd, (struct msghdr *)INVALID_KERNEL_ADDR, 0);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ msg.msg_name = (char *)INVALID_USER_ADDR;
+ msg.msg_namelen = sizeof(struct sockaddr_in);
+ msg.msg_iov = (struct iovec *)INVALID_KERNEL_ADDR;
+ msg.msg_iovlen = 2;
+ ret = recvmsg(lsfd, (struct msghdr *)&msg, 0);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+ ret = recvmsg(lsfd, (struct msghdr *)&msg, 0);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+
+#ifdef TEST_BIG_MEM
+ const int bufSiz = 0x1400000; // 20M
+ void *buf = malloc(bufSiz);
+ if (!buf) {
+ printf("malloc 20M fail\n");
+ } else {
+ printf("malloc 20M success\n");
+ ret = memset_s(buf, bufSiz, 0, bufSiz);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = send(lsfd, buf, bufSiz, 0);
+ printf("send ret = %d, errno :%d\n", ret, errno);
+ ICUNIT_ASSERT_EQUAL(ret, -1, ret);
+ }
+#endif
+
+ close(lsfd);
+ return 0;
+}
+
+void NetSocketTest007(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, TcpTest, TEST_POSIX, TEST_MEM, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_008.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_008.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..dd76e80bd55a4590b73996a96d79f4e1302f2e83
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_008.cpp
@@ -0,0 +1,282 @@
+/*
+ * 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
+#include
+#include
+#include
+#include
+
+#define SERVER_PORT 6666
+#define INVALID_SOCKET -1
+#define CLIENT_NUM 25
+#define BACKLOG CLIENT_NUM
+
+static int gFds[FD_SETSIZE];
+static int gBye;
+
+static void InitFds()
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ gFds[i] = INVALID_SOCKET;
+ }
+}
+
+static void GetReadfds(fd_set *fds, int *nfd)
+{
+ for (int i = 0; i < FD_SETSIZE; i++) {
+ if (gFds[i] == INVALID_SOCKET) {
+ continue;
+ }
+ FD_SET(gFds[i], fds);
+ if (*nfd < gFds[i]) {
+ *nfd = gFds[i];
+ }
+ }
+}
+
+static int AddFd(int fd)
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ if (gFds[i] == INVALID_SOCKET) {
+ gFds[i] = fd;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static void DelFd(int fd)
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ if (gFds[i] == fd) {
+ gFds[i] = INVALID_SOCKET;
+ }
+ }
+ (void)close(fd);
+}
+
+static int CloseAllFd(void)
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ if (gFds[i] != INVALID_SOCKET) {
+ (void)close(gFds[i]);
+ gFds[i] = INVALID_SOCKET;
+ }
+ }
+ return 0;
+}
+
+static int HandleRecv(int fd)
+{
+ char buf[256];
+ int ret = recv(fd, buf, sizeof(buf)-1, 0);
+ if (ret < 0) {
+ LogPrintln("[%d]Error: %s", fd, strerror(errno));
+ DelFd(fd);
+ } else if (ret == 0) {
+ LogPrintln("[%d]Closed", fd);
+ DelFd(fd);
+ } else {
+ buf[ret] = 0;
+ LogPrintln("[%d]Received: %s", fd, buf);
+ if (strstr(buf, "Bye") != NULL) {
+ DelFd(fd);
+ gBye++;
+ }
+ }
+ return -(ret < 0);
+}
+
+static int HandleAccept(int lsfd)
+{
+ struct sockaddr_in sa;
+ int saLen = sizeof(sa);
+ int fd = accept(lsfd, (struct sockaddr *)&sa, (socklen_t *)&saLen);
+ if (fd == INVALID_SOCKET) {
+ perror("accept");
+ return -1;
+ }
+
+ if (AddFd(fd) == -1) {
+ LogPrintln("Too many clients, refuse %s:%d", inet_ntoa(sa.sin_addr), ntohs(sa.sin_port));
+ close(fd);
+ return -1;
+ }
+ LogPrintln("New client %d: %s:%d", fd, inet_ntoa(sa.sin_addr), ntohs(sa.sin_port));
+ return 0;
+}
+
+static int HandleReadfds(fd_set *fds, int lsfd)
+{
+ int ret = 0;
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ if (gFds[i] == INVALID_SOCKET || !FD_ISSET(gFds[i], fds)) {
+ continue;
+ }
+ if (gFds[i] == lsfd) {
+ ret += HandleAccept(lsfd);
+ } else {
+ ret += HandleRecv(gFds[i]);
+ }
+ }
+ return ret;
+}
+
+static void *ClientsThread(void *param)
+{
+ int fd;
+ int thrNo = (int)(intptr_t)param;
+
+ LogPrintln("<%d>socket client thread started", thrNo);
+ fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (fd == INVALID_SOCKET) {
+ perror("socket");
+ return NULL;
+ }
+
+ struct sockaddr_in sa;
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ sa.sin_port = htons(SERVER_PORT);
+ if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
+ perror("connect");
+ return NULL;
+ }
+
+ LogPrintln("[%d]<%d>connected to %s:%d successful", fd, thrNo, inet_ntoa(sa.sin_addr), SERVER_PORT);
+
+ const char *msg[] = {
+ "hello, ",
+ "ohos, ",
+ "my name is net_socket_test_008, ",
+ "see u next time, ",
+ "Bye!"
+ };
+
+ for (int i = 0; i < sizeof(msg) / sizeof(msg[0]); ++i) {
+ if (send(fd, msg[i], strlen(msg[i]), 0) < 0) {
+ LogPrintln("[%d]<%d>send msg [%s] fail", fd, thrNo, msg[i]);
+ }
+ }
+
+ (void)shutdown(fd, SHUT_RDWR);
+ (void)close(fd);
+ return param;
+}
+
+static int StartClients(pthread_t *cli, int cliNum)
+{
+ int ret;
+ pthread_attr_t attr;
+
+ for (int i = 0; i < cliNum; ++i) {
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&cli[i], &attr, ClientsThread, (void *)(intptr_t)i);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ }
+ return 0;
+}
+
+static int SelectTest(void)
+{
+ struct sockaddr_in sa = {0};
+ int lsfd;
+ int ret;
+
+ lsfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ ICUNIT_ASSERT_NOT_EQUAL(lsfd, -1, errno);
+
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = htonl(INADDR_ANY);
+ sa.sin_port = htons(SERVER_PORT);
+ ret = bind(lsfd, (struct sockaddr *)&sa, sizeof(sa));
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, errno + CloseAllFd());
+
+ ret = listen(lsfd, BACKLOG);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, errno + CloseAllFd());
+
+ InitFds();
+ AddFd(lsfd);
+ LogPrintln("[%d]Waiting for client to connect on port %d", lsfd, SERVER_PORT);
+
+ pthread_t clients[CLIENT_NUM];
+
+ ret = StartClients(clients, CLIENT_NUM);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret + CloseAllFd());
+
+ for ( ; ; ) {
+ int nfd;
+ fd_set readfds;
+ struct timeval timeout;
+
+ timeout.tv_sec = 3;
+ timeout.tv_usec = 0;
+
+ nfd = 0;
+ FD_ZERO(&readfds);
+
+ GetReadfds(&readfds, &nfd);
+
+ ret = select(nfd + 1, &readfds, NULL, NULL, &timeout);
+ LogPrintln("select %d", ret);
+ if (ret == -1) {
+ perror("select");
+ break; // error occurred
+ } else if (ret == 0) {
+ break; // timed out
+ }
+
+ if (HandleReadfds(&readfds, lsfd) < 0) {
+ break;
+ }
+ }
+
+ for (int i = 0; i < CLIENT_NUM; ++i) {
+ ret = pthread_join(clients[i], NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret + CloseAllFd());
+ }
+
+ ICUNIT_ASSERT_EQUAL(gBye, CLIENT_NUM, gBye + CloseAllFd());
+ (void)CloseAllFd();
+ return ICUNIT_SUCCESS;
+}
+
+void NetSocketTest008(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, SelectTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_009.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_009.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f864727ef56e293f33fcc48f3fbbeefe892981d3
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_009.cpp
@@ -0,0 +1,278 @@
+/*
+ * 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
+#include
+#include
+#include
+#include
+
+#define SERVER_PORT 8888
+#define INVALID_SOCKET -1
+#define CLIENT_NUM 25
+#define BACKLOG CLIENT_NUM
+
+static int gFds[FD_SETSIZE];
+static int gBye;
+
+static void InitFds()
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ gFds[i] = INVALID_SOCKET;
+ }
+}
+
+static void GetReadfds(struct pollfd *fds, int *nfd)
+{
+ for (int i = 0; i < FD_SETSIZE; i++) {
+ if (gFds[i] == INVALID_SOCKET) {
+ continue;
+ }
+ fds[*nfd].fd = gFds[i];
+ fds[*nfd].events = POLLIN;
+ (*nfd)++;
+ }
+}
+
+static int AddFd(int fd)
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ if (gFds[i] == INVALID_SOCKET) {
+ gFds[i] = fd;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static void DelFd(int fd)
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ if (gFds[i] == fd) {
+ gFds[i] = INVALID_SOCKET;
+ }
+ }
+ (void)close(fd);
+}
+
+static int CloseAllFd(void)
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ if (gFds[i] != INVALID_SOCKET) {
+ (void)close(gFds[i]);
+ gFds[i] = INVALID_SOCKET;
+ }
+ }
+ return 0;
+}
+
+static int HandleRecv(int fd)
+{
+ char buf[256];
+ int ret = recv(fd, buf, sizeof(buf)-1, 0);
+ if (ret < 0) {
+ LogPrintln("[%d]Error: %s", fd, strerror(errno));
+ DelFd(fd);
+ } else if (ret == 0) {
+ LogPrintln("[%d]Closed", fd);
+ DelFd(fd);
+ } else {
+ buf[ret] = 0;
+ LogPrintln("[%d]Received: %s", fd, buf);
+ if (strstr(buf, "Bye") != NULL) {
+ DelFd(fd);
+ gBye++;
+ }
+ }
+ return -(ret < 0);
+}
+
+static int HandleAccept(int lsfd)
+{
+ struct sockaddr_in sa;
+ int saLen = sizeof(sa);
+ int fd = accept(lsfd, (struct sockaddr *)&sa, (socklen_t *)&saLen);
+ if (fd == INVALID_SOCKET) {
+ perror("accept");
+ return -1;
+ }
+
+ if (AddFd(fd) == -1) {
+ LogPrintln("Too many clients, refuse %s:%d", inet_ntoa(sa.sin_addr), ntohs(sa.sin_port));
+ close(fd);
+ return -1;
+ }
+ LogPrintln("New client %d: %s:%d", fd, inet_ntoa(sa.sin_addr), ntohs(sa.sin_port));
+ return 0;
+}
+
+static int HandleReadfds(struct pollfd *fds, int nfds, int lsfd)
+{
+ int ret = 0;
+ for (int i = 0; i < nfds; ++i) {
+ if (fds[i].revents == 0) {
+ continue;
+ }
+ LogPrintln("[%d]revents: %04hx", fds[i].fd, fds[i].revents);
+ if (fds[i].fd == lsfd) {
+ ret += HandleAccept(lsfd);
+ } else {
+ ret += HandleRecv(fds[i].fd);
+ }
+ }
+ return ret;
+}
+
+static void *ClientsThread(void *param)
+{
+ int fd;
+ int thrNo = (int)(intptr_t)param;
+
+ LogPrintln("<%d>socket client thread started", thrNo);
+ fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (fd == INVALID_SOCKET) {
+ perror("socket");
+ return NULL;
+ }
+
+ struct sockaddr_in sa;
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ sa.sin_port = htons(SERVER_PORT);
+ if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
+ perror("connect");
+ return NULL;
+ }
+
+ LogPrintln("[%d]<%d>connected to %s:%d successful", fd, thrNo, inet_ntoa(sa.sin_addr), SERVER_PORT);
+
+ const char *msg[] = {
+ "hello, ",
+ "ohos, ",
+ "my name is net_socket_test_009, ",
+ "see u next time, ",
+ "Bye!"
+ };
+
+ for (int i = 0; i < sizeof(msg) / sizeof(msg[0]); ++i) {
+ if (send(fd, msg[i], strlen(msg[i]), 0) < 0) {
+ LogPrintln("[%d]<%d>send msg [%s] fail", fd, thrNo, msg[i]);
+ }
+ }
+
+ (void)shutdown(fd, SHUT_RDWR);
+ (void)close(fd);
+ return param;
+}
+
+static int StartClients(pthread_t *cli, int cliNum)
+{
+ int ret;
+ pthread_attr_t attr;
+
+ for (int i = 0; i < cliNum; ++i) {
+ ret = pthread_attr_init(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_create(&cli[i], &attr, ClientsThread, (void *)(intptr_t)i);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ }
+ return 0;
+}
+
+static int PollTest(void)
+{
+ struct sockaddr_in sa = {0};
+ int lsfd;
+ int ret;
+
+ lsfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ ICUNIT_ASSERT_NOT_EQUAL(lsfd, -1, errno);
+
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = htonl(INADDR_ANY);
+ sa.sin_port = htons(SERVER_PORT);
+ ret = bind(lsfd, (struct sockaddr *)&sa, sizeof(sa));
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, errno + CloseAllFd());
+
+ ret = listen(lsfd, BACKLOG);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, errno + CloseAllFd());
+
+ InitFds();
+ AddFd(lsfd);
+ LogPrintln("[%d]Waiting for client to connect on port %d", lsfd, SERVER_PORT);
+
+ pthread_t clients[CLIENT_NUM];
+
+ ret = StartClients(clients, CLIENT_NUM);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret + CloseAllFd());
+
+ for ( ; ; ) {
+ int nfd;
+ struct pollfd readfds[FD_SETSIZE];
+ int timeoutMs;
+
+ timeoutMs = 3000;
+ nfd = 0;
+ GetReadfds(readfds, &nfd);
+
+ ret = poll(readfds, nfd, timeoutMs);
+ LogPrintln("poll %d", ret);
+ if (ret == -1) {
+ perror("poll");
+ break; // error occurred
+ } else if (ret == 0) {
+ break; // timed out
+ }
+
+ if (HandleReadfds(readfds, nfd, lsfd) < 0) {
+ break;
+ }
+ }
+
+ for (int i = 0; i < CLIENT_NUM; ++i) {
+ ret = pthread_join(clients[i], NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret + CloseAllFd());
+ }
+
+ ICUNIT_ASSERT_EQUAL(gBye, CLIENT_NUM, gBye + CloseAllFd());
+ (void)CloseAllFd();
+ return ICUNIT_SUCCESS;
+}
+
+void NetSocketTest009(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, PollTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_010.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_010.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..5638d094c1cb00ba36346f79c90e0fbfd448735d
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_010.cpp
@@ -0,0 +1,191 @@
+/*
+ * 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
+#include
+#include
+#include
+#include
+#include
+#include
+
+static char gDefaultNetif[IFNAMSIZ] = "eth0";
+
+static void InitIfreq(struct ifreq *ifr)
+{
+ *ifr = (struct ifreq){{0}};
+ (void)strncpy_s(ifr->ifr_name, sizeof(ifr->ifr_name) - 1, gDefaultNetif, sizeof(ifr->ifr_name) - 1);
+ ifr->ifr_name[sizeof(ifr->ifr_name) - 1] = '\0';
+}
+
+static char *IfIndex2Name(int fd, unsigned index, char *name)
+{
+#if SUPPORT_IF_INDEX_TO_NAME
+ return if_indextoname(index, name);
+#else
+ struct ifreq ifr;
+ int ret;
+
+ ifr.ifr_ifindex = index;
+ ret = ioctl(fd, SIOCGIFNAME, &ifr);
+ if (ret < 0) {
+ return NULL;
+ }
+ ret = strncpy_s(name, IF_NAMESIZE - 1, ifr.ifr_name, IF_NAMESIZE - 1);
+ if (ret < 0) {
+ return NULL;
+ }
+ name[IF_NAMESIZE - 1] = '\0';
+ return name;
+#endif
+}
+
+static unsigned IfName2Index(int fd, const char *name)
+{
+#if SUPPORT_IF_NAME_TO_INDEX
+ return if_nametoindex(name);
+#else
+ struct ifreq ifr;
+ int ret;
+
+ (void)strncpy_s(ifr.ifr_name, sizeof(ifr.ifr_name) - 1, name, sizeof(ifr.ifr_name) - 1);
+ ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+ ret = ioctl(fd, SIOCGIFINDEX, &ifr);
+ return ret < 0 ? 0 : ifr.ifr_ifindex;
+#endif
+}
+
+static int IoctlTestInternal(int sfd)
+{
+ struct ifreq ifr = {{0}};
+ char ifName[IFNAMSIZ] = {0}, *p = NULL;
+ unsigned int loIndex = 0;
+ unsigned int lanIndex = 0;
+ int maxIndex = 256;
+ int ret;
+
+ for (int i = 0; i < maxIndex; ++i) {
+ p = IfIndex2Name(sfd, i, ifName);
+ if (p) {
+ if (strcmp(p, "lo") == 0) {
+ loIndex = i;
+ } else {
+ lanIndex = i;
+ }
+ }
+ }
+
+ LogPrintln("ifindex of lo: %u, ifindex of lan: %u", loIndex, lanIndex);
+ ICUNIT_ASSERT_NOT_EQUAL(loIndex, 0, errno);
+ ICUNIT_ASSERT_NOT_EQUAL(lanIndex, 0, errno);
+
+ p = IfIndex2Name(sfd, loIndex, ifName);
+ LogPrintln("ifindex %u: %s", loIndex, p);
+ ICUNIT_ASSERT_NOT_EQUAL(p, NULL, errno);
+
+ p = IfIndex2Name(sfd, lanIndex, ifName);
+ LogPrintln("ifindex %u: %s", lanIndex, p);
+ ICUNIT_ASSERT_NOT_EQUAL(p, NULL, errno);
+
+ ret = strncpy_s(gDefaultNetif, sizeof(gDefaultNetif) -1, p, sizeof(gDefaultNetif) - 1);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ gDefaultNetif[sizeof(gDefaultNetif) - 1] = '\0';
+
+ ret = (int)IfName2Index(sfd, p);
+ LogPrintln("index of %s: %d", p, ret);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, 0, errno);
+
+ ifr.ifr_ifindex = lanIndex;
+ ret = ioctl(sfd, SIOCGIFNAME, &ifr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, errno);
+ LogPrintln("name of ifindex %u: %s", lanIndex, ifr.ifr_name);
+
+ InitIfreq(&ifr);
+ ret = ioctl(sfd, SIOCGIFINDEX, &ifr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, errno);
+ LogPrintln("index of ifname %s: %d", ifr.ifr_name, ifr.ifr_ifindex);
+
+ InitIfreq(&ifr);
+ ret = ioctl(sfd, SIOCGIFHWADDR, &ifr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, errno);
+ LogPrintln("hwaddr: %02hhX:%02hhX:%02hhX:XX:XX:XX", ifr.ifr_hwaddr.sa_data[0], ifr.ifr_hwaddr.sa_data[1], ifr.ifr_hwaddr.sa_data[2]);
+
+ InitIfreq(&ifr);
+ ret = ioctl(sfd, SIOCGIFFLAGS, &ifr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, errno);
+ LogPrintln("FLAGS of ifname %s: %#x, IFF_PROMISC: %d", ifr.ifr_name, ifr.ifr_flags, !!(ifr.ifr_flags & IFF_PROMISC));
+
+ if (ifr.ifr_flags & IFF_PROMISC) {
+ ifr.ifr_flags &= ~(IFF_PROMISC);
+ } else {
+ ifr.ifr_flags |= IFF_PROMISC;
+ }
+ LogPrintln("SIOCSIFFLAGS FLAGS: %#x", ifr.ifr_flags);
+ ret = ioctl(sfd, SIOCSIFFLAGS, &ifr);
+ if (ret == -1) {
+ ICUNIT_ASSERT_EQUAL(errno, EPERM, errno);
+ } else {
+ ICUNIT_ASSERT_EQUAL(ret, 0, errno);
+ }
+
+ InitIfreq(&ifr);
+ ret = ioctl(sfd, SIOCGIFFLAGS, &ifr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, errno);
+ LogPrintln("FLAGS of ifname %s: %#x, IFF_PROMISC: %d", ifr.ifr_name, ifr.ifr_flags, !!(ifr.ifr_flags & IFF_PROMISC));
+
+ ret = fcntl(sfd, F_GETFL, 0);
+ ICUNIT_ASSERT_EQUAL(ret < 0, 0, errno);
+
+ ret = fcntl(sfd, F_SETFL, ret | O_NONBLOCK);
+ ICUNIT_ASSERT_EQUAL(ret < 0, 0, errno);
+
+ return ICUNIT_SUCCESS;
+}
+
+static int IoctlTest(void)
+{
+ int sfd;
+
+ sfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ LogPrintln("socket(PF_INET, SOCK_STREAM, IPPROTO_TCP): %d", sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, errno);
+
+ (void)IoctlTestInternal(sfd);
+
+ (void)close(sfd);
+ return ICUNIT_SUCCESS;
+}
+
+void NetSocketTest010(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, IoctlTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_011.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_011.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e71a30c7928ea974ba8020de577bb8e1ecdf13de
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_011.cpp
@@ -0,0 +1,259 @@
+/*
+ * 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
+#include
+#include
+#include
+#include
+
+#define SERVER_PORT 7777
+#define INVALID_SOCKET -1
+#define CLIENT_NUM 25
+
+static int gFds[FD_SETSIZE];
+static int gBye;
+
+static void InitFds()
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ gFds[i] = INVALID_SOCKET;
+ }
+}
+
+static void GetReadfds(fd_set *fds, int *nfd)
+{
+ for (int i = 0; i < FD_SETSIZE; i++) {
+ if (gFds[i] == INVALID_SOCKET) {
+ continue;
+ }
+ FD_SET(gFds[i], fds);
+ if (*nfd < gFds[i]) {
+ *nfd = gFds[i];
+ }
+ }
+}
+
+static int AddFd(int fd)
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ if (gFds[i] == INVALID_SOCKET) {
+ gFds[i] = fd;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static void DelFd(int fd)
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ if (gFds[i] == fd) {
+ gFds[i] = INVALID_SOCKET;
+ }
+ }
+ (void)close(fd);
+}
+
+static int CloseAllFd(void)
+{
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ if (gFds[i] != INVALID_SOCKET) {
+ (void)close(gFds[i]);
+ gFds[i] = INVALID_SOCKET;
+ }
+ }
+ return 0;
+}
+
+static int HandleRecv(int fd)
+{
+ char buf[128];
+ int ret = recv(fd, buf, sizeof(buf)-1, 0);
+ if (ret < 0) {
+ LogPrintln("[%d]Error: %s", fd, strerror(errno));
+ DelFd(fd);
+ } else if (ret == 0) {
+ LogPrintln("[%d]Closed", fd);
+ DelFd(fd);
+ } else {
+ buf[ret] = 0;
+ LogPrintln("[%d]Received: %s", fd, buf);
+ if (strstr(buf, "Bye") != NULL) {
+ gBye++;
+ }
+ }
+ return -(ret < 0);
+}
+
+static int HandleReadfds(fd_set *fds, int lsfd)
+{
+ int ret = 0;
+ for (int i = 0; i < FD_SETSIZE; ++i) {
+ if (gFds[i] == INVALID_SOCKET || !FD_ISSET(gFds[i], fds)) {
+ continue;
+ }
+ ret += HandleRecv(gFds[i]);
+ }
+ return ret;
+}
+
+static void *ClientsThread(void *param)
+{
+ int fd;
+ int thrNo = (int)(intptr_t)param;
+
+ LogPrintln("<%d>socket client thread started", thrNo);
+ fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (fd == INVALID_SOCKET) {
+ perror("socket");
+ return NULL;
+ }
+
+ struct sockaddr_in sa;
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ sa.sin_port = htons(SERVER_PORT);
+ if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) == -1) {
+ perror("connect");
+ return NULL;
+ }
+
+ LogPrintln("[%d]<%d>connected to udp://%s:%d successful", fd, thrNo, inet_ntoa(sa.sin_addr), SERVER_PORT);
+
+ const char *msg[] = {
+ "ohos, ",
+ "hello, ",
+ "my name is net_socket_test_011, ",
+ "see u next time, ",
+ "Bye!",
+ };
+
+ for (int i = 0; i < sizeof(msg) / sizeof(msg[0]); ++i) {
+ if (send(fd, msg[i], strlen(msg[i]), 0) < 0) {
+ LogPrintln("[%d]<%d>send msg [%s] fail", fd, thrNo, msg[i]);
+ }
+ }
+
+ (void)shutdown(fd, SHUT_RDWR);
+ (void)close(fd);
+ return param;
+}
+
+static int StartClients(pthread_t *cli, int cliNum)
+{
+ int ret;
+ pthread_attr_t attr = {0};
+ struct sched_param param = { 0 };
+ int policy;
+ ret = pthread_getschedparam(pthread_self(), &policy, ¶m);
+ ICUNIT_ASSERT_EQUAL(ret, 0, -ret);
+
+ for (int i = 0; i < cliNum; ++i) {
+ ret = pthread_attr_init(&attr);
+ param.sched_priority = param.sched_priority + 1;
+ pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
+ pthread_attr_setschedparam(&attr, ¶m);
+
+ ret = pthread_create(&cli[i], &attr, ClientsThread, (void *)(intptr_t)i);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ ret = pthread_attr_destroy(&attr);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret);
+ }
+ return 0;
+}
+
+static int UdpSelectTest(void)
+{
+ struct sockaddr_in sa = {0};
+ int lsfd;
+ int ret;
+
+ lsfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ ICUNIT_ASSERT_NOT_EQUAL(lsfd, -1, errno);
+
+ sa.sin_family = AF_INET;
+ sa.sin_addr.s_addr = htonl(INADDR_ANY);
+ sa.sin_port = htons(SERVER_PORT);
+ ret = bind(lsfd, (struct sockaddr *)&sa, sizeof(sa));
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, errno + CloseAllFd());
+
+ InitFds();
+ AddFd(lsfd);
+ LogPrintln("[%d]Waiting for client to connect on UDP port %d", lsfd, SERVER_PORT);
+
+ pthread_t clients[CLIENT_NUM];
+
+ ret = StartClients(clients, CLIENT_NUM);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret + CloseAllFd());
+
+ for ( ; ; ) {
+ int nfd;
+ fd_set readfds;
+ struct timeval timeout;
+
+ timeout.tv_sec = 3;
+ timeout.tv_usec = 0;
+
+ nfd = 0;
+ FD_ZERO(&readfds);
+
+ GetReadfds(&readfds, &nfd);
+
+ ret = select(nfd + 1, &readfds, NULL, NULL, &timeout);
+ LogPrintln("select %d", ret);
+ if (ret == -1) {
+ perror("select");
+ break; // error occurred
+ } else if (ret == 0) {
+ break; // timed out
+ }
+
+ if (HandleReadfds(&readfds, lsfd) < 0) {
+ break;
+ }
+ }
+
+ for (int i = 0; i < CLIENT_NUM; ++i) {
+ ret = pthread_join(clients[i], NULL);
+ ICUNIT_ASSERT_EQUAL(ret, 0, ret + CloseAllFd());
+ }
+
+ ICUNIT_ASSERT_EQUAL(gBye, CLIENT_NUM, gBye + CloseAllFd());
+ (void)CloseAllFd();
+ return ICUNIT_SUCCESS;
+}
+
+void NetSocketTest011(void)
+{
+ TEST_ADD_CASE(__FUNCTION__, UdpSelectTest, TEST_POSIX, TEST_TCP, TEST_LEVEL0, TEST_FUNCTION);
+}
diff --git a/testsuites/unittest/net/socket/smoke/net_socket_test_012.cpp b/testsuites/unittest/net/socket/smoke/net_socket_test_012.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f7d684c297b7efdfa32f50eec21415347c59bf35
--- /dev/null
+++ b/testsuites/unittest/net/socket/smoke/net_socket_test_012.cpp
@@ -0,0 +1,451 @@
+/*
+ * 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
+#include