[bzip2-tests] Collect all bad tests file names and results to print at the end.

Mark Wielaard mark@klomp.org
Tue Jan 1 00:00:00 GMT 2019


I added the bzip2-tests to the buildbot, but noticed that when there are
bad results, it isn't immediately clear what exactly failed. So this patch
improves the output of the run-test.sh a bit.

When there are bad tests run-tests.sh will print:

  Bad results, look for !!! in the logs above

To make it easier to see which files/results were bad, collect them and
print them at the end. A bad run will now print something like:

  Bad results, look for !!! in the logs above
   - lbzip2/32767.bz2 bad decompress result
   - lbzip2/incomp-2 md5sum doesn't match
---
 run-tests.sh | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/run-tests.sh b/run-tests.sh
index c07deea..1ba8c27 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -64,6 +64,8 @@ find ${TESTS_DIR} -type f -name \*\.testfilecopy\.bz2 -exec rm \{\} \;
 echo "Testing decompression and recompression..."
 echo
 
+badtests=()
+
 nogood=0
 while IFS= read -r -d '' bzfile; do
   file="${bzfile%.*}"
@@ -78,11 +80,13 @@ while IFS= read -r -d '' bzfile; do
   rm -f "${file}"
   ${VALGRIND} ${VALGRIND_ARGS} ${BZIP2} -k -d -q ${bzfile} \
     || { echo "!!! bad decompress result $?";
+         badtests=("${badtests[@]}" $"${bzfile} bad decompress result")
          nogood=$[${nogood}+1]; continue; }
 
   if [[ ${IGNORE_MD5} -ne 1 ]]; then
     md5sum --check --status ${md5file} < ${file} \
       || { echo "!!! md5sum doesn't match decompressed file";
+           badtests=("${badtests[@]}" $"${file} md5sum doesn't match")
            nogood=$[${nogood}+1]; continue; }
   fi
 
@@ -92,15 +96,18 @@ while IFS= read -r -d '' bzfile; do
   echo "  Recompress..."
   ${VALGRIND} ${VALGRIND_ARGS} ${BZIP2} -z -q -s ${copy} \
     || { echo "!!! bad compress result $?";
+         badtests=("${badtests[@]}" $"${copy} bad result")
          nogood=$[${nogood}+1]; continue; }
   echo "  Redecompress..."
   ${VALGRIND} ${VALGRIND_ARGS} ${BZIP2} -d -q -s ${bzcopy} \
     || { echo "!!! bad (re)decompress result $?";
+         badtests=("${badtests[@]}" $"${bzcopy} bad result")
          nogood=$[${nogood}+1]; continue; }
 
   if [[ ${IGNORE_MD5} -ne 1 ]]; then
     md5sum --check --status ${md5file} < ${copy} \
       || { echo "!!! md5sum doesn't match (re)decompressed file";
+           badtests=("${badtests[@]}" $"${copy} md5sum doesn't match")
            nogood=$[${nogood}+1]; continue; }
   fi
 
@@ -111,11 +118,13 @@ while IFS= read -r -d '' bzfile; do
   rm -f "${file}"
   ${VALGRIND} ${VALGRIND_ARGS} ${BZIP2} -k -d -q -s ${bzfile} \
     || { echo "!!! bad decompress result $?";
+         badtests=("${badtests[@]}" $"${bzfile} bad decompress result")
          nogood=$[${nogood}+1]; continue; }
 
   if [[ ${IGNORE_MD5} -ne 1 ]]; then
     md5sum --check --status ${md5file} < ${file} \
       || { echo "!!! md5sum doesn't match decompressed file";
+           badtests=("${badtests[@]}" $"${file} md5sum doesn't match")
            nogood=$[${nogood}+1]; continue; }
   fi
 
@@ -125,15 +134,18 @@ while IFS= read -r -d '' bzfile; do
   echo "  Recompress (small)..."
   ${VALGRIND} ${VALGRIND_ARGS} ${BZIP2} -z -q -s ${copy} \
     || { echo "!!! bad compress result $?";
+         badtests=("${badtests[@]}" $"${copy} bad result")
          nogood=$[${nogood}+1]; continue; }
   echo "  Redecompress (small)..."
   ${VALGRIND} ${VALGRIND_ARGS} ${BZIP2} -d -q -s ${bzcopy} \
     || { echo "!!! bad (re)decompress result $?";
+         badtests=("${badtests[@]}" $"${bzcopy} bad result")
          nogood=$[${nogood}+1]; continue; }
 
   if [[ ${IGNORE_MD5} -ne 1 ]]; then
     md5sum --check --status ${md5file} < ${copy} \
       || { echo "!!! md5sum doesn't match (re)decompressed file";
+           badtests=("${badtests[@]}" $"${copy} md5sum doesn't match")
            nogood=$[${nogood}+1]; continue; }
   fi
 
@@ -166,6 +178,7 @@ while IFS= read -r -d '' badfile; do
   if [[ ${ret} -eq 0 ]]; then
     echo "!!! badness not detected"
     nobad=$[${nobad}+1]
+    badtests=("${badtests[@]}" $"${badfile} badness not detected")
     continue
   fi
 
@@ -174,6 +187,7 @@ while IFS= read -r -d '' badfile; do
   if [[ ${ret} != 1 ]] && [[ ${ret} != 2 ]]; then
     echo "!!! baddness caused baddness in ${BZIP2}"
     badbad=$[${badbad}+1]
+    badtests=("${badtests[@]}" $"${badfile} badness caused baddness")
     continue
   fi
 
@@ -184,6 +198,7 @@ while IFS= read -r -d '' badfile; do
   if [[ ${ret} -eq 0 ]]; then
     echo "!!! badness not detected"
     nobad=$[${nobad}+1]
+    badtests=("${badtests[@]}" $"${badfile} badness not detected")
     continue
   fi
 
@@ -192,6 +207,7 @@ while IFS= read -r -d '' badfile; do
   if [[ ${ret} != 1 ]] && [[ ${ret} != 2 ]]; then
     echo "!!! baddness caused baddness in ${BZIP2}"
     badbad=$[${badbad}+1]
+    badtests=("${badtests[@]}" $"${badfile} badness caused baddness")
     continue
   fi
 
@@ -217,5 +233,6 @@ if [[ ${results} -eq 0 ]]; then
   exit 0
 else
   echo "Bad results, look for !!! in the logs above"
+  printf ' - %s\n' "${badtests[@]}"
   exit 1
 fi
-- 
1.8.3.1



More information about the Bzip2-devel mailing list