From 7d92af4eac386001b46b8f1a98e8ccb95ca1a225 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Fri, 16 Feb 2018 11:29:12 +0100 Subject: tests: run-tests-in-vagrant.sh should return test status The ./run-tests-in-vagrant.sh script does not return the correct exit status. Even if the tests in the Vagrant VM fail, the script returns success. This throws off the expectations that any regular testers (or CI) have. BUG: 1546103 Change-Id: I7f00903f9fe4ef3be8ba80db0f9aa8d412502b86 Signed-off-by: Niels de Vos --- run-tests-in-vagrant.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/run-tests-in-vagrant.sh b/run-tests-in-vagrant.sh index f7838f4732a..c72364a21c8 100755 --- a/run-tests-in-vagrant.sh +++ b/run-tests-in-vagrant.sh @@ -111,8 +111,10 @@ function set_branchname_from_git_branch() } -function destroy_vm_and_exit() +function destroy_vm() { + local retval=0 + echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!CAUTION!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "This will destroy VM and delete tests/vagrant/${BRANCHNAME} dir" echo @@ -128,11 +130,12 @@ function destroy_vm_and_exit() eval vagrant destroy $redirect popd rm -rf "tests/vagrant/${BRANCHNAME}" - exit 0 else echo "Could not find vagrant dir for corresponding git branch, exiting" - exit 1 + retval=1 fi + + return ${retval} } @@ -248,9 +251,14 @@ function compile_gluster() function run_tests() { + local retval=0 + pushd "tests/vagrant/${BRANCHNAME}" vagrant ssh -c "cd /home/vagrant/glusterfs; sudo ./run-tests.sh $run_tests_args" -- -t + retval=$? popd + + return ${retval} } function ssh_into_vm_using_exec() @@ -272,7 +280,8 @@ ansible_check set_branchname_from_git_branch if [ "x$destroy_now" == "xyes" ] ; then - destroy_vm_and_exit + destroy_vm + exit $? fi if [ "x$sshvm" == "xyes" ] ; then @@ -289,7 +298,10 @@ set_vm_attributes copy_source_code compile_gluster run_tests +RET=$? if [ "x$destroy_after_test" == "xyes" ] ; then - destroy_vm_and_exit + destroy_vm fi + +exit ${RET} -- cgit