tests/qemu-iotests: re-format output to for make check-block
This attempts to clean-up the output to better match the output of the rest of the QEMU check system when called with -makecheck. This includes: - formatting as " TEST iotest-FMT: nnn" - only dumping config on failure (when -makecheck enabled) The non-make check output has been cleaned up as well: - line re-displayed (\r) at the end - fancy colours for pass/fail/skip - timestamps always printed (option removed) Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20190503143904.31211-1-alex.bennee@linaro.org> Tested-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
d4271ce5b5
commit
70ff5b07fc
@ -27,9 +27,7 @@ bad=""
|
|||||||
notrun=""
|
notrun=""
|
||||||
casenotrun=""
|
casenotrun=""
|
||||||
interrupt=true
|
interrupt=true
|
||||||
|
makecheck=false
|
||||||
# by default don't output timestamps
|
|
||||||
timestamp=${TIMESTAMP:=false}
|
|
||||||
|
|
||||||
_init_error()
|
_init_error()
|
||||||
{
|
{
|
||||||
@ -88,6 +86,22 @@ _full_platform_details()
|
|||||||
echo "$os/$platform $host $kernel"
|
echo "$os/$platform $host $kernel"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_full_env_details()
|
||||||
|
{
|
||||||
|
cat <<EOF
|
||||||
|
QEMU -- "$QEMU_PROG" $QEMU_OPTIONS
|
||||||
|
QEMU_IMG -- "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS
|
||||||
|
QEMU_IO -- "$QEMU_IO_PROG" $QEMU_IO_OPTIONS
|
||||||
|
QEMU_NBD -- "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS
|
||||||
|
IMGFMT -- $FULL_IMGFMT_DETAILS
|
||||||
|
IMGPROTO -- $IMGPROTO
|
||||||
|
PLATFORM -- $FULL_HOST_DETAILS
|
||||||
|
TEST_DIR -- $TEST_DIR
|
||||||
|
SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
# $1 = prog to look for
|
# $1 = prog to look for
|
||||||
set_prog_path()
|
set_prog_path()
|
||||||
{
|
{
|
||||||
@ -254,8 +268,8 @@ other options
|
|||||||
-misalign misalign memory allocations
|
-misalign misalign memory allocations
|
||||||
-n show me, do not run tests
|
-n show me, do not run tests
|
||||||
-o options -o options to pass to qemu-img create/convert
|
-o options -o options to pass to qemu-img create/convert
|
||||||
-T output timestamps
|
|
||||||
-c mode cache mode
|
-c mode cache mode
|
||||||
|
-makecheck pretty print output for make check
|
||||||
|
|
||||||
testlist options
|
testlist options
|
||||||
-g group[,group...] include tests from these groups
|
-g group[,group...] include tests from these groups
|
||||||
@ -403,7 +417,10 @@ testlist options
|
|||||||
command -v xxdiff >/dev/null 2>&1 && diff=xxdiff
|
command -v xxdiff >/dev/null 2>&1 && diff=xxdiff
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
-makecheck) # makecheck friendly output
|
||||||
|
makecheck=true
|
||||||
|
xpand=false
|
||||||
|
;;
|
||||||
-n) # show me, don't do it
|
-n) # show me, don't do it
|
||||||
showme=true
|
showme=true
|
||||||
xpand=false
|
xpand=false
|
||||||
@ -416,8 +433,7 @@ testlist options
|
|||||||
cachemode=true
|
cachemode=true
|
||||||
xpand=false
|
xpand=false
|
||||||
;;
|
;;
|
||||||
-T) # turn on timestamp output
|
-T) # deprecated timestamp option
|
||||||
timestamp=true
|
|
||||||
xpand=false
|
xpand=false
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@ -633,12 +649,6 @@ _wallclock()
|
|||||||
date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }'
|
date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
_timestamp()
|
|
||||||
{
|
|
||||||
now=$(date "+%T")
|
|
||||||
printf %s " [$now]"
|
|
||||||
}
|
|
||||||
|
|
||||||
_wrapup()
|
_wrapup()
|
||||||
{
|
{
|
||||||
if $showme
|
if $showme
|
||||||
@ -704,23 +714,54 @@ END { if (NR > 0) {
|
|||||||
|
|
||||||
trap "_wrapup; exit \$status" 0 1 2 3 15
|
trap "_wrapup; exit \$status" 0 1 2 3 15
|
||||||
|
|
||||||
|
# Report the test start and results. For makecheck we want to pretty
|
||||||
|
# print the whole report at the end of the execution.
|
||||||
|
# args: $seq, $starttime, $lasttime
|
||||||
|
_report_test_start()
|
||||||
|
{
|
||||||
|
if ! $makecheck; then
|
||||||
|
if [ -n "$3" ]; then
|
||||||
|
local lasttime=" (last: $3s)"
|
||||||
|
fi
|
||||||
|
printf "%-8s %-10s [%s] %4s%-14s\r" "$1" "..." "$2" "..." "$lasttime"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
# args:$seq $status $starttime $lasttime $thistime $details
|
||||||
|
_report_test_result()
|
||||||
|
{
|
||||||
|
local status lasttime thistime
|
||||||
|
if $makecheck; then
|
||||||
|
if [ -n "$2" ] && [ "$2" != "pass" ]; then
|
||||||
|
status=" [$2]"
|
||||||
|
fi
|
||||||
|
printf " TEST iotest-$IMGFMT: %s%s\n" "$1" "$status"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$4" ]; then
|
||||||
|
lasttime=" (last: $4s)"
|
||||||
|
fi
|
||||||
|
if [ -n "$5" ]; then
|
||||||
|
thistime=" $5s"
|
||||||
|
fi
|
||||||
|
case "$2" in
|
||||||
|
"pass") status=$(printf "\e[32m%-10s\e[0m" "$2") ;;
|
||||||
|
"fail") status=$(printf "\e[1m\e[31m%-10s\e[0m" "$2") ;;
|
||||||
|
"not run") status=$(printf "\e[33m%-10s\e[0m" "$2") ;;
|
||||||
|
*) status=$(printf "%-10s" "$2") ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
printf "%-8s %s [%s] [%s] %4s%-14s %s\n" "$1" "$status" "$3" "$(date '+%T')" "$thistime" "$lasttime" "$6"
|
||||||
|
}
|
||||||
|
|
||||||
[ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE
|
[ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE
|
||||||
|
|
||||||
FULL_IMGFMT_DETAILS=$(_full_imgfmt_details)
|
FULL_IMGFMT_DETAILS=$(_full_imgfmt_details)
|
||||||
FULL_HOST_DETAILS=$(_full_platform_details)
|
FULL_HOST_DETAILS=$(_full_platform_details)
|
||||||
|
|
||||||
cat <<EOF
|
if ! $makecheck; then
|
||||||
QEMU -- "$QEMU_PROG" $QEMU_OPTIONS
|
_full_env_details
|
||||||
QEMU_IMG -- "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS
|
fi
|
||||||
QEMU_IO -- "$QEMU_IO_PROG" $QEMU_IO_OPTIONS
|
|
||||||
QEMU_NBD -- "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS
|
|
||||||
IMGFMT -- $FULL_IMGFMT_DETAILS
|
|
||||||
IMGPROTO -- $IMGPROTO
|
|
||||||
PLATFORM -- $FULL_HOST_DETAILS
|
|
||||||
TEST_DIR -- $TEST_DIR
|
|
||||||
SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
seq="check"
|
seq="check"
|
||||||
|
|
||||||
@ -728,42 +769,43 @@ seq="check"
|
|||||||
|
|
||||||
for seq in $list
|
for seq in $list
|
||||||
do
|
do
|
||||||
err=false
|
err=false # error flag
|
||||||
printf %s "$seq"
|
printdiff=false # show diff to reference output?
|
||||||
|
status="" # test result summary
|
||||||
|
results="" # test result details
|
||||||
|
|
||||||
if [ -n "$TESTS_REMAINING_LOG" ] ; then
|
if [ -n "$TESTS_REMAINING_LOG" ] ; then
|
||||||
sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
|
sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
|
||||||
mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
|
mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
|
||||||
sync
|
sync
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE)
|
||||||
|
starttime=$(date "+%T")
|
||||||
|
_report_test_start $seq $starttime $lasttime
|
||||||
|
|
||||||
if $showme
|
if $showme
|
||||||
then
|
then
|
||||||
echo
|
status="not run"
|
||||||
continue
|
|
||||||
elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
|
elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
|
||||||
then
|
then
|
||||||
echo " - expunged"
|
status="not run"
|
||||||
|
results="expunged"
|
||||||
rm -f $seq.out.bad
|
rm -f $seq.out.bad
|
||||||
echo "/^$seq\$/d" >>$tmp.expunged
|
echo "/^$seq\$/d" >>$tmp.expunged
|
||||||
elif [ ! -f "$source_iotests/$seq" ]
|
elif [ ! -f "$source_iotests/$seq" ]
|
||||||
then
|
then
|
||||||
echo " - no such test?"
|
status="not run"
|
||||||
|
results="no such test?"
|
||||||
echo "/^$seq\$/d" >>$tmp.expunged
|
echo "/^$seq\$/d" >>$tmp.expunged
|
||||||
else
|
else
|
||||||
# really going to try and run this one
|
# really going to try and run this one
|
||||||
#
|
#
|
||||||
rm -f $seq.out.bad
|
rm -f $seq.out.bad
|
||||||
lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE)
|
|
||||||
if [ "X$lasttime" != X ]; then
|
|
||||||
printf %s " ${lasttime}s ..."
|
|
||||||
else
|
|
||||||
printf " " # prettier output with timestamps.
|
|
||||||
fi
|
|
||||||
rm -f core $seq.notrun
|
rm -f core $seq.notrun
|
||||||
rm -f $seq.casenotrun
|
rm -f $seq.casenotrun
|
||||||
|
|
||||||
start=$(_wallclock)
|
start=$(_wallclock)
|
||||||
$timestamp && printf %s " [$(date "+%T")]"
|
|
||||||
|
|
||||||
if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
|
if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
|
||||||
run_command="$PYTHON $seq"
|
run_command="$PYTHON $seq"
|
||||||
@ -781,26 +823,26 @@ do
|
|||||||
$run_command >$tmp.out 2>&1)
|
$run_command >$tmp.out 2>&1)
|
||||||
fi
|
fi
|
||||||
sts=$?
|
sts=$?
|
||||||
$timestamp && _timestamp
|
|
||||||
stop=$(_wallclock)
|
stop=$(_wallclock)
|
||||||
|
|
||||||
if [ -f core ]
|
if [ -f core ]
|
||||||
then
|
then
|
||||||
printf " [dumped core]"
|
|
||||||
mv core $seq.core
|
mv core $seq.core
|
||||||
|
status="fail"
|
||||||
|
results="[dumped core] $seq.core"
|
||||||
err=true
|
err=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $seq.notrun ]
|
if [ -f $seq.notrun ]
|
||||||
then
|
then
|
||||||
$timestamp || printf " [not run] "
|
# overwrites timestamp output
|
||||||
$timestamp && echo " [not run]" && printf %s " $seq -- "
|
status="not run"
|
||||||
cat $seq.notrun
|
results="$(cat $seq.notrun)"
|
||||||
notrun="$notrun $seq"
|
|
||||||
else
|
else
|
||||||
if [ $sts -ne 0 ]
|
if [ $sts -ne 0 ]
|
||||||
then
|
then
|
||||||
printf %s " [failed, exit status $sts]"
|
status="fail"
|
||||||
|
results=$(printf %s "[failed, exit status $sts]")
|
||||||
err=true
|
err=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -821,22 +863,23 @@ do
|
|||||||
|
|
||||||
if [ ! -f "$reference" ]
|
if [ ! -f "$reference" ]
|
||||||
then
|
then
|
||||||
echo " - no qualified output"
|
status="fail"
|
||||||
|
reason="no qualified output"
|
||||||
err=true
|
err=true
|
||||||
else
|
else
|
||||||
if diff -w "$reference" $tmp.out >/dev/null 2>&1
|
if diff -w "$reference" $tmp.out >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
echo ""
|
if ! $err; then
|
||||||
if $err
|
status="pass"
|
||||||
then
|
thistime=$(expr $stop - $start)
|
||||||
:
|
echo "$seq $thistime" >>$tmp.time
|
||||||
else
|
|
||||||
echo "$seq $(expr $stop - $start)" >>$tmp.time
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo " - output mismatch (see $seq.out.bad)"
|
|
||||||
mv $tmp.out $seq.out.bad
|
mv $tmp.out $seq.out.bad
|
||||||
$diff -w "$reference" "$PWD"/$seq.out.bad
|
$diff -w "$reference" "$PWD"/$seq.out.bad
|
||||||
|
status="fail"
|
||||||
|
results="output mismatch (see $seq.out.bad)"
|
||||||
|
printdiff=true
|
||||||
err=true
|
err=true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -850,13 +893,27 @@ do
|
|||||||
|
|
||||||
# come here for each test, except when $showme is true
|
# come here for each test, except when $showme is true
|
||||||
#
|
#
|
||||||
if $err
|
_report_test_result $seq "$status" "$starttime" "$lasttime" "$thistime" "$results"
|
||||||
then
|
case "$status" in
|
||||||
bad="$bad $seq"
|
"pass")
|
||||||
n_bad=$(expr $n_bad + 1)
|
try=$(expr $try + 1)
|
||||||
quick=false
|
;;
|
||||||
fi
|
"fail")
|
||||||
[ -f $seq.notrun ] || try=$(expr $try + 1)
|
try=$(expr $try + 1)
|
||||||
|
if $makecheck; then
|
||||||
|
_full_env_details
|
||||||
|
fi
|
||||||
|
if $printdiff; then
|
||||||
|
$diff -w "$reference" "$PWD"/$seq.out.bad
|
||||||
|
fi
|
||||||
|
bad="$bad $seq"
|
||||||
|
n_bad=$(expr $n_bad + 1)
|
||||||
|
quick=false
|
||||||
|
;;
|
||||||
|
"not run")
|
||||||
|
notrun="$notrun $seq"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
seq="after_$seq"
|
seq="after_$seq"
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user