未验证 提交 1b11caa4 编写于 作者: O openharmony_ci 提交者: Gitee

!853 检视问题修复

Merge pull request !853 from wangchen/0322_up
...@@ -53,7 +53,9 @@ static void LmsMallocTest(void) ...@@ -53,7 +53,9 @@ static void LmsMallocTest(void)
#define TEST_SIZE 16 #define TEST_SIZE 16
printf("\n-------- LmsMallocTest Start --------\n"); printf("\n-------- LmsMallocTest Start --------\n");
char *buf = (char *)malloc(TEST_SIZE); char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsMallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n"); printf("[LmsMallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n");
BufReadTest(buf, -1, TEST_SIZE); BufReadTest(buf, -1, TEST_SIZE);
printf("[LmsMallocTest] write overflow error should be triggered, write range[0, TEST_SIZE]\n"); printf("[LmsMallocTest] write overflow error should be triggered, write range[0, TEST_SIZE]\n");
...@@ -88,6 +90,9 @@ static void LmsCallocTest(void) ...@@ -88,6 +90,9 @@ static void LmsCallocTest(void)
#define TEST_SIZE 16 #define TEST_SIZE 16
printf("\n-------- LmsCallocTest Start --------\n"); printf("\n-------- LmsCallocTest Start --------\n");
char *buf = (char *)calloc(4, 4); /* 4: test size */ char *buf = (char *)calloc(4, 4); /* 4: test size */
if (buf == NULL) {
return;
}
printf("[LmsCallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n"); printf("[LmsCallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n");
BufReadTest(buf, -1, TEST_SIZE); BufReadTest(buf, -1, TEST_SIZE);
free(buf); free(buf);
...@@ -99,6 +104,9 @@ static void LmsVallocTest(void) ...@@ -99,6 +104,9 @@ static void LmsVallocTest(void)
#define TEST_SIZE 4096 #define TEST_SIZE 4096
printf("\n-------- LmsVallocTest Start --------\n"); printf("\n-------- LmsVallocTest Start --------\n");
char *buf = (char *)valloc(TEST_SIZE); char *buf = (char *)valloc(TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsVallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n"); printf("[LmsVallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n");
BufReadTest(buf, -1, TEST_SIZE); BufReadTest(buf, -1, TEST_SIZE);
free(buf); free(buf);
...@@ -111,6 +119,9 @@ static void LmsAlignedAllocTest(void) ...@@ -111,6 +119,9 @@ static void LmsAlignedAllocTest(void)
#define TEST_SIZE 128 #define TEST_SIZE 128
printf("\n-------- LmsAlignedAllocTest Start --------\n"); printf("\n-------- LmsAlignedAllocTest Start --------\n");
char *buf = (char *)aligned_alloc(TEST_ALIGN_SIZE, TEST_SIZE); char *buf = (char *)aligned_alloc(TEST_ALIGN_SIZE, TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsAlignedAllocTest] read overflow & underflow error should be triggered, read range[-1,128]\n"); printf("[LmsAlignedAllocTest] read overflow & underflow error should be triggered, read range[-1,128]\n");
BufReadTest(buf, -1, 128); BufReadTest(buf, -1, 128);
free(buf); free(buf);
...@@ -122,6 +133,9 @@ static void LmsMemsetTest(void) ...@@ -122,6 +133,9 @@ static void LmsMemsetTest(void)
#define TEST_SIZE 32 #define TEST_SIZE 32
printf("\n-------- LmsMemsetTest Start --------\n"); printf("\n-------- LmsMemsetTest Start --------\n");
char *buf = (char *)malloc(TEST_SIZE); char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsMemsetTest] memset overflow & underflow error should be triggered, memset size:%d\n", TEST_SIZE + 1); printf("[LmsMemsetTest] memset overflow & underflow error should be triggered, memset size:%d\n", TEST_SIZE + 1);
memset(buf, 0, TEST_SIZE + 1); memset(buf, 0, TEST_SIZE + 1);
free(buf); free(buf);
...@@ -133,6 +147,9 @@ static void LmsMemcpyTest(void) ...@@ -133,6 +147,9 @@ static void LmsMemcpyTest(void)
#define TEST_SIZE 20 #define TEST_SIZE 20
printf("\n-------- LmsMemcpyTest Start --------\n"); printf("\n-------- LmsMemcpyTest Start --------\n");
char *buf = (char *)malloc(TEST_SIZE); char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
char localBuf[32] = {0}; /* 32: test size */ char localBuf[32] = {0}; /* 32: test size */
printf("[LmsMemcpyTest] memcpy overflow error should be triggered, memcpy size:%d\n", TEST_SIZE + 1); printf("[LmsMemcpyTest] memcpy overflow error should be triggered, memcpy size:%d\n", TEST_SIZE + 1);
memcpy(buf, localBuf, TEST_SIZE + 1); memcpy(buf, localBuf, TEST_SIZE + 1);
...@@ -145,6 +162,9 @@ static void LmsMemmoveTest(void) ...@@ -145,6 +162,9 @@ static void LmsMemmoveTest(void)
#define TEST_SIZE 20 #define TEST_SIZE 20
printf("\n-------- LmsMemmoveTest Start --------\n"); printf("\n-------- LmsMemmoveTest Start --------\n");
char *buf = (char *)malloc(TEST_SIZE); char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsMemmoveTest] memmove overflow error should be triggered\n"); printf("[LmsMemmoveTest] memmove overflow error should be triggered\n");
memmove(buf + 12, buf, 10); /* 12 and 10: test size */ memmove(buf + 12, buf, 10); /* 12 and 10: test size */
free(buf); free(buf);
...@@ -156,6 +176,9 @@ static void LmsStrcpyTest(void) ...@@ -156,6 +176,9 @@ static void LmsStrcpyTest(void)
#define TEST_SIZE 16 #define TEST_SIZE 16
printf("\n-------- LmsStrcpyTest Start --------\n"); printf("\n-------- LmsStrcpyTest Start --------\n");
char *buf = (char *)malloc(TEST_SIZE); char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
char *testStr = "bbbbbbbbbbbbbbbbb"; char *testStr = "bbbbbbbbbbbbbbbbb";
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n", strlen(testStr) + 1); printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n", strlen(testStr) + 1);
strcpy(buf, testStr); strcpy(buf, testStr);
...@@ -168,6 +191,9 @@ static void LmsStrcatTest(void) ...@@ -168,6 +191,9 @@ static void LmsStrcatTest(void)
#define TEST_SIZE 16 #define TEST_SIZE 16
printf("\n-------- LmsStrcatTest Start --------\n"); printf("\n-------- LmsStrcatTest Start --------\n");
char *buf = (char *)malloc(TEST_SIZE); char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
buf[0] = 'a'; buf[0] = 'a';
buf[1] = 'b'; buf[1] = 'b';
buf[2] = 0; buf[2] = 0;
...@@ -185,6 +211,9 @@ static void LmsFreeTest(void) ...@@ -185,6 +211,9 @@ static void LmsFreeTest(void)
#define TEST_SIZE 16 #define TEST_SIZE 16
printf("\n-------- LmsFreeTest Start --------\n"); printf("\n-------- LmsFreeTest Start --------\n");
char *buf = (char *)malloc(TEST_SIZE); char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsFreeTest] free size:%d\n", TEST_SIZE); printf("[LmsFreeTest] free size:%d\n", TEST_SIZE);
free(buf); free(buf);
printf("[LmsFreeTest] Use after free error should be triggered, read range[1,1]\n"); printf("[LmsFreeTest] Use after free error should be triggered, read range[1,1]\n");
...@@ -200,6 +229,9 @@ int main(int argc, char * const *argv) ...@@ -200,6 +229,9 @@ int main(int argc, char * const *argv)
(void)argv; (void)argv;
printf("\n############### Lms Test start ###############\n"); printf("\n############### Lms Test start ###############\n");
char *tmp = (char *)malloc(5000); /* 5000: test mem size */ char *tmp = (char *)malloc(5000); /* 5000: test mem size */
if (tmp == NULL) {
return;
}
LmsMallocTest(); LmsMallocTest();
LmsReallocTest(); LmsReallocTest();
LmsCallocTest(); LmsCallocTest();
......
...@@ -41,7 +41,7 @@ void RandomOperationsInit(const RandomOperations *r) ...@@ -41,7 +41,7 @@ void RandomOperationsInit(const RandomOperations *r)
if (r != NULL) { if (r != NULL) {
(void)memcpy_s(&g_randomOp, sizeof(RandomOperations), r, sizeof(RandomOperations)); (void)memcpy_s(&g_randomOp, sizeof(RandomOperations), r, sizeof(RandomOperations));
} else { } else {
PRINT_ERR("param is invalid\n", __FUNCTION__, __LINE__); PRINT_ERR("%s %d param is invalid\n", __FUNCTION__, __LINE__);
} }
return; return;
} }
......
...@@ -55,14 +55,15 @@ INT32 OsMountPatchFs(VOID) ...@@ -55,14 +55,15 @@ INT32 OsMountPatchFs(VOID)
} }
partInfo.fsType = strdup(FS_TYPE); partInfo.fsType = strdup(FS_TYPE);
if (partInfo.fsType == NULL) { if (partInfo.fsType == NULL) {
return LOS_NOK; ret = LOS_NOK;
goto EXIT;
} }
partInfo.startAddr = PATCHFS_FLASH_ADDR; partInfo.startAddr = PATCHFS_FLASH_ADDR;
partInfo.partSize = PATCHFS_FLASH_SIZE; partInfo.partSize = PATCHFS_FLASH_SIZE;
#else #else
ret = GetPartitionInfo(&partInfo); ret = GetPartitionInfo(&partInfo);
if (ret != LOS_OK) { if (ret != LOS_OK) {
return ret; goto EXIT;
} }
partInfo.startAddr = (partInfo.startAddr >= 0) ? partInfo.startAddr : PATCHFS_FLASH_ADDR; partInfo.startAddr = (partInfo.startAddr >= 0) ? partInfo.startAddr : PATCHFS_FLASH_ADDR;
partInfo.partSize = (partInfo.partSize >= 0) ? partInfo.partSize : PATCHFS_FLASH_SIZE; partInfo.partSize = (partInfo.partSize >= 0) ? partInfo.partSize : PATCHFS_FLASH_SIZE;
...@@ -71,7 +72,7 @@ INT32 OsMountPatchFs(VOID) ...@@ -71,7 +72,7 @@ INT32 OsMountPatchFs(VOID)
ret = LOS_NOK; ret = LOS_NOK;
partInfo.devName = strdup(PATCH_FLASH_DEV_NAME); partInfo.devName = strdup(PATCH_FLASH_DEV_NAME);
if (partInfo.devName == NULL) { if (partInfo.devName == NULL) {
return LOS_NOK; goto EXIT;
} }
const CHAR *devName = GetDevNameOfPartition(&partInfo); const CHAR *devName = GetDevNameOfPartition(&partInfo);
if (devName != NULL) { if (devName != NULL) {
...@@ -92,9 +93,13 @@ INT32 OsMountPatchFs(VOID) ...@@ -92,9 +93,13 @@ INT32 OsMountPatchFs(VOID)
ResetDevNameofPartition(&partInfo); ResetDevNameofPartition(&partInfo);
} }
EXIT:
free(partInfo.devName); free(partInfo.devName);
partInfo.devName = NULL;
free(partInfo.storageType); free(partInfo.storageType);
partInfo.storageType = NULL;
free(partInfo.fsType); free(partInfo.fsType);
partInfo.fsType = NULL;
return ret; return ret;
} }
......
...@@ -214,7 +214,7 @@ UINT64 LOS_SizeStrToNum(CHAR *value) ...@@ -214,7 +214,7 @@ UINT64 LOS_SizeStrToNum(CHAR *value)
UINT64 num = 0; UINT64 num = 0;
/* If the string is a hexadecimal value */ /* If the string is a hexadecimal value */
if (sscanf_s(value, "0x%x", &num) > 0) { if (sscanf_s(value, "0x%llx", &num) > 0) {
value += strlen("0x"); value += strlen("0x");
if (strspn(value, "0123456789abcdefABCDEF") < strlen(value)) { if (strspn(value, "0123456789abcdefABCDEF") < strlen(value)) {
goto ERROUT; goto ERROUT;
...@@ -247,4 +247,4 @@ UINT64 LOS_SizeStrToNum(CHAR *value) ...@@ -247,4 +247,4 @@ UINT64 LOS_SizeStrToNum(CHAR *value)
ERROUT: ERROUT:
PRINT_ERR("Invalid value string \"%s\"!\n", value); PRINT_ERR("Invalid value string \"%s\"!\n", value);
return num; return num;
} }
\ No newline at end of file
...@@ -327,7 +327,7 @@ STATIC INT32 CheckValidation(UINT64 rootAddr, UINT64 rootSize, UINT64 userAddr, ...@@ -327,7 +327,7 @@ STATIC INT32 CheckValidation(UINT64 rootAddr, UINT64 rootSize, UINT64 userAddr,
if ((rootAddr & (alignSize - 1)) || (rootSize & (alignSize - 1)) || if ((rootAddr & (alignSize - 1)) || (rootSize & (alignSize - 1)) ||
(userAddr & (alignSize - 1)) || (userSize & (alignSize - 1))) { (userAddr & (alignSize - 1)) || (userSize & (alignSize - 1))) {
PRINT_ERR("The address or size value should be 0x%x aligned!\n", alignSize); PRINT_ERR("The address or size value should be 0x%llx aligned!\n", alignSize);
return LOS_NOK; return LOS_NOK;
} }
...@@ -371,4 +371,4 @@ INT32 OsMountRootfs() ...@@ -371,4 +371,4 @@ INT32 OsMountRootfs()
} }
return LOS_OK; return LOS_OK;
} }
\ No newline at end of file
...@@ -654,7 +654,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename ...@@ -654,7 +654,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename
char *dst_filepath = NULL; char *dst_filepath = NULL;
char *buf = NULL; char *buf = NULL;
const char *filename = NULL; const char *filename = NULL;
size_t r_size, w_size; ssize_t r_size, w_size;
int src_fd = -1; int src_fd = -1;
int dst_fd = -1; int dst_fd = -1;
struct stat stat_buf; struct stat stat_buf;
...@@ -1391,8 +1391,8 @@ int checkNum(const char *arg) ...@@ -1391,8 +1391,8 @@ int checkNum(const char *arg)
#ifdef LOSCFG_KERNEL_SYSCALL #ifdef LOSCFG_KERNEL_SYSCALL
int osShellCmdSu(int argc, const char **argv) int osShellCmdSu(int argc, const char **argv)
{ {
unsigned int su_uid; int su_uid;
unsigned int su_gid; int su_gid;
if (argc == 0) if (argc == 0)
{ {
......
...@@ -1748,7 +1748,7 @@ STATIC VOID OsMemNodeInfo(const struct OsMemNodeHead *tmpNode, ...@@ -1748,7 +1748,7 @@ STATIC VOID OsMemNodeInfo(const struct OsMemNodeHead *tmpNode,
usedNode->header.ptr.prev, usedNode->header.magic, usedNode->header.sizeAndFlag); usedNode->header.ptr.prev, usedNode->header.magic, usedNode->header.sizeAndFlag);
} else { } else {
freeNode = (struct OsMemFreeNodeHead *)tmpNode; freeNode = (struct OsMemFreeNodeHead *)tmpNode;
PRINTK("\n broken node head: %#x %#x %#x %#x, ", PRINTK("\n broken node head: %#x %#x %#x %#x, %#x",
freeNode->header.ptr.prev, freeNode->next, freeNode->prev, freeNode->header.magic, freeNode->header.ptr.prev, freeNode->next, freeNode->prev, freeNode->header.magic,
freeNode->header.sizeAndFlag); freeNode->header.sizeAndFlag);
} }
...@@ -1759,7 +1759,7 @@ STATIC VOID OsMemNodeInfo(const struct OsMemNodeHead *tmpNode, ...@@ -1759,7 +1759,7 @@ STATIC VOID OsMemNodeInfo(const struct OsMemNodeHead *tmpNode,
usedNode->header.ptr.prev, usedNode->header.magic, usedNode->header.sizeAndFlag); usedNode->header.ptr.prev, usedNode->header.magic, usedNode->header.sizeAndFlag);
} else { } else {
freeNode = (struct OsMemFreeNodeHead *)preNode; freeNode = (struct OsMemFreeNodeHead *)preNode;
PRINTK("prev node head: %#x %#x %#x %#x, ", PRINTK("prev node head: %#x %#x %#x %#x, %#x",
freeNode->header.ptr.prev, freeNode->next, freeNode->prev, freeNode->header.magic, freeNode->header.ptr.prev, freeNode->next, freeNode->prev, freeNode->header.magic,
freeNode->header.sizeAndFlag); freeNode->header.sizeAndFlag);
} }
......
...@@ -117,8 +117,10 @@ VOID OsExcStackInfoReg(const StackInfo *stackInfo, UINT32 stackNum) ...@@ -117,8 +117,10 @@ VOID OsExcStackInfoReg(const StackInfo *stackInfo, UINT32 stackNum)
VOID OsStackInit(VOID *stacktop, UINT32 stacksize) VOID OsStackInit(VOID *stacktop, UINT32 stacksize)
{ {
/* initialize the task stack, write magic num to stack top */ /* initialize the task stack, write magic num to stack top */
(VOID)memset_s(stacktop, stacksize, (INT32)OS_STACK_INIT, stacksize); errno_t ret = memset_s(stacktop, stacksize, (INT32)OS_STACK_INIT, stacksize);
*((UINTPTR *)stacktop) = OS_STACK_MAGIC_WORD; if (ret == EOK) {
*((UINTPTR *)stacktop) = OS_STACK_MAGIC_WORD;
}
} }
#ifdef LOSCFG_SHELL_CMD_DEBUG #ifdef LOSCFG_SHELL_CMD_DEBUG
......
...@@ -148,7 +148,7 @@ static int HiLogBufferCopy(unsigned char *dst, unsigned dstLen, const unsigned c ...@@ -148,7 +148,7 @@ static int HiLogBufferCopy(unsigned char *dst, unsigned dstLen, const unsigned c
static int HiLogReadRingBuffer(unsigned char *buffer, size_t bufLen) static int HiLogReadRingBuffer(unsigned char *buffer, size_t bufLen)
{ {
size_t retval; int retval;
size_t bufLeft = HILOG_BUFFER - g_hiLogDev.headOffset; size_t bufLeft = HILOG_BUFFER - g_hiLogDev.headOffset;
if (bufLeft > bufLen) { if (bufLeft > bufLen) {
retval = HiLogBufferCopy(buffer, bufLen, HiLogBufferHead(), bufLen); retval = HiLogBufferCopy(buffer, bufLen, HiLogBufferHead(), bufLen);
...@@ -165,7 +165,7 @@ static int HiLogReadRingBuffer(unsigned char *buffer, size_t bufLen) ...@@ -165,7 +165,7 @@ static int HiLogReadRingBuffer(unsigned char *buffer, size_t bufLen)
static ssize_t HiLogRead(struct file *filep, char *buffer, size_t bufLen) static ssize_t HiLogRead(struct file *filep, char *buffer, size_t bufLen)
{ {
size_t retval; int retval;
struct HiLogEntry header; struct HiLogEntry header;
(void)filep; (void)filep;
...@@ -209,7 +209,7 @@ out: ...@@ -209,7 +209,7 @@ out:
g_hiLogDev.count = 0; g_hiLogDev.count = 0;
} }
(VOID)LOS_MuxRelease(&g_hiLogDev.mtx); (VOID)LOS_MuxRelease(&g_hiLogDev.mtx);
return retval; return (ssize_t)retval;
} }
static int HiLogWriteRingBuffer(unsigned char *buffer, size_t bufLen) static int HiLogWriteRingBuffer(unsigned char *buffer, size_t bufLen)
......
...@@ -1337,10 +1337,10 @@ out: ...@@ -1337,10 +1337,10 @@ out:
LWIP_STATIC void lwip_arp_usage(const char *cmd) LWIP_STATIC void lwip_arp_usage(const char *cmd)
{ {
PRINTK("Usage:"\ PRINTK("Usage:"
"\n%s" "\n%s"
"\n%s [-i IF] -s IPADDR HWADDR"\ "\n%s [-i IF] -s IPADDR HWADDR"
"\n%s [-i IF] -d IPADDR\n", "\n%s [-i IF] -d IPADDR\n",
cmd, cmd, cmd); cmd, cmd, cmd);
} }
......
...@@ -237,8 +237,6 @@ extern void ICunitSaveErr(iiUINT32 line, iiUINT32 retCode); ...@@ -237,8 +237,6 @@ extern void ICunitSaveErr(iiUINT32 line, iiUINT32 retCode);
#define ICUNIT_SUCCESS 0x00000000 #define ICUNIT_SUCCESS 0x00000000
#if 1
#define ICUNIT_TRACK_EQUAL(param, g_value, retcode) \ #define ICUNIT_TRACK_EQUAL(param, g_value, retcode) \
do { \ do { \
if ((param) != (g_value)) { \ if ((param) != (g_value)) { \
...@@ -414,114 +412,6 @@ extern void ICunitSaveErr(iiUINT32 line, iiUINT32 retCode); ...@@ -414,114 +412,6 @@ extern void ICunitSaveErr(iiUINT32 line, iiUINT32 retCode);
} \ } \
} while (0) } 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
#ifdef LOSCFG_KERNEL_SMP #ifdef LOSCFG_KERNEL_SMP
extern SPIN_LOCK_S g_testSuitSpin; extern SPIN_LOCK_S g_testSuitSpin;
#define TESTSUIT_LOCK(state) LOS_SpinLockSave(&g_testSuitSpin, &(state)) #define TESTSUIT_LOCK(state) LOS_SpinLockSave(&g_testSuitSpin, &(state))
......
...@@ -45,8 +45,6 @@ static void TaskF02(void const * argument) ...@@ -45,8 +45,6 @@ static void TaskF02(void const * argument)
ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 1, ret, EXIT); ICUNIT_GOTO_EQUAL(g_timesliceTestCount, 1, ret, EXIT);
g_timesliceTestCount++; g_timesliceTestCount++;
return; return;
EXIT:;
} }
static void SwtmrF01(UINT32 *arg) static void SwtmrF01(UINT32 *arg)
......
...@@ -117,7 +117,6 @@ EXIT: ...@@ -117,7 +117,6 @@ EXIT:
LOS_TaskDelete(g_testTaskID01); LOS_TaskDelete(g_testTaskID01);
return LOS_OK; return LOS_OK;
return LOS_OK;
} }
VOID ItLosEvent022(VOID) // IT_Layer_ModuleORFeature_No VOID ItLosEvent022(VOID) // IT_Layer_ModuleORFeature_No
......
...@@ -103,7 +103,6 @@ static UINT32 Testcase(void) ...@@ -103,7 +103,6 @@ static UINT32 Testcase(void)
PRINT_DEBUG("ret1= 0x%x,ret2 = 0x%x,ret3=0x%x\n", g_ret1, g_ret2, g_ret3); 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 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) && } else if ((g_ret1 == 0x11) && (g_ret2 == LOS_OK) &&
(g_ret3 == LOS_ERRNO_EVENT_SHOULD_NOT_DESTROY)) { // pend-delete-post (g_ret3 == LOS_ERRNO_EVENT_SHOULD_NOT_DESTROY)) { // pend-delete-post
} else if ((g_ret1 == 0xff) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_OK)) { // post-del-pend } else if ((g_ret1 == 0xff) && (g_ret2 == LOS_OK) && (g_ret3 == LOS_OK)) { // post-del-pend
......
...@@ -56,8 +56,6 @@ static UINT32 Testcase(VOID) ...@@ -56,8 +56,6 @@ static UINT32 Testcase(VOID)
ret = LOS_QueueRead(queueID[index - 1], &buff2, sizeof(UINTPTR), 0); ret = LOS_QueueRead(queueID[index - 1], &buff2, sizeof(UINTPTR), 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); 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. 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); ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT);
EXIT: EXIT:
......
...@@ -46,7 +46,7 @@ UINT32 TestGetSingleHwiCpup(UINT32 hwi, UINT32 mode) ...@@ -46,7 +46,7 @@ UINT32 TestGetSingleHwiCpup(UINT32 hwi, UINT32 mode)
{ {
UINT32 size; UINT32 size;
UINT32 tempHwi; UINT32 tempHwi;
if (hwi < 0 || hwi > OS_HWI_MAX_NUM) { if (hwi > OS_HWI_MAX_NUM) {
return -1; return -1;
} }
......
...@@ -51,7 +51,6 @@ static VOID *PthreadF01(void *argument) ...@@ -51,7 +51,6 @@ static VOID *PthreadF01(void *argument)
pthread_cleanup_push(PthreadCleanF01, (void *)8); // 8, here set value. pthread_cleanup_push(PthreadCleanF01, (void *)8); // 8, here set value.
return (void *)8; // 8, here set value about the return status. return (void *)8; // 8, here set value about the return status.
pthread_cleanup_pop(0)
} }
static UINT32 Testcase(VOID) static UINT32 Testcase(VOID)
...@@ -85,4 +84,4 @@ VOID ItPosixPthread023(VOID) // IT_Layer_ModuleORFeature_No ...@@ -85,4 +84,4 @@ VOID ItPosixPthread023(VOID) // IT_Layer_ModuleORFeature_No
#if __cplusplus #if __cplusplus
} }
#endif /* __cpluscplus */ #endif /* __cpluscplus */
#endif /* __cpluscplus */ #endif /* __cpluscplus */
\ No newline at end of file
...@@ -51,13 +51,17 @@ static UINT32 Testcase(VOID) ...@@ -51,13 +51,17 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc); ICUNIT_ASSERT_EQUAL(rc, 0, rc);
rc = pthread_cond_init(&cond2, NULL); rc = pthread_cond_init(&cond2, NULL);
ICUNIT_ASSERT_EQUAL(rc, 0, rc); ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
rc = pthread_cond_destroy(&cond1); rc = pthread_cond_destroy(&cond1);
ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc); ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
rc = pthread_cond_destroy(&cond2); rc = pthread_cond_destroy(&cond2);
ICUNIT_ASSERT_EQUAL(rc, ENOERR, rc); ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
return PTHREAD_NO_ERROR; return PTHREAD_NO_ERROR;
EXIT:
(void)pthread_cond_destroy(&cond1);
(void)pthread_cond_destroy(&cond2);
} }
VOID ItPosixPthread069(VOID) // IT_Layer_ModuleORFeature_No VOID ItPosixPthread069(VOID) // IT_Layer_ModuleORFeature_No
...@@ -69,4 +73,4 @@ VOID ItPosixPthread069(VOID) // IT_Layer_ModuleORFeature_No ...@@ -69,4 +73,4 @@ VOID ItPosixPthread069(VOID) // IT_Layer_ModuleORFeature_No
#if __cplusplus #if __cplusplus
} }
#endif /* __cpluscplus */ #endif /* __cpluscplus */
#endif /* __cpluscplus */ #endif /* __cpluscplus */
\ No newline at end of file
...@@ -48,8 +48,7 @@ static VOID *PthreadF01(void *argument) ...@@ -48,8 +48,7 @@ static VOID *PthreadF01(void *argument)
ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate); ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DEFERRED, oldstate, EXIT); ICUNIT_GOTO_EQUAL(oldstate, PTHREAD_CANCEL_DEFERRED, oldstate, EXIT);
LOS_TaskDelay(2); // 2, delay for Timing control. LOS_TaskDelay(4); // 4, delay for Timing control.
LOS_TaskDelay(2); // 2, delay for Timing control.
EXIT: EXIT:
return (void *)9; // 9, here set value about the return status. return (void *)9; // 9, here set value about the return status.
......
...@@ -56,8 +56,8 @@ static int Testcase(void) ...@@ -56,8 +56,8 @@ static int Testcase(void)
ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle); ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND); func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND);
ICUNIT_ASSERT_NOT_EQUAL(func, NULL, func); ICUNIT_GOTO_NOT_EQUAL(func, NULL, func, EXIT);
ICUNIT_ASSERT_EQUAL(func, SYMBOL_TO_MATCH, func); ICUNIT_GOTO_EQUAL(func, SYMBOL_TO_MATCH, func, EXIT);
ret = dlclose(handle); ret = dlclose(handle);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
...@@ -66,12 +66,16 @@ static int Testcase(void) ...@@ -66,12 +66,16 @@ static int Testcase(void)
ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle); ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND); func = (int (*)(int))dlsym(handle, SYMBOL_TO_FIND);
ICUNIT_ASSERT_NOT_EQUAL(func, NULL, func); ICUNIT_GOTO_NOT_EQUAL(func, NULL, func, EXIT);
ret = dlclose(handle); ret = dlclose(handle);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
return 0; return 0;
EXIT:
dlclose(handle);
return 0;
} }
void ItTestDynload002(void) void ItTestDynload002(void)
......
...@@ -42,6 +42,8 @@ static int TestCase(void) ...@@ -42,6 +42,8 @@ static int TestCase(void)
wchar_t *p, *pnew; wchar_t *p, *pnew;
pnew = (wchar_t*)malloc(sizeof(wchar_t) * (wcslen(res) + wcslen(res1))); pnew = (wchar_t*)malloc(sizeof(wchar_t) * (wcslen(res) + wcslen(res1)));
ICUNIT_ASSERT_NOT_EQUAL(pnew, NULL, pnew);
p = wmempcpy(pnew, res, wcslen(res)); p = wmempcpy(pnew, res, wcslen(res));
wmempcpy(p, res1, wcslen(res1)); wmempcpy(p, res1, wcslen(res1));
flag = wmemcmp(pnew, res2, wcslen(res)); flag = wmemcmp(pnew, res2, wcslen(res));
......
...@@ -44,21 +44,27 @@ static int testcase(void) ...@@ -44,21 +44,27 @@ static int testcase(void)
ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd); ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
writebuf = (char*)malloc(pageSize); writebuf = (char*)malloc(pageSize);
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf); ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
readbuf = (char*)malloc(pageSize); readbuf = (char*)malloc(pageSize);
ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf); ICUNIT_GOTO_NOT_EQUAL(readbuf, NULL, readbuf, EXIT);
(void)memset_s(writebuf, pageSize, 0xf, pageSize); (void)memset_s(writebuf, pageSize, 0xf, pageSize);
count = write(shmfd, writebuf, pageSize); count = write(shmfd, writebuf, pageSize);
ICUNIT_ASSERT_EQUAL(count, pageSize, count); ICUNIT_GOTO_EQUAL(count, pageSize, count, EXIT);
ret = lseek(shmfd, 0, SEEK_SET); ret = lseek(shmfd, 0, SEEK_SET);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
count = read(shmfd, readbuf, pageSize); count = read(shmfd, readbuf, pageSize);
ICUNIT_ASSERT_EQUAL(count, pageSize, count); ICUNIT_GOTO_EQUAL(count, pageSize, count, EXIT);
free(readbuf);
free(writebuf); EXIT:
if (readbuf != NULL) {
free(readbuf);
}
if (writebuf != NULL) {
free(writebuf);
}
close(shmfd); close(shmfd);
ret = shm_unlink("test_1"); ret = shm_unlink("test_1");
return 0; return 0;
......
...@@ -51,37 +51,6 @@ HWTEST_F(MemVmTest, ItTestMmap001, TestSize.Level0) ...@@ -51,37 +51,6 @@ HWTEST_F(MemVmTest, ItTestMmap001, TestSize.Level0)
{ {
ItTestMmap001(); ItTestMmap001();
} }
#if 0 // need tmpfs
/* *
* @tc.name: it_test_mmap_002
* @tc.desc: function for MemVmTest
* @tc.type: FUNC
*/
HWTEST_F(MemVmTest, ItTestMmap002, TestSize.Level0)
{
ItTestMmap002();
}
/* *
* @tc.name: it_test_mmap_003
* @tc.desc: function for MemVmTest
* @tc.type: FUNC
*/
HWTEST_F(MemVmTest, ItTestMmap003, TestSize.Level0)
{
ItTestMmap003();
}
/* *
* @tc.name: it_test_mmap_004
* @tc.desc: function for MemVmTest
* @tc.type: FUNC
*/
HWTEST_F(MemVmTest, ItTestMmap004, TestSize.Level0)
{
ItTestMmap004();
}
#endif
/* * /* *
* @tc.name: it_test_mmap_005 * @tc.name: it_test_mmap_005
......
...@@ -76,8 +76,10 @@ static int Testcase(void) ...@@ -76,8 +76,10 @@ static int Testcase(void)
(void)memset_s(buf, pageSize, 0xf, pageSize); (void)memset_s(buf, pageSize, 0xf, pageSize);
count = write(shmfd, buf, pageSize); count = write(shmfd, buf, pageSize);
ICUNIT_ASSERT_EQUAL(count, pageSize, count); if (count != pageSize) {
free(buf);
ICUNIT_ASSERT_EQUAL(count, pageSize, count);
}
free(buf); free(buf);
/* Simple MAP_ANONYMOUS */ /* Simple MAP_ANONYMOUS */
......
...@@ -40,30 +40,4 @@ public: ...@@ -40,30 +40,4 @@ public:
static void SetUpTestCase(void) {} static void SetUpTestCase(void) {}
static void TearDownTestCase(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
*/
#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
*/
#if 0
HWTEST_F(IoTest, IPC_TEST_MKFIFOAT_002, TestSize.Level0)
{
IPC_TEST_MKFIFOAT_002();
}
#endif
#endif
} // namespace OHOS } // namespace OHOS
...@@ -56,11 +56,17 @@ static int TestMkfifo() ...@@ -56,11 +56,17 @@ static int TestMkfifo()
return -1; return -1;
} else if (pid == 0) { } else if (pid == 0) {
fd = open("/dev/fifo", O_WRONLY); fd = open("/dev/fifo", O_WRONLY);
if (fd < 0) {
return -1;
}
write(fd, sentence, sizeof(sentence) + 1); write(fd, sentence, sizeof(sentence) + 1);
close(fd); close(fd);
exit(0); exit(0);
} else { } else {
fd = open("/dev/fifo", O_RDONLY); fd = open("/dev/fifo", O_RDONLY);
if (fd < 0) {
return -1;
}
read(fd, buffer, sizeof(buffer)); read(fd, buffer, sizeof(buffer));
printf("Receive data: %s\n", buffer); printf("Receive data: %s\n", buffer);
close(fd); close(fd);
......
...@@ -60,6 +60,8 @@ static UINT32 Testcase(VOID) ...@@ -60,6 +60,8 @@ static UINT32 Testcase(VOID)
fclose(testFile); fclose(testFile);
testFile = fopen(pathname, "r"); testFile = fopen(pathname, "r");
ICUNIT_GOTO_NOT_EQUAL(testFile, NULL, testFile, EXIT);
p = fgetws(tarStr, 16, testFile); // 16, read size,total write and '\0' p = fgetws(tarStr, 16, testFile); // 16, read size,total write and '\0'
nRet = wcscmp(L"hello world 666", tarStr); nRet = wcscmp(L"hello world 666", tarStr);
ICUNIT_GOTO_EQUAL(nRet, 0, nRet, EXIT); ICUNIT_GOTO_EQUAL(nRet, 0, nRet, EXIT);
......
...@@ -55,6 +55,10 @@ static UINT32 testcase(VOID) ...@@ -55,6 +55,10 @@ static UINT32 testcase(VOID)
} }
mnt_new = (struct mntent *)malloc(sizeof(struct mntent)); mnt_new = (struct mntent *)malloc(sizeof(struct mntent));
if (mnt_new == NULL) {
(VOID)RecoveryFileEnv(pathList, 1);
return LOS_NOK;
}
mnt_new->mnt_fsname = "UUID=c4992556-a86e-45e8-ba5f-190b16a9073x"; mnt_new->mnt_fsname = "UUID=c4992556-a86e-45e8-ba5f-190b16a9073x";
mnt_new->mnt_dir = "/usr1"; mnt_new->mnt_dir = "/usr1";
mnt_new->mnt_type = "ext3"; mnt_new->mnt_type = "ext3";
......
...@@ -55,6 +55,8 @@ static UINT32 Testcase(VOID) ...@@ -55,6 +55,8 @@ static UINT32 Testcase(VOID)
fclose(putwcFile); fclose(putwcFile);
putwcFile = fopen(pathname, "r"); putwcFile = fopen(pathname, "r");
ICUNIT_GOTO_NOT_EQUAL(putwcFile, NULL, putwcFile, EXIT);
tarWc = getwc(putwcFile); tarWc = getwc(putwcFile);
ICUNIT_GOTO_EQUAL(tarWc, L'H', tarWc, EXIT); ICUNIT_GOTO_EQUAL(tarWc, L'H', tarWc, EXIT);
......
...@@ -44,8 +44,6 @@ static UINT32 Testcase(VOID) ...@@ -44,8 +44,6 @@ static UINT32 Testcase(VOID)
ICUNIT_GOTO_EQUAL(ret, MQUEUE_IS_ERROR, ret, EXIT1); ICUNIT_GOTO_EQUAL(ret, MQUEUE_IS_ERROR, ret, EXIT1);
ICUNIT_GOTO_EQUAL(ret, MQUEUE_IS_ERROR, ret, EXIT1);
ret = mq_close(mqueue); ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1); ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT1);
......
...@@ -43,7 +43,6 @@ static VOID *pthread_f02(void *argument) ...@@ -43,7 +43,6 @@ static VOID *pthread_f02(void *argument)
ret = pthread_getschedparam(pthread_self(), &policy, &param); ret = pthread_getschedparam(pthread_self(), &policy, &param);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT); // ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT); //
ICUNIT_GOTO_EQUAL(param.sched_priority, 3, param.sched_priority, EXIT); ICUNIT_GOTO_EQUAL(param.sched_priority, 3, param.sched_priority, EXIT);
...@@ -63,7 +62,6 @@ static VOID *pthread_f01(void *argument) ...@@ -63,7 +62,6 @@ static VOID *pthread_f01(void *argument)
ret = pthread_getschedparam(pthread_self(), &policy, &param); ret = pthread_getschedparam(pthread_self(), &policy, &param);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT); // ICUNIT_GOTO_EQUAL(policy, SCHED_RR, policy, EXIT); //
ICUNIT_GOTO_EQUAL(param.sched_priority, 4, param.sched_priority, EXIT); ICUNIT_GOTO_EQUAL(param.sched_priority, 4, param.sched_priority, EXIT);
......
...@@ -43,7 +43,7 @@ static UINT32 TestCase(VOID) ...@@ -43,7 +43,7 @@ static UINT32 TestCase(VOID)
ICUNIT_GOTO_NOT_EQUAL(p, NULL, p, EXIT); ICUNIT_GOTO_NOT_EQUAL(p, NULL, p, EXIT);
x = drand48(); x = drand48();
printf("x= %d\n", x); printf("x= %lf\n", x);
return 0; return 0;
EXIT: EXIT:
......
...@@ -42,18 +42,6 @@ static void sig_alarm(int signum) ...@@ -42,18 +42,6 @@ static void sig_alarm(int signum)
static UINT32 TestCase(VOID) static UINT32 TestCase(VOID)
{ {
#if 0
int alarm_time = 1;
int ret;
signal(SIGALRM, sig_alarm);
alarm(alarm_time);
ret = sigsetjmp(jmp_env, 1);
if (ret) {
ICUNIT_ASSERT_EQUAL(ret, val, ret);
}
sleep(3);
#endif
return 0; return 0;
} }
......
...@@ -48,6 +48,9 @@ static UINT32 TestCase(VOID) ...@@ -48,6 +48,9 @@ static UINT32 TestCase(VOID)
NULL NULL
}; };
CHAR *buf = (char *)malloc(TEST_BUF_SIZE); CHAR *buf = (char *)malloc(TEST_BUF_SIZE);
if (buf == NULL) {
return -1;
}
CHAR *a = TEST_STR; CHAR *a = TEST_STR;
CHAR *value = NULL; CHAR *value = NULL;
CHAR *subopts = NULL; CHAR *subopts = NULL;
......
...@@ -87,11 +87,13 @@ static UINT32 TestCase(VOID) ...@@ -87,11 +87,13 @@ static UINT32 TestCase(VOID)
ptr = (int *)Xmalloc(sizeof(int)); ptr = (int *)Xmalloc(sizeof(int));
*ptr = rand() & 0xff; *ptr = rand() & 0xff;
val = tsearch((void *)ptr, &g_root, Compare); val = tsearch((void *)ptr, &g_root, Compare);
if (val == NULL) if (val == NULL) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
else if ((*(int **)val) != ptr) } else if ((*(int **)val) != ptr) {
free(ptr); free(ptr);
}
} }
twalk(g_root, Action); twalk(g_root, Action);
tdestroy(g_root, free); tdestroy(g_root, free);
......
...@@ -83,7 +83,7 @@ static int SampleTcpServer() ...@@ -83,7 +83,7 @@ static int SampleTcpServer()
ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, sfd); ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, sfd);
/* send */ /* send */
ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
gBuf[BUF_SIZE - 1] = '\0'; gBuf[BUF_SIZE - 1] = '\0';
ret = strcpy_s(gBuf, BUF_SIZE - 1, SRV_MSG); ret = strcpy_s(gBuf, BUF_SIZE - 1, SRV_MSG);
...@@ -94,7 +94,7 @@ static int SampleTcpServer() ...@@ -94,7 +94,7 @@ static int SampleTcpServer()
ICUNIT_ASSERT_EQUAL(ret, strlen(SRV_MSG), ret); ICUNIT_ASSERT_EQUAL(ret, strlen(SRV_MSG), ret);
/* recv */ /* recv */
ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
gBuf[BUF_SIZE - 1] = '\0'; gBuf[BUF_SIZE - 1] = '\0';
ret = recv(sfd, gBuf, sizeof(gBuf), 0); ret = recv(sfd, gBuf, sizeof(gBuf), 0);
...@@ -107,7 +107,7 @@ static int SampleTcpServer() ...@@ -107,7 +107,7 @@ static int SampleTcpServer()
clnAddr.sin_family = AF_INET; clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(PEER_IP); clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
clnAddr.sin_port = htons(PEER_PORT); clnAddr.sin_port = htons(PEER_PORT);
ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
gBuf[BUF_SIZE - 1] = '\0'; gBuf[BUF_SIZE - 1] = '\0';
ret = strcpy_s(gBuf, BUF_SIZE - 1, SRV_MSG); ret = strcpy_s(gBuf, BUF_SIZE - 1, SRV_MSG);
...@@ -128,7 +128,7 @@ static int SampleTcpServer() ...@@ -128,7 +128,7 @@ static int SampleTcpServer()
Wait(); Wait();
/* recvmsg */ /* recvmsg */
ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
gBuf[BUF_SIZE - 1] = '\0'; gBuf[BUF_SIZE - 1] = '\0';
ret = memset_s(&msg, sizeof(msg), 0, sizeof(msg)); ret = memset_s(&msg, sizeof(msg), 0, sizeof(msg));
...@@ -196,7 +196,7 @@ static int SampleTcpClient() ...@@ -196,7 +196,7 @@ static int SampleTcpClient()
inet_addr(STACK_IP), ((struct sockaddr_in*)&addr)->sin_addr.s_addr); inet_addr(STACK_IP), ((struct sockaddr_in*)&addr)->sin_addr.s_addr);
/* send */ /* send */
ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
gBuf[BUF_SIZE - 1] = '\0'; gBuf[BUF_SIZE - 1] = '\0';
ret = strcpy_s(gBuf, BUF_SIZE - 1, CLI_MSG); ret = strcpy_s(gBuf, BUF_SIZE - 1, CLI_MSG);
...@@ -207,7 +207,7 @@ static int SampleTcpClient() ...@@ -207,7 +207,7 @@ static int SampleTcpClient()
ICUNIT_ASSERT_EQUAL(ret, strlen(CLI_MSG), ret); ICUNIT_ASSERT_EQUAL(ret, strlen(CLI_MSG), ret);
/* recv */ /* recv */
ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
gBuf[BUF_SIZE - 1] = '\0'; gBuf[BUF_SIZE - 1] = '\0';
ret = recv(sfd, gBuf, sizeof(gBuf), 0); ret = recv(sfd, gBuf, sizeof(gBuf), 0);
...@@ -220,7 +220,7 @@ static int SampleTcpClient() ...@@ -220,7 +220,7 @@ static int SampleTcpClient()
clnAddr.sin_family = AF_INET; clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(PEER_IP); clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
clnAddr.sin_port = htons(PEER_PORT); clnAddr.sin_port = htons(PEER_PORT);
ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
gBuf[BUF_SIZE - 1] = '\0'; gBuf[BUF_SIZE - 1] = '\0';
ret = strcpy_s(gBuf, BUF_SIZE - 1, CLI_MSG); ret = strcpy_s(gBuf, BUF_SIZE - 1, CLI_MSG);
...@@ -241,7 +241,7 @@ static int SampleTcpClient() ...@@ -241,7 +241,7 @@ static int SampleTcpClient()
Wait(); Wait();
/* recvmsg */ /* recvmsg */
ret = memset_s(gBuf, BUF_SIZE - 1, 0, BUF_SIZE - 1); ret = memset_s(gBuf, BUF_SIZE + 1, 0, BUF_SIZE + 1);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
gBuf[BUF_SIZE - 1] = '\0'; gBuf[BUF_SIZE - 1] = '\0';
ret = memset_s(&msg, sizeof(msg), 0, sizeof(msg)); ret = memset_s(&msg, sizeof(msg), 0, sizeof(msg));
......
...@@ -139,13 +139,17 @@ static int TcpTest() ...@@ -139,13 +139,17 @@ static int TcpTest()
} else { } else {
printf("malloc 20M success\n"); printf("malloc 20M success\n");
ret = memset_s(buf, bufSiz, 0, bufSiz); ret = memset_s(buf, bufSiz, 0, bufSiz);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = send(lsfd, buf, bufSiz, 0); ret = send(lsfd, buf, bufSiz, 0);
printf("send ret = %d, errno :%d\n", ret, errno); printf("send ret = %d, errno :%d\n", ret, errno);
ICUNIT_ASSERT_EQUAL(ret, -1, ret); ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT);
} }
#endif
EXIT:
if (buf != NULL) {
free(buf);
}
#endif
close(lsfd); close(lsfd);
return 0; return 0;
} }
......
...@@ -149,6 +149,9 @@ static int TestSpawnAttr(short flag) ...@@ -149,6 +149,9 @@ static int TestSpawnAttr(short flag)
ICUNIT_GOTO_EQUAL(status, 0, status, EXIT); ICUNIT_GOTO_EQUAL(status, 0, status, EXIT);
fd = open("/storage/testspawnattr.txt", O_RDWR | O_CREAT, 0644); // 0644, open config fd = open("/storage/testspawnattr.txt", O_RDWR | O_CREAT, 0644); // 0644, open config
if (fd < 0) {
goto EXIT;
}
ret = read(fd, temp, NUMMAX); ret = read(fd, temp, NUMMAX);
ICUNIT_GOTO_EQUAL(ret, NUMMAX, ret, EXIT1); ICUNIT_GOTO_EQUAL(ret, NUMMAX, ret, EXIT1);
......
...@@ -51,7 +51,6 @@ static int Testcase(void) ...@@ -51,7 +51,6 @@ static int Testcase(void)
CPU_SET(1, &cpuset); /* cpu1 unsupported operation */ CPU_SET(1, &cpuset); /* cpu1 unsupported operation */
ret = sched_setaffinity(getpid(), sizeof(cpu_set_t), &cpuset); ret = sched_setaffinity(getpid(), sizeof(cpu_set_t), &cpuset);
ICUNIT_GOTO_EQUAL(ret, -1, ret, ERROR_OUT); ICUNIT_GOTO_EQUAL(ret, -1, ret, ERROR_OUT);
CPU_ZERO(&cpuset);
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
CPU_SET(0, &cpuset); /* cpu0 */ CPU_SET(0, &cpuset); /* cpu0 */
......
...@@ -55,7 +55,14 @@ static void ChildFunc() ...@@ -55,7 +55,14 @@ static void ChildFunc()
ent.sigev_signo = SIGUSR1; ent.sigev_signo = SIGUSR1;
tid2 = (timer_t *)malloc(sizeof(UINTPTR) * 1024); tid2 = (timer_t *)malloc(sizeof(UINTPTR) * 1024);
if (tid2 == NULL) {
return;
}
ret1 = (int *)malloc(sizeof(int) * 1024); ret1 = (int *)malloc(sizeof(int) * 1024);
if (ret1 == NULL) {
free(tid2);
return;
}
(void)memset_s(tid2, sizeof(char *) * 1024, 0, sizeof(char *) * 1024); (void)memset_s(tid2, sizeof(char *) * 1024, 0, sizeof(char *) * 1024);
(void)memset_s(ret1, sizeof(int) * 1024, 0xff, sizeof(int) * 1024); (void)memset_s(ret1, sizeof(int) * 1024, 0xff, sizeof(int) * 1024);
while (i < 1024) { while (i < 1024) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册