diff --git a/test/integration-test-common.sh b/test/integration-test-common.sh index 8236820..a9a2d15 100644 --- a/test/integration-test-common.sh +++ b/test/integration-test-common.sh @@ -103,25 +103,22 @@ fi # This function execute the function parameters $1 times # before giving up, with 1 second delays. function retry { - set +o errexit N=$1; shift; - status=0 + rc=0 for i in $(seq $N); do echo "Trying: $*" - eval $@ - status=$? - if [ $status == 0 ]; then + eval $@ && rc=$? || rc=$? + if [ $rc == 0 ]; then break fi sleep 1 echo "Retrying: $*" done - if [ $status != 0 ]; then + if [ $rc != 0 ]; then echo "timeout waiting for $*" fi - set -o errexit - return $status + return $rc } # Proxy is not started if S3PROXY_BINARY is an empty string @@ -268,20 +265,18 @@ function start_s3fs { rm -f pid if [ `uname` = "Darwin" ]; then - set +o errexit TRYCOUNT=0 while [ $TRYCOUNT -le ${RETRIES:=20} ]; do - df | grep -q $TEST_BUCKET_MOUNT_POINT_1 - if [ $? -eq 0 ]; then + df | grep -q $TEST_BUCKET_MOUNT_POINT_1 && rc=$? || rc=$? + if [ $rc -eq 0 ]; then break; fi sleep 1 TRYCOUNT=`expr ${TRYCOUNT} + 1` done - if [ $? -ne 0 ]; then + if [ $rc -ne 0 ]; then exit 1 fi - set -o errexit else retry ${RETRIES:=20} grep -q $TEST_BUCKET_MOUNT_POINT_1 /proc/mounts || exit 1 fi diff --git a/test/test-utils.sh b/test/test-utils.sh index b6c2774..da5fcc8 100644 --- a/test/test-utils.sh +++ b/test/test-utils.sh @@ -235,22 +235,12 @@ function run_suite { key_prefix="testrun-$RANDOM" cd_run_dir $key_prefix for t in "${TEST_LIST[@]}"; do - # The following sequence runs tests in a subshell to allow continuation - # on test failure, but still allowing errexit to be in effect during - # the test. - # - # See: - # https://groups.google.com/d/msg/gnu.bash.bug/NCK_0GmIv2M/dkeZ9MFhPOIJ - # Other ways of trying to capture the return value will also disable - # errexit in the function due to bash... compliance with POSIX? - set +o errexit - (set -o errexit; $t $key_prefix) - if [[ $? == 0 ]]; then + $t $key_prefix && rc=$? || rc=$? + if [[ $rc == 0 ]] ; then report_pass $t else report_fail $t fi - set -o errexit done cd ${orig_dir} clean_run_dir