[CRIU] [PATCH v3] test: adjust the output for tests

Yicheng Qin yichengq at google.com
Tue Aug 13 05:02:55 EDT 2013


Adjust the format of information printed.
Print out more necessary debug information.
Display error message in STDERR and make it more readable.

Signed-off-by: Yicheng Qin <yichengq at google.com>
---
Changelog since v2:
- no-error on creating existed directory
Changelog since v1:
- redirect all output of case_error in stderr

 test/tcp/run.sh | 13 ++++++++++++-
 test/zdtm.sh    | 31 ++++++++++++++++++++++++++-----
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/test/tcp/run.sh b/test/tcp/run.sh
index 0dd0e70..43a0674 100644
--- a/test/tcp/run.sh
+++ b/test/tcp/run.sh
@@ -34,12 +34,21 @@ echo "Make it run"
 echo "${TEXT}" >&3
 
 function fail {
+	echo FAIL
+
+(	exec >&2
+
 	echo "$@"
 	kill -9 ${CLN_PID}
 	kill -9 ${SRV_PID}
+	echo ${CLN_LOG}:
+	cat ${CLN_LOG}
+)
 	exit 1
 }
 
+kill -s 0 ${CLN_PID} || fail "Client is dead"
+
 echo "Suspend server"
 ${CRIU} dump -D ${DDIR} -o dump.log -t ${SRV_PID} --tcp-established -vvvv || fail "Fail to dump server"
 sleep 1
@@ -51,5 +60,7 @@ echo "${TEXT}" >&3
 
 echo "Collect results"
 exec 3>&-
-wait ${CLN_PID}
+wait ${CLN_PID} || fail "Client exits abruptly"
 kill -9 ${SRV_PID}
+
+echo PASS
diff --git a/test/zdtm.sh b/test/zdtm.sh
index 1f18765..77a7512 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -182,6 +182,10 @@ check_mainstream()
 	local -a ver_arr
 	local ver_str=`uname -r`
 
+	cat >&2 <<EOF
+========================== CRIU CHECK =============================
+EOF
+
 	$CRIU check && return 0
 	MAINSTREAM_KERNEL=1
 
@@ -257,7 +261,7 @@ construct_root()
 	done
 
 	# make 'tmp' dir under new root
-	mkdir $tmpdir
+	mkdir -p $tmpdir
 	chmod 0777 $tmpdir
 }
 
@@ -287,7 +291,7 @@ start_test()
 		PID=`cat $test.pid` || return 1
 	else
 		if [ -z "$ZDTM_ROOT" ]; then
-			mkdir dump
+			mkdir -p dump
 			ZDTM_ROOT=`mktemp -d /tmp/criu-root.XXXXXX`
 			ZDTM_ROOT=`readlink -f $ZDTM_ROOT`
 			mount --bind . $ZDTM_ROOT || return 1
@@ -508,6 +512,7 @@ EOF
 	cat $test.out
 	cat $test.out | grep -q PASS || return 2
 	[ "$CLEANUP" -ne 0 ] && rm -rf `dirname $ddump`
+	echo "Test: $test, Result: PASS"
 	return 0
 }
 
@@ -516,25 +521,41 @@ case_error()
 	test=${ZP}/${1#ns/}
 	local test_log=`pwd`/$test.out
 
+	echo "Test: $test, Result: FAIL"
 	ZDTM_FAILED=1
 
-	echo "Test: $test"
+(	exec >&2
+
 	echo "====================== ERROR ======================"
+	echo "Test: $test, Namespace: $PIDNS"
 
 	if [ -n "$DUMP_PATH" ]; then
 		[ -e "$DUMP_PATH/dump.log" ] && {
 			echo "Dump log   : $DUMP_PATH/dump.log"
 			cat $DUMP_PATH/dump.log* | grep Error
+			echo "* * * * * * * * * * * * * * *"
+			tail -n 40 $DUMP_PATH/dump.log*
+			echo "*****************************"
 		}
 		[ -e "$DUMP_PATH/restore.log" ] && {
 			echo "Restore log: $DUMP_PATH/restore.log"
 			cat $DUMP_PATH/restore.log* | grep Error
+			echo "* * * * * * * * * * * * * * *"
+			tail -n 40 $DUMP_PATH/restore.log*
+			echo "*****************************"
 		}
 	fi
-	[ -e "$test_log" ] &&
+	[ -e "$test_log" ] && {
 		echo "Output file: $test_log"
+		cat $test_log*
+		echo "*****************************"
+	}
+
 	[ -n "$HEAD" ] &&
 		echo "The initial HEAD was $HEAD"
+
+	echo "==================== ERROR OVER ===================="
+)
 	exit 1
 }
 
@@ -594,7 +615,7 @@ while :; do
 	if [ "$1" = "-t" ]; then
 		shift
 		TMPFS_DUMP=dump
-		[ -d dump ] || mkdir $TMPFS_DUMP
+		[ -d dump ] || mkdir -p $TMPFS_DUMP
 		mount -t tmpfs none $TMPFS_DUMP || exit 1
 		continue;
 	fi
-- 
1.8.3



More information about the CRIU mailing list