提交 5bf5eeeb 编写于 作者: O openharmony_ci 提交者: Gitee

!121 Resolve failed test cases:ActsIpcPipeTest:PipeTest.cpp

Merge pull request !121 from jiyong/master
...@@ -68,7 +68,7 @@ HWTEST_F(PipeTest, testHelloWorld, Function | MediumTest | Level0) ...@@ -68,7 +68,7 @@ HWTEST_F(PipeTest, testHelloWorld, Function | MediumTest | Level0)
close(fd[1]); close(fd[1]);
Msleep(100); Msleep(100);
AssertProcExitedOK(pid); WaitProcExitedOK(pid);
} }
/** /**
...@@ -81,7 +81,7 @@ HWTEST_F(PipeTest, tesPipeNonblack, Function | MediumTest | Level1) ...@@ -81,7 +81,7 @@ HWTEST_F(PipeTest, tesPipeNonblack, Function | MediumTest | Level1)
int fd[2]; int fd[2];
int ret = pipe(fd); int ret = pipe(fd);
ASSERT_EQ(ret, 0) << "> parent: pipe error ret = %d" << ret; ASSERT_EQ(ret, 0) << "> parent: pipe error ret = %d" << ret;
printf("fd %d, %d\n", fd[0], fd[1]);
pid_t pid = fork(); pid_t pid = fork();
ASSERT_TRUE(pid >= 0) << "> parent: fork errno = " << errno; ASSERT_TRUE(pid >= 0) << "> parent: fork errno = " << errno;
if (pid == 0) { // child --- O_NONBLOCK R test, should be failed if (pid == 0) { // child --- O_NONBLOCK R test, should be failed
...@@ -98,17 +98,17 @@ HWTEST_F(PipeTest, tesPipeNonblack, Function | MediumTest | Level1) ...@@ -98,17 +98,17 @@ HWTEST_F(PipeTest, tesPipeNonblack, Function | MediumTest | Level1)
} }
Msleep(100); Msleep(100);
close(fd[0]); close(fd[0]);
printf("1234 \n");
exit(0); exit(0);
} }
// parent --- use O_NONBLOCK W test // parent --- use O_NONBLOCK W test
close(fd[0]); close(fd[0]);
Msleep(50); Msleep(50);
ret = write(fd[1], "O_NONBLOCK R test", sizeof("O_NONBLOCK R test"));
ASSERT_NE(ret, -1) << "> parent : O_NONBLOCK write error";
close(fd[1]); close(fd[1]);
Msleep(150); Msleep(150);
AssertProcExitedOK(pid); WaitProcExitedOK(pid);
printf("5678 \n");
} }
/** /**
...@@ -123,9 +123,10 @@ HWTEST_F(PipeTest, testPipeBuf, Function | MediumTest | Level3) ...@@ -123,9 +123,10 @@ HWTEST_F(PipeTest, testPipeBuf, Function | MediumTest | Level3)
int tmpInt; int tmpInt;
char testBuffer[arrSize]; char testBuffer[arrSize];
memset_s(testBuffer, sizeof(testBuffer), '1', sizeof(testBuffer)); memset_s(testBuffer, sizeof(testBuffer), '1', sizeof(testBuffer));
printf("abcd \n");
tmpInt = pipe(fd); tmpInt = pipe(fd);
ASSERT_EQ(tmpInt, 0) << "> parent: Create Pipe Error! "; ASSERT_EQ(tmpInt, 0) << "> parent: Create Pipe Error! ";
printf("fd %d, %d\n", fd[0], fd[1]);
pid_t pid = fork(); pid_t pid = fork();
ASSERT_TRUE(pid >= 0) << "> parent: error : fork"; ASSERT_TRUE(pid >= 0) << "> parent: error : fork";
...@@ -159,13 +160,14 @@ HWTEST_F(PipeTest, testPipeBuf, Function | MediumTest | Level3) ...@@ -159,13 +160,14 @@ HWTEST_F(PipeTest, testPipeBuf, Function | MediumTest | Level3)
Msleep(30); Msleep(30);
EXPECT_NE(fcntl(fd[1], F_SETFL, O_NONBLOCK), -1) << "> fcntl errno = " << errno; EXPECT_NE(fcntl(fd[1], F_SETFL, O_NONBLOCK), -1) << "> fcntl errno = " << errno;
printf("efg \n");
tmpInt = write(fd[1], writeBuffer, arrSize); tmpInt = write(fd[1], writeBuffer, arrSize);
LOG("> parent: write num = %d", tmpInt); LOG("> parent: write num = %d", tmpInt);
EXPECT_NE(tmpInt, -1) << "> parent: error : write num = "<< tmpInt; EXPECT_NE(tmpInt, -1) << "> parent: error : write num = "<< tmpInt;
close(fd[1]); close(fd[1]);
Msleep(100); Msleep(100);
AssertProcExitedOK(pid); WaitProcExitedOK(pid);
} }
/** /**
...@@ -218,7 +220,7 @@ HWTEST_F(PipeTest, testPipeBlock, Function | MediumTest | Level2) ...@@ -218,7 +220,7 @@ HWTEST_F(PipeTest, testPipeBlock, Function | MediumTest | Level2)
close(fd[1]); close(fd[1]);
Msleep(100); Msleep(100);
AssertProcExitedOK(pid); WaitProcExitedOK(pid);
} }
/** /**
...@@ -267,6 +269,6 @@ HWTEST_F(PipeTest, testBrotherHelloWorld, Function | MediumTest | Level1) ...@@ -267,6 +269,6 @@ HWTEST_F(PipeTest, testBrotherHelloWorld, Function | MediumTest | Level1)
close(fd[1]); close(fd[1]);
Msleep(100); Msleep(100);
AssertProcExitedOK(pidChild1); WaitProcExitedOK(pidChild1);
AssertProcExitedOK(pidChild2); WaitProcExitedOK(pidChild2);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册