From ff0e96dcf900b26cfbdb4d2e28c85b3bb7b8c65b Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Mon, 22 Jul 2013 19:36:47 +0400 Subject: [PATCH] zdtm: Use "post-dump" script for "-d" and "-s" option v2: - Use special opcode 32 to distinguish error cases - Use --scripts for snapshot testings v3: - test for both 32 and 0 for error code v4: (by avagin@) - restore from the last snapshot v5: - update comment https://bugzilla.openvz.org/show_bug.cgi?id=2583 Signed-off-by: Cyrill Gorcunov Signed-off-by: Andrey Vagin Signed-off-by: Pavel Emelyanov --- test/post-dump.sh | 9 +++++++++ test/zdtm.sh | 32 ++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 8 deletions(-) create mode 100755 test/post-dump.sh diff --git a/test/post-dump.sh b/test/post-dump.sh new file mode 100755 index 000000000..50ada0601 --- /dev/null +++ b/test/post-dump.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +[ $CRTOOLS_SCRIPT_ACTION == post-dump ] && { + # + # Special code to inform zdtm that we're + # done and should proceed testing treating + # non-zero return as known case. + exit 32 +} diff --git a/test/zdtm.sh b/test/zdtm.sh index e8db62a94..e610aa72a 100755 --- a/test/zdtm.sh +++ b/test/zdtm.sh @@ -153,6 +153,8 @@ sk-netlink CRIU=$(readlink -f `dirname $0`/../criu) CRIU_CPT=$CRIU TMP_TREE="" +SCRIPTDIR=`dirname $CRIU`/test +POSTDUMP="--action-script $SCRIPTDIR/post-dump.sh" test -x $CRIU || { echo "$CRIU is unavailable" @@ -378,12 +380,15 @@ EOF } for i in `seq $ITERATIONS`; do - + local dump_only= + local postdump= ddump=dump/$tname/$PID/$i DUMP_PATH=`pwd`/$ddump echo Dump $PID mkdir -p $ddump + [ -n "$DUMP_ONLY" ] && dump_only=1 + if [ $PAGE_SERVER -eq 1 ]; then $CRIU page-server -D $ddump -o page_server.log -v4 --port $PS_PORT --daemon PS_PID=$! @@ -392,16 +397,28 @@ EOF if [ -n "$SNAPSHOT" ]; then snapopt="" - [ "$i" -ne "$ITERATIONS" ] && snapopt="$snapopt -R --track-mem" + [ "$i" -ne "$ITERATIONS" ] && { + snapopt="$snapopt -R --track-mem" + dump_only=1 + } [ -n "$snappdir" ] && snapopt="$snapopt --prev-images-dir=$snappdir" fi + [ -n "$dump_only" ] && postdump=$POSTDUMP + save_fds $PID $ddump/dump.fd setsid $CRIU_CPT dump $opts --file-locks --tcp-established $linkremap \ - -x --evasive-devices -D $ddump -o dump.log -v4 -t $PID $args $ARGS $snapopt || { - echo WARNING: process $tname is left running for your debugging needs + -x --evasive-devices -D $ddump -o dump.log -v4 -t $PID $args $ARGS $snapopt $postdump + retcode=$? + + # + # Here we may have two cases: either checkpoint is failed + # with some error code, or checkpoint is complete but return + # code is non-zero because of post dump action. + if [ "$retcode" -ne 0 ] && [[ "$retcode" -ne 32 || -z "$dump_only" ]]; then + echo WARNING: $tname returned $retcode and left running for debug needs return 1 - } + fi if [ -n "$SNAPSHOT" ]; then snappdir=../`basename $ddump` @@ -412,10 +429,9 @@ EOF wait $PS_PID fi - if expr " $ARGS" : ' -s' > /dev/null; then + if [ -n "$dump_only" ]; then save_fds $PID $ddump/dump.fd.after diff_fds $ddump/dump.fd $ddump/dump.fd.after || return 1 - killall -CONT $tname if [[ $linkremap ]]; then echo "remove ./$tdir/link_remap.*" rm -f ./$tdir/link_remap.* @@ -512,7 +528,7 @@ cd `dirname $0` || exit 1 while :; do if [ "$1" = "-d" ]; then - ARGS="-s" + DUMP_ONLY=1 shift continue fi