Commit 7050ea2c authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Cyrill Gorcunov

zdtm: Static pstree test

I'm waiting for Andrey's

* pthread join fix
* infrastructure for fokring in zdtm

to extend it with threads.

Besides, we/me need to fix the seizing of dynamically forking tasks
to write a transition pstree test.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 6da51eee
...@@ -26,6 +26,7 @@ $ZP/transition/fork ...@@ -26,6 +26,7 @@ $ZP/transition/fork
$ZP/static/zombie00 $ZP/static/zombie00
$ZP/static/sockets00 $ZP/static/sockets00
$ZP/static/pid00 $ZP/static/pid00
$ZP/static/pstree
$ZP/static/caps00 $ZP/static/caps00
$ZP/static/cmdlinenv00 $ZP/static/cmdlinenv00
$ZP/static/socket_listen" $ZP/static/socket_listen"
......
...@@ -29,6 +29,7 @@ TST_NOFILE = \ ...@@ -29,6 +29,7 @@ TST_NOFILE = \
pthread00 \ pthread00 \
vdso00 \ vdso00 \
utsname \ utsname \
pstree \
sockets00 \ sockets00 \
ipc_namespace \ ipc_namespace \
# jobctl00 \ # jobctl00 \
......
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "zdtmtst.h"
const char *test_doc = "Check that environment didn't change";
const char *test_author = "Pavel Emelianov <xemul@parallels.com>";
int main(int argc, char **argv)
{
char x;
int pid, ppid;
int sp[2], fp[2], rp[2];
test_init(argc, argv);
pipe(sp);
pipe(fp);
pipe(rp);
pid = fork();
if (pid == 0) {
close(sp[0]);
close(fp[1]);
close(rp[0]);
pid = getpid();
ppid = getppid();
close(sp[1]);
read(fp[0], &x, 1);
close(fp[0]);
if (pid != getpid())
x = 'p';
else if (ppid != getppid())
x = 'P';
else
x = '0';
write(rp[1], &x, 1);
close(rp[1]);
_exit(0);
}
x = 'X';
close(sp[1]);
close(fp[0]);
close(rp[1]);
read(sp[1], &x, 1);
test_daemon();
test_waitsig();
close(fp[1]);
read(rp[0], &x, 1);
close(rp[0]);
if (x == 'X')
fail("Sync failed");
else if (x == 'p')
fail("Pid failed");
else if (x == 'P')
fail("PPid failed");
else if (x != '0')
fail("Shit happened");
else
pass();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment