We currently print FAIL for the failure of a succ_* test, but don't
return a failure exit code.  Instead, convert the script to emit
Test Anything Protocol, which gives visibility into each subtest
as well as not relying on exit codes.

Suggested-by: Paolo Bonzini <pbonz...@redhat.com>
Signed-off-by: Richard Henderson <richard.hender...@linaro.org>
---
 tests/decode/check.sh | 36 ++++++++++++++++++++++++++----------
 tests/meson.build     |  1 +
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/tests/decode/check.sh b/tests/decode/check.sh
index 95445a0115..a3d879a099 100755
--- a/tests/decode/check.sh
+++ b/tests/decode/check.sh
@@ -4,21 +4,37 @@
 
 PYTHON=$1
 DECODETREE=$2
-E=0
+E_FILES=`echo err_*.decode`
+S_FILES=`echo succ_*.decode`
 
-# All of these tests should produce errors
-for i in err_*.decode; do
+j=0
+for i in $E_FILES $S_FILES; do
+    j=`expr $j + 1`
+done
+
+echo 1..$j
+
+j=0
+for i in $E_FILES; do
+    j=`expr $j + 1`
+    n=`basename $i .decode`
     if $PYTHON $DECODETREE $i > /dev/null 2> /dev/null; then
-        # Pass, aka failed to fail.
-        echo FAIL: $i 1>&2
-        E=1
+        # Failed to fail.
+        echo not ok $j $n
+    else
+        echo ok $j $n
     fi
 done
 
-for i in succ_*.decode; do
-    if ! $PYTHON $DECODETREE $i > /dev/null 2> /dev/null; then
-        echo FAIL:$i 1>&2
+for i in $S_FILES; do
+    j=`expr $j + 1`
+    n=`basename $i .decode`
+    if $PYTHON $DECODETREE $i > /dev/null 2> /dev/null; then
+        # Succeeded.
+        echo ok $j $n
+    else
+        echo not ok $j $n
     fi
 done
 
-exit $E
+exit 0
diff --git a/tests/meson.build b/tests/meson.build
index 8e318ec513..137ef85ab6 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -77,6 +77,7 @@ endif
 test('decodetree', sh,
      args: [ files('decode/check.sh'), config_host['PYTHON'], 
files('../scripts/decodetree.py') ],
      workdir: meson.current_source_dir() / 'decode',
+     protocol: 'tap', verbose: true,
      suite: 'decodetree')
 
 if 'CONFIG_TCG' in config_all
-- 
2.34.1


Reply via email to