diff --git a/test/check_actions.py b/test/check_actions.py new file mode 100755 index 000000000..70d257fbd --- /dev/null +++ b/test/check_actions.py @@ -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' diff --git a/test/jenkins/actions.sh b/test/jenkins/actions.sh new file mode 100755 index 000000000..801904500 --- /dev/null +++ b/test/jenkins/actions.sh @@ -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 diff --git a/test/show_action.sh b/test/show_action.sh new file mode 100755 index 000000000..86468b67a --- /dev/null +++ b/test/show_action.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo "${CRTOOLS_SCRIPT_ACTION} ${CRTOOLS_IMAGE_DIR} ${CRTOOLS_INIT_PID}" \ + >> "$(dirname $0)/actions_called.txt" diff --git a/test/zdtm.py b/test/zdtm.py index b8b2eaad0..67e852cbf 100755 --- a/test/zdtm.py +++ b/test/zdtm.py @@ -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")