mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 01:51:51 +00:00
test: Check action scripts to work as we expect
We expect: - all 9 scripts are called - there's always images dir variable - for 7 of those scripts there's root-pid variable Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Acked-by: Andrew Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
caf67f1f73
commit
330b0d1656
40
test/check_actions.py
Executable file
40
test/check_actions.py
Executable file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
actions = set(['pre-dump', 'pre-restore', 'post-dump', 'setup-namespaces', \
|
||||
'post-setup-namespaces', 'post-restore', 'post-resume', \
|
||||
'network-lock', 'network-unlock' ])
|
||||
errors = []
|
||||
af = os.path.dirname(os.path.abspath(__file__)) + '/actions_called.txt'
|
||||
|
||||
for act in open(af):
|
||||
act = act.strip().split()
|
||||
act.append('EMPTY')
|
||||
act.append('EMPTY')
|
||||
|
||||
if act[0] == 'EMPTY':
|
||||
raise Exception("Error in test, bogus actions line")
|
||||
|
||||
if act[1] == 'EMPTY':
|
||||
errors.append('Action %s misses CRTOOLS_IMAGE_DIR' % act[0])
|
||||
|
||||
if act[0] in ('post-dump', 'setup-namespaces', 'post-setup-namespaces', \
|
||||
'post-restore', 'post-resume', 'network-lock', 'network-unlock'):
|
||||
if act[2] == 'EMPTY':
|
||||
errors.append('Action %s misses CRTOOLS_INIT_PID' % act[0])
|
||||
elif not act[2].isdigit() or int(act[2]) == 0:
|
||||
errors.append('Action %s PID is not number (%s)' % (act[0], act[2]))
|
||||
|
||||
actions -= set([act[0]])
|
||||
|
||||
if actions:
|
||||
errors.append('Not all actions called: %r' % actions)
|
||||
|
||||
if errors:
|
||||
for x in errors:
|
||||
print x
|
||||
sys.exit(1)
|
||||
|
||||
print 'PASS'
|
8
test/jenkins/actions.sh
Executable file
8
test/jenkins/actions.sh
Executable file
@ -0,0 +1,8 @@
|
||||
# Check how crit de/encodes images
|
||||
set -e
|
||||
source `dirname $0`/criu-lib.sh
|
||||
# prep
|
||||
rm -f actions_called.txt
|
||||
./test/zdtm.py run -t zdtm/static/env00 --script "$(pwd)/test/show_action.sh" || fail
|
||||
./test/check_actions.py || fail
|
||||
exit 0
|
3
test/show_action.sh
Executable file
3
test/show_action.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
echo "${CRTOOLS_SCRIPT_ACTION} ${CRTOOLS_IMAGE_DIR} ${CRTOOLS_INIT_PID}" \
|
||||
>> "$(dirname $0)/actions_called.txt"
|
@ -610,6 +610,7 @@ class criu_cli:
|
||||
self.__page_server = (opts['page_server'] and True or False)
|
||||
self.__restore_sibling = (opts['sibling'] and True or False)
|
||||
self.__fault = (opts['fault'])
|
||||
self.__script = opts['script']
|
||||
self.__sat = (opts['sat'] and True or False)
|
||||
self.__dedup = (opts['dedup'] and True or False)
|
||||
self.__user = (opts['user'] and True or False)
|
||||
@ -672,6 +673,9 @@ class criu_cli:
|
||||
strace += [ '-f' ]
|
||||
s_args += [ '--action-script', os.getcwd() + '/../scripts/fake-restore.sh' ]
|
||||
|
||||
if self.__script:
|
||||
s_args += ['--action-script', self.__script]
|
||||
|
||||
preexec = self.__user and self.set_user_id or None
|
||||
|
||||
__ddir = self.__ddir()
|
||||
@ -1058,7 +1062,7 @@ class launcher:
|
||||
self.__show_progress()
|
||||
|
||||
nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', \
|
||||
'fault', 'keep_img', 'report', 'snaps', 'sat', \
|
||||
'fault', 'keep_img', 'report', 'snaps', 'sat', 'script', \
|
||||
'dedup', 'sbs', 'freezecg', 'user', 'dry_run')
|
||||
arg = repr((name, desc, flavor, { d: self.__opts[d] for d in nd }))
|
||||
|
||||
@ -1484,7 +1488,7 @@ rp.add_argument("--user", help = "Run CRIU as regular user", action = 'store_tru
|
||||
rp.add_argument("--page-server", help = "Use page server dump", action = 'store_true')
|
||||
rp.add_argument("-p", "--parallel", help = "Run test in parallel")
|
||||
rp.add_argument("--dry-run", help="Don't run tests, just pretend to", action='store_true')
|
||||
|
||||
rp.add_argument("--script", help="Add script to get notified by criu")
|
||||
rp.add_argument("-k", "--keep-img", help = "Whether or not to keep images after test",
|
||||
choices = [ 'always', 'never', 'failed' ], default = 'failed')
|
||||
rp.add_argument("--report", help = "Generate summary report in directory")
|
||||
|
Loading…
x
Reference in New Issue
Block a user