Commit 87411d6d authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

test: app-emu -- job: Fix comparison and wait for restore complete by a signal

Since we're migrating session leader here, test for session has not
been changed instead.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 19de6865
......@@ -14,15 +14,27 @@
#include <dirent.h>
static int stop = 0;
void sighandler(int sig)
{
stop = 1;
}
int main(int argc, char *argv[])
{
int pid, gid, sid;
int tty_sid, tty_gid;
int fd = fileno(stdout);
char buf[32];
int c = 0;
struct dirent *de;
DIR *fd_dir;
sigset_t bmask, cmask;
if (signal(SIGTERM, sighandler)) {
printf("Unable to set a signal handler: %m\n");
return 1;
}
if (!isatty(fd)) {
printf("stdout is not tty\n");
......@@ -70,21 +82,19 @@ int main(int argc, char *argv[])
}
printf("stdout gid = %d\n", tty_gid);
sigemptyset(&cmask);
sigemptyset(&bmask);
sigaddset(&bmask, SIGTERM);
sigprocmask(SIG_SETMASK, &bmask, NULL);
printf("READY\n");
c = 0;
while (1) {
sleep(1);
if (c++ > 10) {
printf("Too long for restore\n");
exit(-1);
}
while (!stop)
sigsuspend(&cmask);
if (getsid(pid) != sid) {
printf("ALIVE\n");
break;
}
}
if (getsid(pid) == sid)
printf("ALIVE\n");
return 0;
}
......@@ -38,6 +38,12 @@ switch $current {
}
spawn ../../../crtools restore -v 4 -D ./dump -o restore.log -j -t $pid
#
# spawn doesn't wait for restore to complete, so
# add some sleep here. Still better would be to
# rewrite this test completely.
sleep 2
system kill -15 $pid
expect "ALIVE" {
puts "PASS"
......
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