Fix run_test.sh failure logic
The script looks for PASS/SKIP/FAIL in the output and if found, it
returns the error code it got from QEMU. But a failing test still
returns zero because the emulation was sucessful.
Split grepping for PASS/SKIP and FAIL, and force a non-zero return code
for the latter.
Test: make failing-test
Change-Id: I62ba1ab522a9544024882e276161905f7cf84c1f
diff --git a/kvm-unit-tests/run_test.sh b/kvm-unit-tests/run_test.sh
index afd7c4b..832be7f 100755
--- a/kvm-unit-tests/run_test.sh
+++ b/kvm-unit-tests/run_test.sh
@@ -165,8 +165,16 @@
"${CMD[@]}" &> "${OUTPUT}"
EXIT_STATUS=$?
- RESULT=$(grep -E -h --color=never "[^ ](PASS|FAIL|SKIP)[^:]" "${OUTPUT}")
- if [ -z "${RESULT}" ]; then
+ PASS=$(grep -E -h --color=never "[^ ](PASS|SKIP)[^:]" "${OUTPUT}")
+ FAIL=$(grep -E -h --color=never "[^ ]FAIL[^:]" "${OUTPUT}")
+
+ # Check FAIL eagerly.
+ if [ -n "${FAIL}" ]; then
+ RESULT="${FAIL}"
+ EXIT_STATUS=1
+ elif [ -n "${PASS}" ]; then
+ RESULT="${PASS}"
+ else
RESULT="\e[31;1mTIMEOUT/CRASH\e[0m"
EXIT_STATUS=1
fi