mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-08-01 06:20:55 +00:00
test: rpc: restore
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
ba196e6358
commit
f5cd8bfdc3
3 changed files with 60 additions and 0 deletions
4
test/rpc/loop.sh
Executable file
4
test/rpc/loop.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
while :; do
|
||||
sleep 1
|
||||
done
|
||||
37
test/rpc/restore-loop.py
Executable file
37
test/rpc/restore-loop.py
Executable file
|
|
@ -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)
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue