From: Andrew Jones Subject: [kvm-unit-tests PATCH v4 2/6] run scripts need consistent exit status Date: Wed, 2 Mar 2016 18:32:58 +0100 Message-ID: <1456939982-13178-3-git-send-email-drjones@redhat.com> References: <1456939982-13178-1-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: pbonzini@redhat.com, rkrcmar@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:58708 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755282AbcCBRdM (ORCPT ); Wed, 2 Mar 2016 12:33:12 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id B7F6D19CBF2 for ; Wed, 2 Mar 2016 17:33:11 +0000 (UTC) In-Reply-To: <1456939982-13178-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 Reviewed-by: Radim Kr=C4=8Dm=C3=A1=C5=99 --- run_tests.sh | 4 ++-- scripts/mkstandalone.sh | 14 ++++++-------- scripts/runtime.bash | 4 ++-- x86/run | 6 ++---- 4 files changed, 12 insertions(+), 16 deletions(-) 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=3D"no" =20 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=3D"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 @@ =20 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 () =20 echo "$var=3D\`mktemp\`" echo "cleanup=3D\"\$$var \$cleanup\"" - echo "base64 -d << 'BIN_EOF' | zcat > \$$var || exit 1" + echo "base64 -d << 'BIN_EOF' | zcat > \$$var || exit 2" =20 gzip - < $file | base64 =20 @@ -47,8 +47,8 @@ generate_test () =20 if [ ! -f $kernel ]; then echo 'echo "skip '"$testname"' (test kernel not present)"' - echo 'exit 1' - return 1 + echo 'exit 2' + return fi =20 echo "trap 'rm -f \$cleanup' EXIT" @@ -73,11 +73,11 @@ function mkstandalone() local testname=3D"$1" =20 if [ -z "$testname" ]; then - return 1 + return fi =20 if [ -n "$one_testname" ] && [ "$testname" !=3D "$one_testname" ]; th= en - return 1 + return fi =20 standalone=3Dtests/$testname @@ -86,8 +86,6 @@ function mkstandalone() =20 chmod +x $standalone echo Written $standalone. - - return 0 } =20 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() =20 if [ -n "$arch" ] && [ "$arch" !=3D "$ARCH" ]; then echo "skip $1 ($arch only)" - return + return 2 fi =20 # check a file for a particular value before running a test @@ -34,7 +34,7 @@ function run() value=3D${check_param#*=3D} if [ "$path" ] && [ "$(cat $path)" !=3D "$value" ]; then echo "skip $1 ($path not equal to $value)" - return + return 2 fi done =20 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=3D1 -TESTDEVNOTSUPP=3D2 =20 qemubinarysearch=3D"${QEMU:-qemu-kvm qemu-system-x86_64}" =20 @@ -19,11 +17,11 @@ done if [ -z "${QEMUFOUND}" ] then echo "A QEMU binary was not found, You can set a custom location by u= sing the QEMU=3D environment variable " - exit ${NOTFOUND} + exit 2 elif [ -z "${qemu}" ] then echo "No Qemu test device support found" - exit ${TESTDEVNOTSUPP} + exit 2 fi =20 if --=20 2.4.3