From f5cd8bfdc3f27f095e5eb31801e26ee45f2a7925 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Wed, 2 Oct 2013 23:45:35 +0400 Subject: [PATCH] test: rpc: restore Signed-off-by: Ruslan Kuprieiev Signed-off-by: Pavel Emelyanov --- test/rpc/loop.sh | 4 ++++ test/rpc/restore-loop.py | 37 +++++++++++++++++++++++++++++++++++++ test/rpc/run.sh | 19 +++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100755 test/rpc/loop.sh create mode 100755 test/rpc/restore-loop.py diff --git a/test/rpc/loop.sh b/test/rpc/loop.sh new file mode 100755 index 000000000..0ab34ce96 --- /dev/null +++ b/test/rpc/loop.sh @@ -0,0 +1,4 @@ +#!/bin/bash +while :; do + sleep 1 +done diff --git a/test/rpc/restore-loop.py b/test/rpc/restore-loop.py new file mode 100755 index 000000000..bf91cb56a --- /dev/null +++ b/test/rpc/restore-loop.py @@ -0,0 +1,37 @@ +#!/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) diff --git a/test/rpc/run.sh b/test/rpc/run.sh index 4d8260c62..f13b040d0 100755 --- a/test/rpc/run.sh +++ b/test/rpc/run.sh @@ -24,6 +24,12 @@ function _exit { exit $1 } +function check_and_term { + title_print "Check and term $1" + ps -C $1 + pkill $1 +} + title_print "Build programs" make clean mkdir build @@ -45,4 +51,17 @@ ${CRIU} restore -v4 -o restore-c.log -D imgs_c --shell-job || _exit $? title_print "Restore test-py" ${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