Commit f5cd8bfd authored by Ruslan Kuprieiev's avatar Ruslan Kuprieiev Committed by Pavel Emelyanov

test: rpc: restore

Signed-off-by: 's avatarRuslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ba196e63
#!/bin/bash
while :; do
sleep 1
done
#!/usr/bin/python
import socket, os, imp, sys
p = os.getcwd()
sys.path.append(p)
import rpc_pb2 as rpc
# Connect to service socket
s = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET)
s.connect('criu_service.socket')
# Create criu msg, set it's type to dump request
# and set dump options. Checkout more options in protobuf/rpc.proto
req = rpc.criu_req()
req.type = rpc.RESTORE
req.opts.images_dir_fd = os.open('imgs_loop', os.O_DIRECTORY)
# Send request
s.send(req.SerializeToString())
# Recv response
resp = rpc.criu_resp()
MAX_MSG_SIZE = 1024
resp.ParseFromString(s.recv(MAX_MSG_SIZE))
if resp.type != rpc.RESTORE:
print 'Unexpected msg type'
sys.exit(-1)
else:
if resp.success:
print 'Restore success'
else:
print 'Restore fail'
sys.exit(-1)
print "PID of the restored program is %d\n" %(resp.restore.pid)
...@@ -24,6 +24,12 @@ function _exit { ...@@ -24,6 +24,12 @@ function _exit {
exit $1 exit $1
} }
function check_and_term {
title_print "Check and term $1"
ps -C $1
pkill $1
}
title_print "Build programs" title_print "Build programs"
make clean make clean
mkdir build mkdir build
...@@ -45,4 +51,17 @@ ${CRIU} restore -v4 -o restore-c.log -D imgs_c --shell-job || _exit $? ...@@ -45,4 +51,17 @@ ${CRIU} restore -v4 -o restore-c.log -D imgs_c --shell-job || _exit $?
title_print "Restore test-py" title_print "Restore test-py"
${CRIU} restore -v4 -o restore-py.log -D imgs_py --shell-job || _exit $? ${CRIU} restore -v4 -o restore-py.log -D imgs_py --shell-job || _exit $?
title_print "Run loop.sh"
setsid ../loop.sh < /dev/null &> loop.log &
P=${!}
echo "pid ${P}"
title_print "Dump loop.sh"
mkdir imgs_loop
${CRIU} dump -v4 -o dump-loop.log -D imgs_loop -t ${P} || _exit $?
title_print "Run restore-loop"
../restore-loop.py || _exit $?
kill -SIGTERM ${P}
_exit 0 _exit 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