mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 23:05:39 +00:00
zdtm: Convert caps00 test to use task_waiters
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Acked-by: Andrey Vagin <avagin@parallels.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
8d7a55ed74
commit
486da8827e
@@ -29,25 +29,24 @@ int capset(struct cap_hdr *hdrp, const struct cap_data *datap);
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int pid, s_p[2], f_p[2], r_p[3];
|
task_waiter_t t;
|
||||||
|
int pid, result_pipe[2];
|
||||||
char res = 'x';
|
char res = 'x';
|
||||||
|
|
||||||
test_init(argc, argv);
|
test_init(argc, argv);
|
||||||
|
task_waiter_init(&t);
|
||||||
|
|
||||||
pipe(s_p);
|
if (pipe(result_pipe)) {
|
||||||
pipe(f_p);
|
err("Can't create pipe\n");
|
||||||
pipe(r_p);
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
pid = fork();
|
pid = test_fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
struct cap_hdr hdr;
|
struct cap_hdr hdr;
|
||||||
struct cap_data data[_LINUX_CAPABILITY_U32S_3];
|
struct cap_data data[_LINUX_CAPABILITY_U32S_3];
|
||||||
struct cap_data data_2[_LINUX_CAPABILITY_U32S_3];
|
struct cap_data data_2[_LINUX_CAPABILITY_U32S_3];
|
||||||
|
|
||||||
close(s_p[0]);
|
|
||||||
close(f_p[1]);
|
|
||||||
close(r_p[0]);
|
|
||||||
|
|
||||||
hdr.version = _LINUX_CAPABILITY_VERSION_3;
|
hdr.version = _LINUX_CAPABILITY_VERSION_3;
|
||||||
hdr.pid = 0;
|
hdr.pid = 0;
|
||||||
|
|
||||||
@@ -61,10 +60,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
capset(&hdr, data);
|
capset(&hdr, data);
|
||||||
|
|
||||||
close(s_p[1]);
|
task_waiter_complete_current(&t);
|
||||||
|
task_waiter_wait4(&t, getppid());
|
||||||
read(f_p[0], &res, 1);
|
|
||||||
close(f_p[0]);
|
|
||||||
|
|
||||||
hdr.version = _LINUX_CAPABILITY_VERSION_3;
|
hdr.version = _LINUX_CAPABILITY_VERSION_3;
|
||||||
hdr.pid = 0;
|
hdr.pid = 0;
|
||||||
@@ -98,24 +95,23 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
res = '0';
|
res = '0';
|
||||||
bad:
|
bad:
|
||||||
write(r_p[1], &res, 1);
|
write(result_pipe[1], &res, 1);
|
||||||
close(r_p[1]);
|
close(result_pipe[0]);
|
||||||
|
close(result_pipe[1]);
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(f_p[0]);
|
task_waiter_wait4(&t, pid);
|
||||||
close(s_p[1]);
|
|
||||||
close(r_p[1]);
|
|
||||||
|
|
||||||
read(s_p[0], &res, 1);
|
|
||||||
close(s_p[0]);
|
|
||||||
|
|
||||||
test_daemon();
|
test_daemon();
|
||||||
test_waitsig();
|
test_waitsig();
|
||||||
|
|
||||||
close(f_p[1]);
|
task_waiter_complete_current(&t);
|
||||||
|
|
||||||
|
read(result_pipe[0], &res, 1);
|
||||||
|
close(result_pipe[0]);
|
||||||
|
close(result_pipe[1]);
|
||||||
|
|
||||||
read(r_p[0], &res, 1);
|
|
||||||
if (res == '0')
|
if (res == '0')
|
||||||
pass();
|
pass();
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user