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

Andrew Vagin avagin at gmail.com
Tue Aug 13 12:15:20 EDT 2013


# git diff
diff --git a/test/zdtm/live/static/env00.c
b/test/zdtm/live/static/env00.c
index c6ab23a..08d26c2 100644
--- a/test/zdtm/live/static/env00.c
+++ b/test/zdtm/live/static/env00.c
@@ -32,8 +32,8 @@ int main(int argc, char **argv)
 
        if (strcmp(env, test_author))
                fail("%s != %s\n", env, test_author);
-       else
-               pass();
+//     else
+//             pass();
 out:
        return 0;
 }

# bash test/zdtm.sh  -i 0 static/.*  1> /dev/null
========================== CRIU CHECK =============================
====================== ERROR ======================
Test: zdtm/live/static/env00, Namespace: 
Output file: /root/crtools/test/zdtm/live/static/env00.out
*****************************
==================== ERROR OVER ====================

Can all markштп line have the same size?
I would prefer to use "----" instead of "****"

On Mon, Aug 12, 2013 at 03:49:14PM -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.
> 
> Signed-off-by: Yicheng Qin <yichengq at google.com>
> ---
> Changelog since v1:
> - redirect all output of case_error in stderr
> 
>  test/tcp/run.sh | 13 ++++++++++++-
>  test/zdtm.sh    | 27 ++++++++++++++++++++++++---
>  2 files changed, 36 insertions(+), 4 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 0f4decd..79c7641 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
>  }
>  
> @@ -509,6 +513,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
>  }
>  
> @@ -517,25 +522,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
>  }
>  
> -- 
> 1.8.3
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list