提交 aa45db22 编写于 作者: N nanxiansen

fix failed testcase

Change-Id: I7dbdb8d0c1d3f819888d0d6dabe3b08b45f4e809
上级 21f2c4f9
......@@ -246,11 +246,11 @@ HWTEST_F(IoTest, testWmemset, Function | MediumTest | Level1)
HWTEST_F(IoTest, testWmemchr, Function | MediumTest | Level1)
{
wchar_t src[] = L"hello world";
wchar_t *ret = wmemchr(src, L' ', sizeof(src));
wchar_t *ret = wmemchr(src, L' ', sizeof(src) / sizeof(src[0]) - 1);
EXPECT_STREQ(ret, L" world");
wchar_t srcT[] = L"this is string";
ret = wmemchr(srcT, L'?', sizeof(srcT));
ret = wmemchr(srcT, L'?', sizeof(srcT) / sizeof(srcT[0]) - 1);
EXPECT_STREQ(ret, nullptr);
}
......
......@@ -67,8 +67,9 @@ HWTEST_F(PidTest, testOrphanProcess, Function | MediumTest | Level1)
ASSERT_NE(shmID, -1) << "get share mem fail, errno = " << errno;
int *shared = (int*)(shmat(shmID, nullptr, 0));
ASSERT_NE(shared, reinterpret_cast<int*>(-1)) << "shmat fail, errno = " << errno;
*shared = retPass;
shared[0] = retPass;
shared[1] = 0;
LOG("parent process id:%d", getpid());
pid_t pid = fork();
EXPECT_TRUE(pid >= 0) << "======== Fork Error! =========";
......@@ -77,22 +78,26 @@ HWTEST_F(PidTest, testOrphanProcess, Function | MediumTest | Level1)
pid_t pid2 = fork();
if (pid2 < 0) {
LOG("======== Fork Error! =========");
*shared = 1;
exit(1);
}
if (pid2 == 0) { // child
LOG("orphane process id:%d", getpid());
Msleep(100);
int *shmAddr = (int*)(shmat(shmID, nullptr, 0));
LOG("before while child child %d", shmAddr[1]);
while (shmAddr[1] != 1) {
Msleep(50);
}
LOG("after while child child %d", shmAddr[1]);
pid_t pPid = getppid();
if (pPid != 1) {
LOG("getppid orphaned process fail, expect:1, but get:%d", pPid);
// transfer result to main process
int *shmAddr = (int*)(shmat(shmID, nullptr, 0));
*shmAddr = retFail;
shmdt(shmAddr);
exit(0);
shmAddr[0] == retFail;
}
shmAddr[1] =2;
LOG("child child exit %d", shmAddr[1]);
shmdt(shmAddr);
exit(0);
} else { // sub parent
exit(0);
......@@ -100,8 +105,13 @@ HWTEST_F(PidTest, testOrphanProcess, Function | MediumTest | Level1)
}
// parent
WaitProcExitedOK(pid);
shared[1] = 1;
Msleep(200);
EXPECT_EQ(*shared, retPass);
EXPECT_EQ(shared[0], retPass);
LOG("before while paret %d", shared[1]);
while (shared[1] != 2) {
Msleep(50);
}
shmdt(shared);
shmctl(shmID, IPC_RMID, nullptr);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册