All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>, "Thomas Huth" <thuth@redhat.com>,
	"open list:Block layer core" <qemu-block@nongnu.org>,
	"Max Reitz" <mreitz@redhat.com>,
	qemu-arm@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: [Qemu-devel] [PATCH v2 27/28] tests/qemu-iotests: re-format output to for make check-block
Date: Thu, 23 May 2019 11:25:31 +0100	[thread overview]
Message-ID: <20190523102532.10486-28-alex.bennee@linaro.org> (raw)
In-Reply-To: <20190523102532.10486-1-alex.bennee@linaro.org>

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>

---
v3
  - revert echo to printf
  - add _report_test_start
v4
  - -pretty -> -makecheck
  - keep all output together for makecheck
v5
  - merged in kwolf's pretty printing
  - timestamps always printed in non-makecheck mode
---
 tests/qemu-iotests/check | 179 +++++++++++++++++++++++++--------------
 1 file changed, 116 insertions(+), 63 deletions(-)

diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 922c5d1d3d3..f46b90dbbf4 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -27,9 +27,7 @@ bad=""
 notrun=""
 casenotrun=""
 interrupt=true
-
-# by default don't output timestamps
-timestamp=${TIMESTAMP:=false}
+makecheck=false
 
 _init_error()
 {
@@ -88,6 +86,22 @@ _full_platform_details()
     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
 set_prog_path()
 {
@@ -254,8 +268,8 @@ other options
     -misalign           misalign memory allocations
     -n                  show me, do not run tests
     -o options          -o options to pass to qemu-img create/convert
-    -T                  output timestamps
     -c mode             cache mode
+    -makecheck          pretty print output for make check
 
 testlist options
     -g group[,group...]        include tests from these groups
@@ -403,7 +417,10 @@ testlist options
                 command -v xxdiff >/dev/null 2>&1 && diff=xxdiff
             fi
             ;;
-
+        -makecheck)   # makecheck friendly output
+            makecheck=true
+            xpand=false
+            ;;
         -n)        # show me, don't do it
             showme=true
             xpand=false
@@ -416,11 +433,6 @@ testlist options
             cachemode=true
             xpand=false
             ;;
-        -T)        # turn on timestamp output
-            timestamp=true
-            xpand=false
-            ;;
-
         -v)
             verbose=true
             xpand=false
@@ -633,12 +645,6 @@ _wallclock()
     date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }'
 }
 
-_timestamp()
-{
-    now=$(date "+%T")
-    printf %s " [$now]"
-}
-
 _wrapup()
 {
     if $showme
@@ -704,23 +710,54 @@ END        { if (NR > 0) {
 
 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
 
 FULL_IMGFMT_DETAILS=$(_full_imgfmt_details)
 FULL_HOST_DETAILS=$(_full_platform_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
+if ! $makecheck; then
+    _full_env_details
+fi
 
 seq="check"
 
@@ -728,42 +765,43 @@ seq="check"
 
 for seq in $list
 do
-    err=false
-    printf %s "$seq"
+    err=false       # error flag
+    printdiff=false # show diff to reference output?
+    status=""       # test result summary
+    results=""      # test result details
+
     if [ -n "$TESTS_REMAINING_LOG" ] ; then
         sed -e "s/$seq//" -e 's/  / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
         mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
         sync
     fi
 
+    lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE)
+    starttime=$(date "+%T")
+    _report_test_start $seq $starttime $lasttime
+
     if $showme
     then
-        echo
-        continue
+        status="not run"
     elif [ -f expunged ] && $expunge && egrep "^$seq([         ]|\$)" expunged >/dev/null
     then
-        echo " - expunged"
+        status="not run"
+        results="expunged"
         rm -f $seq.out.bad
         echo "/^$seq\$/d" >>$tmp.expunged
     elif [ ! -f "$source_iotests/$seq" ]
     then
-        echo " - no such test?"
+        status="not run"
+        results="no such test?"
         echo "/^$seq\$/d" >>$tmp.expunged
     else
         # really going to try and run this one
         #
         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 $seq.casenotrun
 
         start=$(_wallclock)
-        $timestamp && printf %s "        [$(date "+%T")]"
 
         if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
             run_command="$PYTHON $seq"
@@ -781,26 +819,26 @@ do
                     $run_command >$tmp.out 2>&1)
         fi
         sts=$?
-        $timestamp && _timestamp
         stop=$(_wallclock)
 
         if [ -f core ]
         then
-            printf " [dumped core]"
             mv core $seq.core
+            status="fail"
+            results="[dumped core] $seq.core"
             err=true
         fi
 
         if [ -f $seq.notrun ]
         then
-            $timestamp || printf " [not run] "
-            $timestamp && echo " [not run]" && printf %s "        $seq -- "
-            cat $seq.notrun
-            notrun="$notrun $seq"
+            # overwrites timestamp output
+            status="not run"
+            results="$(cat $seq.notrun)"
         else
             if [ $sts -ne 0 ]
             then
-                printf %s " [failed, exit status $sts]"
+                status="fail"
+                results=$(printf %s "[failed, exit status $sts]")
                 err=true
             fi
 
@@ -821,22 +859,23 @@ do
 
             if [ ! -f "$reference" ]
             then
-                echo " - no qualified output"
+                status="fail"
+                reason="no qualified output"
                 err=true
             else
                 if diff -w "$reference" $tmp.out >/dev/null 2>&1
                 then
-                    echo ""
-                    if $err
-                    then
-                        :
-                    else
-                        echo "$seq $(expr $stop - $start)" >>$tmp.time
+                    if ! $err; then
+                        status="pass"
+                        thistime=$(expr $stop - $start)
+                        echo "$seq $thistime" >>$tmp.time
                     fi
                 else
-                    echo " - output mismatch (see $seq.out.bad)"
                     mv $tmp.out $seq.out.bad
                     $diff -w "$reference" "$PWD"/$seq.out.bad
+                    status="fail"
+                    results="output mismatch (see $seq.out.bad)"
+                    printdiff=true
                     err=true
                 fi
             fi
@@ -850,13 +889,27 @@ do
 
     # come here for each test, except when $showme is true
     #
-    if $err
-    then
-        bad="$bad $seq"
-        n_bad=$(expr $n_bad + 1)
-        quick=false
-    fi
-    [ -f $seq.notrun ] || try=$(expr $try + 1)
+    _report_test_result $seq "$status" "$starttime" "$lasttime" "$thistime" "$results"
+    case "$status" in
+        "pass")
+            try=$(expr $try + 1)
+            ;;
+        "fail")
+            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"
 done
