Commit 98cc46fc authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

test: add a new test to check external terminals

It's an example how it can be used
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent df0be41e
import subprocess
import pty
import os, sys, time
master, slave = pty.openpty()
p = subprocess.Popen(["setsid", "--ctty", "sleep", "10000"],
stdin = slave, stdout = slave, stderr = slave, close_fds = True)
st = os.stat("/proc/self/fd/%d" % slave)
ttyid = "tty[%x:%x]" % (st.st_rdev, st.st_dev)
os.close(slave)
time.sleep(1)
ret = subprocess.Popen(["../../criu", "dump", "-t", str(p.pid), "-v4", "--external", ttyid]).wait()
if ret:
sys.exit(ret)
p.wait()
new_master, slave = pty.openpty() # get another pty pair
os.close(master)
ttyid = "fd[%d]:tty[%x:%x]" % (slave, st.st_rdev, st.st_dev)
ret = subprocess.Popen(["../../criu", "restore", "-v4", "--inherit-fd", ttyid, "--restore-sibling", "--restore-detach"]).wait()
if ret:
sys.exit(ret)
os.close(slave)
os.waitpid(-1, os.WNOHANG) # is the process alive
os.close(new_master)
_, status = os.wait()
if not os.WIFSIGNALED(status) or not os.WTERMSIG(status):
print status
sys.exit(1)
print "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