[CRIU] [PATCH] zdtm.py: Check how CRIT de/encodes images
Pavel Emelyanov
xemul at parallels.com
Mon Nov 23 05:02:11 PST 2015
To do this decode and encode every single image generated during the
test. This takes times, so for jenkins job exclude several of them.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
crit | 2 +-
test/jenkins/crit.sh | 6 ++++++
test/zdtm.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 54 insertions(+), 3 deletions(-)
create mode 100644 test/jenkins/crit.sh
diff --git a/crit b/crit
index 2758b01..14eb3dc 100755
--- a/crit
+++ b/crit
@@ -27,7 +27,7 @@ def decode(opts):
print >>sys.stderr, "Unknown magic %#x.\n"\
"Maybe you are feeding me an image with "\
"raw data(i.e. pages.img)?" % exc.magic
- sys.exit(1)
+ sys.exit(13)
if opts['pretty']:
indent = 4
diff --git a/test/jenkins/crit.sh b/test/jenkins/crit.sh
new file mode 100644
index 0000000..c625869
--- /dev/null
+++ b/test/jenkins/crit.sh
@@ -0,0 +1,6 @@
+# Check how crit en-/decodes images
+set -e
+source `dirname $0`/criu-lib.sh
+prep
+mount_tmpfs_to_dump
+./test/zdtm.py run --all --crit --report report -f uns -x maps04 -x rtc -x transition -f uns || fail
diff --git a/test/zdtm.py b/test/zdtm.py
index b9bcb4f..3ccdeef 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -18,6 +18,7 @@ import string
import imp
import socket
import fcntl
+import filecmp
os.chdir(os.path.dirname(os.path.abspath(__file__)))
@@ -460,6 +461,8 @@ test_classes = { 'zdtm': zdtm_test, 'inhfd': inhfd_test }
#
criu_bin = "../criu"
+crit_bin = "../crit"
+
class criu_cli:
def __init__(self, opts):
self.__test = None
@@ -660,6 +663,44 @@ def check_visible_state(test, state):
raise test_fail_exc("maps compare")
+
+def check_img_with_crit(img_dir, img_name):
+ img_path = os.path.join(img_dir, img_name)
+ try:
+ subprocess.check_call([crit_bin, "decode", \
+ "-i", img_path, "-o", img_path + '.json' ])
+ except subprocess.CalledProcessError as e:
+ if e.returncode == 13: # Bad magic, not an image
+ print "[%s] crit skip" % img_name
+ return
+
+ raise test_fail_exc("Image %s decode FAIL" % img_name)
+
+ try:
+ subprocess.check_call([crit_bin, "encode", \
+ "-i", img_path + '.json', "-o", img_path + '.2' ])
+ except subprocess.CalledProcessError:
+ raise test_fail_exc("Image %s encode FAIL" % img_name)
+
+ if not filecmp.cmp(img_path, img_path + '.2'):
+ raise test_fail_exc("Image %s enc-dec FAIL" % img_name)
+
+
+def check_imgs_with_crit(path):
+ print "Verify [%s] with CRIT" % path
+ sys.stdout.flush() # Not to let crit's messages appear before ours
+
+ for i in os.listdir(path):
+ i = path + '/' + i
+ for img in os.listdir(i):
+ if not img.endswith('.img'):
+ continue
+ if img.startswith('pages-'):
+ continue
+
+ check_img_with_crit(i, img)
+
+
def do_run_test(tname, tdesc, flavs, opts):
tcname = tname.split('/')[0]
tclass = test_classes.get(tcname, None)
@@ -690,6 +731,8 @@ def do_run_test(tname, tdesc, flavs, opts):
check_visible_state(t, s)
t.stop()
try_run_hook(t, ["--clean"])
+ if opts['crit']:
+ check_imgs_with_crit(cr_api.logs())
except test_fail_exc as e:
print_sep("Test %s FAIL at %s" % (tname, e.step), '#')
t.print_output()
@@ -729,7 +772,8 @@ class launcher:
self.__nr += 1
self.__show_progress()
- nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', 'fault', 'keep_img', 'report', 'snaps', 'sat')
+ nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', \
+ 'fault', 'keep_img', 'report', 'snaps', 'sat', 'crit')
arg = repr((name, desc, flavor, { d: self.__opts[d] for d in nd }))
log = name.replace('/', '_') + ".log"
sub = subprocess.Popen(["./zdtm_ct", "zdtm.py"], \
@@ -952,6 +996,7 @@ rp.add_argument("--norst", help = "Don't restore tasks, leave them running after
rp.add_argument("--iters", help = "Do CR cycle several times before check (n[:pause])")
rp.add_argument("--fault", help = "Test fault injection")
rp.add_argument("--sat", help = "Generate criu strace-s for sat tool (restore is fake, images are kept)", action = 'store_true')
+rp.add_argument("--crit", help = "Check images with CRIT", action = 'store_true')
rp.add_argument("--page-server", help = "Use page server dump", action = 'store_true')
rp.add_argument("-p", "--parallel", help = "Run test in parallel")
@@ -965,7 +1010,7 @@ lp.set_defaults(action = list_tests)
lp.add_argument('-i', '--info', help = "Show more info about tests", action = 'store_true')
opts = vars(p.parse_args())
-if opts['sat']:
+if opts.get('sat', False):
opts['keep_img'] = 'always'
if opts['debug']:
--
1.9.3
More information about the CRIU
mailing list