2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

test: adjust the output for tests

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@google.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Yicheng Qin
2013-08-14 13:43:06 +04:00
committed by Pavel Emelyanov
parent 1f9da83048
commit a7a787a402
2 changed files with 58 additions and 8 deletions

View File

@@ -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

View File

@@ -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