test: 修复了杀死掉hilog进程后SecurityCapability门禁用例无法通过的问题
【背景】如果操作系统先执行kill hilog进程,然后再执行SecurityCapability,那么门禁用例将无法通过,原因是该用例先获取了hilog进程的id,但hilog进程已经杀掉了,所以报错 【修改方案】 1. 增加kill 0与错误码判断,如果发现进程已经被干掉的话将不执行相关内容 【影响】 无其它影响。 Signed-off-by: vcbchang <vcbchang@qq.com> Change-Id: Icdf357800175eff19acf1f92426469642a697386
This commit is contained in:
parent
43bdf2f1d3
commit
455e42e5b9
|
@ -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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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();
|
||||
|
|
Loading…
Reference in New Issue