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

Andrew Vagin avagin at parallels.com
Tue Aug 13 15:17:53 EDT 2013


On Tue, Aug 13, 2013 at 11:05:23AM -0700, Yicheng Qin wrote:
> Adjust the format of information printed.
> Print out more necessary debug information.
> Display error message in STDERR and make it more readable.
> 

Acked-by: Andrew Vagin <avagin at parallels.com>

> Signed-off-by: Yicheng Qin <yichengq at google.com>
> ---
> Changelog since v3:
> - modify format
> 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    | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
>  2 files changed, 58 insertions(+), 8 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 bdceeff..6868863 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
>  
> @@ -198,7 +202,7 @@ EOF
>  	[ "${ver_arr[0]}" -gt 3 ] && return 0
>  	[[ "${ver_arr[0]}" -eq 3 && "${ver_arr[1]}" -ge 8 ]] && return 0
>  
> -	echo "A version of kernel should be greater or equal to 3.8"
> +	echo "A version of kernel should be greater or equal to 3.8" >&2
>  
>  	return 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,59 @@ case_error()
>  	test=${ZP}/${1#ns/}
>  	local test_log=`pwd`/$test.out
>  
> +	echo "Test: $test, Result: FAIL"
>  	ZDTM_FAILED=1
>  
> -	echo "Test: $test"
> -	echo "====================== ERROR ======================"
> +(	exec >&2
> +
> +	cat <<EOF
> +============================= ERROR ===============================
> +EOF
> +
> +	echo "Test: $test, Namespace: $PIDNS"
> +	cat <<EOF
> +-------------------------------------------------------------------
> +EOF
>  
>  	if [ -n "$DUMP_PATH" ]; then
>  		[ -e "$DUMP_PATH/dump.log" ] && {
>  			echo "Dump log   : $DUMP_PATH/dump.log"
>  			cat $DUMP_PATH/dump.log* | grep Error
> +			cat <<EOF
> +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> +EOF
> +			tail -n 40 $DUMP_PATH/dump.log*
> +			cat <<EOF
> +-------------------------------------------------------------------
> +EOF
>  		}
>  		[ -e "$DUMP_PATH/restore.log" ] && {
>  			echo "Restore log: $DUMP_PATH/restore.log"
>  			cat $DUMP_PATH/restore.log* | grep Error
> +			cat <<EOF
> +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> +EOF
> +			tail -n 40 $DUMP_PATH/restore.log*
> +			cat <<EOF
> +-------------------------------------------------------------------
> +EOF
>  		}
>  	fi
> -	[ -e "$test_log" ] &&
> +	[ -e "$test_log" ] && {
>  		echo "Output file: $test_log"
> +		cat $test_log*
> +		cat <<EOF
> +-------------------------------------------------------------------
> +EOF
> +	}
> +
>  	[ -n "$HEAD" ] &&
>  		echo "The initial HEAD was $HEAD"
> +
> +	cat <<EOF
> +=========================== ERROR OVER ============================
> +EOF
> +)
>  	exit 1
>  }
>  
> @@ -594,7 +633,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