提交 455e42e5 编写于 作者: V vcbchang

test: 修复了杀死掉hilog进程后SecurityCapability门禁用例无法通过的问题

【背景】如果操作系统先执行kill hilog进程,然后再执行SecurityCapability,那么门禁用例将无法通过,原因是该用例先获取了hilog进程的id,但hilog进程已经杀掉了,所以报错

【修改方案】
1. 增加kill 0与错误码判断,如果发现进程已经被干掉的话将不执行相关内容

【影响】
无其它影响。
Signed-off-by: Nvcbchang <vcbchang@qq.com>
Change-Id: Icdf357800175eff19acf1f92426469642a697386
上级 43bdf2f1
......@@ -82,22 +82,38 @@ static int TestChild(VOID)
capheader.pid = INVAILD_PID;
ret = capget(&capheader, &capdatac[0]);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
errno = 0;
capheader.pid = 3;
ret = capget(&capheader, &capdatac[0]);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
printf("e %d,p %d\n", capdatac[0].effective, capdatac[0].permitted);
kill(capheader.pid, 0);
if (errno != ESRCH) {
ret = capget(&capheader, &capdatac[0]);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
printf("e %d,p %d\n", capdatac[0].effective, capdatac[0].permitted);
}
errno = 0;
capheader.pid = 4;
ret = capget(&capheader, &capdatac[0]);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
printf("e %d,p %d\n", capdatac[0].effective, capdatac[0].permitted);
kill(capheader.pid, 0);
if (errno != ESRCH) {
ret = capget(&capheader, &capdatac[0]);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
printf("e %d,p %d\n", capdatac[0].effective, capdatac[0].permitted);
}
errno = 0;
capheader.pid = 5;
ret = capget(&capheader, &capdatac[0]);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
printf("e %d,p %d\n", capdatac[0].effective, capdatac[0].permitted);
kill(capheader.pid, 0);
if (errno != ESRCH) {
ret = capget(&capheader, &capdatac[0]);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
printf("e %d,p %d\n", capdatac[0].effective, capdatac[0].permitted);
}
errno = 0;
capheader.pid = 6;
ret = capget(&capheader, &capdatac[0]);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
printf("e %d,p %d\n", capdatac[0].effective, capdatac[0].permitted);
kill(capheader.pid, 0);
if (errno != ESRCH) {
ret = capget(&capheader, &capdatac[0]);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
printf("e %d,p %d\n", capdatac[0].effective, capdatac[0].permitted);
}
capheader.pid = 0;
int pid = fork();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册