diff mbox

[kvm-unit-tests,v3,2/6] run scripts need consistent exit status

Message ID 1456772003-27911-3-git-send-email-drjones@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Jones Feb. 29, 2016, 6:53 p.m. UTC
When a script fails on something build related, e.g. ./configure
hasn't been run, or usage related, e.g. a bad parameter, then an
exit status of 1 makes sense, as no test was attempted. However,
if a test is attempted, then we now need to reserve an exit status
of 1 for QEMU failures. arch-run scripts and standalone generated
run scripts should always use 2, as it's assumed that attempting
to run those attempt to run the test.

(Additional cleanup; remove return values from a couple of
 "void" functions in scripts/mkstandalone)

Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Radim Kr?má? <rkrcmar@redhat.com>
---
 run_tests.sh            |  4 ++--
 scripts/mkstandalone.sh | 14 ++++++--------
 scripts/runtime.bash    |  4 ++--
 x86/run                 |  6 ++----
 4 files changed, 12 insertions(+), 16 deletions(-)
diff mbox

Patch

diff --git a/run_tests.sh b/run_tests.sh
index 2c8af36b2726e..10de5474a0b42 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -4,7 +4,7 @@  verbose="no"
 
 if [ ! -f config.mak ]; then
     echo "run ./configure && make first. See ./configure -h"
-    exit
+    exit 1
 fi
 source config.mak
 source scripts/functions.bash
@@ -41,7 +41,7 @@  while getopts "g:hv" opt; do
             verbose="yes"
             ;;
         *)
-            exit
+            exit 1
             ;;
     esac
 done
diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index c7e78f83fb086..408bb05480b11 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -2,7 +2,7 @@ 
 
 if [ ! -f config.mak ]; then
 	echo "run ./configure && make first. See ./configure -h"
-	exit
+	exit 1
 fi
 source config.mak
 source scripts/functions.bash
@@ -21,7 +21,7 @@  temp_file ()
 
 	echo "$var=\`mktemp\`"
 	echo "cleanup=\"\$$var \$cleanup\""
-	echo "base64 -d << 'BIN_EOF' | zcat > \$$var || exit 1"
+	echo "base64 -d << 'BIN_EOF' | zcat > \$$var || exit 2"
 
 	gzip - < $file | base64
 
@@ -47,8 +47,8 @@  generate_test ()
 
 	if [ ! -f $kernel ]; then
 		echo 'echo "skip '"$testname"' (test kernel not present)"'
-		echo 'exit 1'
-		return 1
+		echo 'exit 2'
+		return
 	fi
 
 	echo "trap 'rm -f \$cleanup' EXIT"
@@ -73,11 +73,11 @@  function mkstandalone()
 	local testname="$1"
 
 	if [ -z "$testname" ]; then
-		return 1
+		return
 	fi
 
 	if [ -n "$one_testname" ] && [ "$testname" != "$one_testname" ]; then
-		return 1
+		return
 	fi
 
 	standalone=tests/$testname
@@ -86,8 +86,6 @@  function mkstandalone()
 
 	chmod +x $standalone
 	echo Written $standalone.
-
-	return 0
 }
 
 trap 'rm -f $cfg' EXIT
diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index 63d1b9653007b..04adb9d070f13 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -23,7 +23,7 @@  function run()
 
     if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
         echo "skip $1 ($arch only)"
-        return
+        return 2
     fi
 
     # check a file for a particular value before running a test
@@ -34,7 +34,7 @@  function run()
         value=${check_param#*=}
         if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then
             echo "skip $1 ($path not equal to $value)"
-            return
+            return 2
         fi
     done
 
diff --git a/x86/run b/x86/run
index bdd7c7e394e45..22d7f2cad0d06 100755
--- a/x86/run
+++ b/x86/run
@@ -1,6 +1,4 @@ 
 #!/bin/bash
-NOTFOUND=1
-TESTDEVNOTSUPP=2
 
 qemubinarysearch="${QEMU:-qemu-kvm qemu-system-x86_64}"
 
@@ -19,11 +17,11 @@  done
 if      [ -z "${QEMUFOUND}" ]
 then
 	echo "A QEMU binary was not found, You can set a custom location by using the QEMU=<path> environment variable "
-	exit ${NOTFOUND}
+	exit 2
 elif    [ -z "${qemu}" ]
 then
 	echo "No Qemu test device support found"
-	exit ${TESTDEVNOTSUPP}
+	exit 2
 fi
 
 if