-- 
2.20.1



  parent reply	other threads:[~2019-05-23 10:50 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23 10:25 [Qemu-devel] [PATCH v2 00/28] current testing/next queue Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 01/28] semihosting: move semihosting configuration into its own directory Alex Bennée
2019-05-23 15:12   ` Richard Henderson
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 02/28] semihosting: introduce CONFIG_SEMIHOSTING Alex Bennée
2019-05-23 15:12   ` Richard Henderson
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 03/28] semihosting: implement a semihosting console Alex Bennée
2019-05-23 13:13   ` Peter Maydell
2019-05-24 10:46     ` Alex Bennée
2019-05-24 10:56       ` Peter Maydell
2019-05-24 11:25         ` Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 04/28] semihosting: enable chardev backed output for console Alex Bennée
2019-05-23 15:16   ` Richard Henderson
2019-05-28  9:36     ` Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 05/28] target/arm: fixup some of the commentary for arm-semi Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 06/28] target/arm: use the common interface for WRITE0/WRITEC in arm-semi Alex Bennée
2019-05-23 15:12   ` Richard Henderson
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 07/28] target/arm: add LOG_UNIMP messages to arm-semi Alex Bennée
2019-05-23 15:18   ` Richard Henderson
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 08/28] target/arm: correct return values for WRITE/READ in arm-semi Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 09/28] target/mips: only build mips-semi for softmmu Alex Bennée
2019-05-23 19:52   ` Richard Henderson
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 10/28] target/mips: convert UHI_plog to use common semihosting code Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 11/28] MAINTAINERS: update for semihostings new home Alex Bennée
2019-05-23 19:55   ` Richard Henderson
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 12/28] tests/docker: add ubuntu 18.04 Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 13/28] tests/docker: Test more components on the Fedora default image Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 14/28] tests/tcg/multiarch: add support for multiarch system tests Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 15/28] tests/tcg/multiarch: add hello world system test Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 16/28] editorconfig: add settings for .s/.S files Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 17/28] tests/tcg/aarch64: add system boot.S Alex Bennée
2019-05-23 20:10   ` Richard Henderson
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 18/28] tests/tcg/multiarch: move the system memory test Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 19/28] tests/tcg/minilib: support %c format char Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 20/28] tests/tcg/multiarch: expand system memory test to cover more Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 21/28] tests/tcg/alpha: add system boot.S Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 22/28] .travis.yml: enable aarch64-softmmu and alpha-softmmu tcg tests Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 23/28] Makefile: fix coverage-report reference to BUILD_DIR Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 24/28] Makefile: include per-target build directories in coverage report Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 25/28] Makefile.target: support per-target coverage reports Alex Bennée
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 26/28] tests/qemu-iotests/group: Re-use the "auto" group for tests that can always run Alex Bennée
2019-05-23 10:25 ` Alex Bennée [this message]
2019-05-27 13:43   ` [Qemu-devel] [PATCH v2 27/28] tests/qemu-iotests: re-format output to for make check-block Max Reitz
2019-05-27 16:20     ` Alex Bennée
2019-05-27 16:53       ` Max Reitz
2019-05-23 10:25 ` [Qemu-devel] [PATCH v2 28/28] tests: Run the iotests during "make check" again Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190523102532.10486-28-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.