fix:修复函数返回错误等问题

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
This commit is contained in:
zhangdengyu
2022-09-24 17:04:38 +08:00
parent 453c376198
commit 043e84dfcb
34 changed files with 82 additions and 79 deletions

View File

@@ -33,12 +33,10 @@
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);
}
@@ -54,7 +52,6 @@ static int TestCase(void)
pid = fork();
ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
if (pid == 0) {
*test = 0x1;
exit(0);
}

View File

@@ -35,19 +35,15 @@
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);
@@ -56,7 +52,6 @@ static int TestThread(void)
static int TestCase(void)
{
int *test = nullptr;
int count = 5;
int status = 0;
int ret;

View File

@@ -59,7 +59,7 @@ static int TestMkfifo()
if (fd < 0) {
return -1;
}
write(fd, sentence, sizeof(sentence) + 1);
write(fd, sentence, sizeof(sentence));
close(fd);
exit(0);
} else {

View File

@@ -45,7 +45,6 @@ static int TestMkfifoReturn()
int retValue, i;
int status = 0;
pid_t pid;
char pathname[NAME_BUF_SIZE];
retValue = mkfifo("/dev/fifo0", 0777); // 0777, mkfifo config.
ICUNIT_ASSERT_EQUAL(retValue, 0, retValue);
@@ -57,7 +56,6 @@ static int TestMkfifoReturn()
unlink("/dev/fifo0/fifo1");
unlink("/dev/usr/fifo0");
rmdir("/dev/usr");
unlink(pathname);
unlink("/dev/fifo0");
return LOS_OK;
@@ -66,7 +64,6 @@ EXIT:
unlink("/dev/fifo0/fifo1");
unlink("/dev/usr/fifo0");
rmdir("/dev/usr");
unlink(pathname);
unlink("/dev/fifo0");
return LOS_NOK;
}

View File

@@ -54,7 +54,7 @@ static UINT32 testcase(VOID)
UINT32 ret;
retval = pipe(pipeFd);
ICUNIT_GOTO_EQUAL(retval, 0, retval, OUT);
ICUNIT_GOTO_EQUAL(retval, 0, retval, OUT4);
/* Watch fd to see when it has input. */
FD_ZERO(&rfds);
@@ -62,11 +62,11 @@ static UINT32 testcase(VOID)
/* Wait up to three seconds. */
epFd = epoll_create1(100); /* 100, cretae input, */
ICUNIT_GOTO_NOT_EQUAL(epFd, -1, epFd, OUT);
ICUNIT_GOTO_NOT_EQUAL(epFd, -1, epFd, OUT2);
ev.events = EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM;
retval = epoll_ctl(epFd, EPOLL_CTL_ADD, pipeFd[0], &ev);
ICUNIT_GOTO_NOT_EQUAL(retval, -1, retval, OUT);
ICUNIT_GOTO_NOT_EQUAL(retval, -1, retval, OUT1);
pid = fork();
if (pid == 0) {
@@ -86,7 +86,7 @@ static UINT32 testcase(VOID)
sleep(1);
close(pipeFd[0]);
retval = write(pipeFd[1], "0123456789012345678901234567890123456789", 40); /* write 40 bytes to stdin(fd 0) */
ICUNIT_GOTO_EQUAL(retval, 40, retval, OUT);
ICUNIT_GOTO_EQUAL(retval, 40, retval, OUT3);
close(pipeFd[1]);
wait(&status);
@@ -95,10 +95,20 @@ static UINT32 testcase(VOID)
}
return LOS_OK;
OUT:
OUT1:
close(epFd);
close(pipeFd[0]);
close(pipeFd[1]);
return LOS_NOK;
OUT2:
close(pipeFd[0]);
close(pipeFd[1]);
return LOS_NOK;
OUT3:
close(epFd);
close(pipeFd[1]);
return LOS_NOK;
OUT4:
return LOS_NOK;
}

View File

@@ -53,7 +53,7 @@ static UINT32 testcase(VOID)
int i = 0;
int status;
int epFd;
int epFd = 0;
sigset_t mask;
void (*retSig)(int);
struct epoll_event ev;
@@ -75,7 +75,7 @@ static UINT32 testcase(VOID)
ICUNIT_ASSERT_EQUAL(retval, 0, retval);
retval = pipe(pipeFd);
ICUNIT_GOTO_EQUAL(retval, 0, retval, OUT);
ICUNIT_GOTO_EQUAL(retval, 0, retval, OUT3);
/* Watch fd to see when it has input. */
FD_ZERO(&rfds);
@@ -86,12 +86,12 @@ static UINT32 testcase(VOID)
tv.tv_nsec = 5; /* 5, wait timer, nano second */
epFd = epoll_create1(100); /* 100, cretae input, */
ICUNIT_GOTO_NOT_EQUAL(epFd, -1, epFd, OUT);
ICUNIT_GOTO_NOT_EQUAL(epFd, -1, epFd, OUT2);
ev.events = EPOLLRDNORM;
retval = epoll_ctl(epFd, EPOLL_CTL_ADD, pipeFd[0], &ev);
ICUNIT_GOTO_NOT_EQUAL(retval, -1, retval, OUT);
ICUNIT_GOTO_NOT_EQUAL(retval, -1, retval, OUT1);
pid = fork();
if (pid == 0) {
@@ -125,10 +125,12 @@ static UINT32 testcase(VOID)
}
return LOS_OK;
OUT:
OUT1:
close(epFd);
OUT2:
close(pipeFd[0]);
close(pipeFd[1]);
close(epFd);
OUT3:
return LOS_NOK;
}

View File

@@ -36,7 +36,7 @@ static int Testcase()
#define CURRENT_PROCESS_POLICY SCHED_RR
struct sched_param param = { 0 };
int ret;
int ret = OS_ERROR;
int currProcessPri = getpriority(PRIO_PROCESS, getpid());
ICUNIT_GOTO_WITHIN_EQUAL(currProcessPri, 0, 31, currProcessPri, ERROR_OUT); // 31, assert function Result equal to this.

View File

@@ -35,7 +35,7 @@ static int TestCase()
{
#define PROCESS_TEST_PRI1 (currProcessPri + 1)
struct sched_param param = { 0 };
int ret;
int ret = OS_ERROR;
int val, currPolicy;
int currProcessPri = getpriority(PRIO_PROCESS, getpid());
ICUNIT_GOTO_WITHIN_EQUAL(currProcessPri, 0, 31, currProcessPri, ERROR_OUT); // 31, assert currProcessPri equal to this.