fix:根据内源代码检视意见对用例进行整改

【背景】3.1代码review问题修改

    【修改方案】
     修复用例问题

     Signed-off-by: xuiny <xuxinyu6@huawei.com>

Change-Id: I8ee5d8f5f5765e469cf72c810af8a3831a3879f9
This commit is contained in:
x_xiny 2022-03-14 21:03:26 +08:00
parent 6a8f24ba01
commit 543732f522
2 changed files with 14 additions and 6 deletions

View File

@ -46,6 +46,7 @@ extern int g_iteration;
void ReallocFuzzTest(void)
{
char *source = NULL;
char *buf = NULL;
int c;
printf("Fuzz test in line [%d] realloc start\n", __LINE__);
@ -59,6 +60,7 @@ void ReallocFuzzTest(void)
INIT_FuzzEnvironment();
CreatPrecondForQueue();
for (int i = 0; i < CYCLE_TOTAL_TIMES; i++) {
source = buf;
hi_watchdog_feed();
heartbeatPrint(i);
@ -66,10 +68,13 @@ void ReallocFuzzTest(void)
if ((c <= 0) || (c > TEST_MAX_BUF_LEN)) {
c = TEST_BUF_LEN;
}
source = (char *)realloc(source, c);
buf = (char *)realloc(source, c);
if (buf == NULL) {
break;
}
}
if (source == NULL) {
if (buf == NULL) {
free(source);
}

View File

@ -270,19 +270,22 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc001, Function | MediumTest
memset(mem, testChar, mlen);
rlen = rand() % (1024) + mlen;
mem = realloc(mem, rlen);
TEST_ASSERT_NOT_NULL(mem);
char *mem1 = realloc(mem, rlen);
if (mem1 == NULL) {
free(mem);
}
TEST_ASSERT_NOT_NULL(mem1);
len = mlen <= rlen ? mlen : rlen;
data = (char *)mem;
data = (char *)mem1;
for (k = 0; k < len; k++) {
if (data[k] != testChar) {
failure = 1;
}
}
free(mem);
free(mem1);
TEST_ASSERT_EQUAL_INT(failure, 0);
}
};