diff options
author | Dan Streetman <ddstreet@canonical.com> | 2019-07-12 14:09:48 -0400 |
---|---|---|
committer | Dan Streetman <ddstreet@canonical.com> | 2019-07-16 18:05:15 -0400 |
commit | f85bc044e5c2d862d86b9dd0fcef5e8aa2928f06 (patch) | |
tree | d90bbfe6195da87085fc082f647c8651bbc016c7 | |
parent | ec4cab49c95d03d23cad9741685f3837a8ccaab4 (diff) | |
download | systemd-f85bc044e5c2d862d86b9dd0fcef5e8aa2928f06.tar.gz systemd-f85bc044e5c2d862d86b9dd0fcef5e8aa2928f06.tar.bz2 systemd-f85bc044e5c2d862d86b9dd0fcef5e8aa2928f06.zip |
test: ignore errors during test cleanup, so cleanup can finish
Also move TESTDIR and STATEFILE removal into test_cleanup
-rwxr-xr-x | test/TEST-02-CRYPTSETUP/test.sh | 3 | ||||
-rw-r--r-- | test/test-functions | 32 |
2 files changed, 18 insertions, 17 deletions
diff --git a/test/TEST-02-CRYPTSETUP/test.sh b/test/TEST-02-CRYPTSETUP/test.sh index e28cec0340..2dd2cce6e5 100755 --- a/test/TEST-02-CRYPTSETUP/test.sh +++ b/test/TEST-02-CRYPTSETUP/test.sh @@ -83,7 +83,8 @@ cleanup_root_var() { } test_cleanup() { - cleanup_root_var + # ignore errors, so cleanup can continue + cleanup_root_var || true _test_cleanup } diff --git a/test/test-functions b/test/test-functions index f652e82dd0..17cb22be76 100644 --- a/test/test-functions +++ b/test/test-functions @@ -1706,14 +1706,20 @@ test_setup_cleanup() { } _test_cleanup() { - if mountpoint $TESTDIR/root; then - ddebug "umount $TESTDIR/root" - umount $TESTDIR/root - fi - if [[ $LOOPDEV && -b $LOOPDEV ]]; then - ddebug "losetup -d $LOOPDEV" - losetup -d $LOOPDEV - fi + # (post-test) cleanup should always ignore failure and cleanup as much as possible + ( + set +e + if mountpoint $TESTDIR/root; then + ddebug "umount $TESTDIR/root" + umount $TESTDIR/root + fi + if [[ $LOOPDEV && -b $LOOPDEV ]]; then + ddebug "losetup -d $LOOPDEV" + losetup -d $LOOPDEV + fi + rm -fr "$TESTDIR" + rm -f "$STATEFILE" + ) || true } # can be overridden in specific test @@ -1787,22 +1793,16 @@ do_test() { --clean) echo "TEST CLEANUP: $TEST_DESCRIPTION" test_cleanup - rm -fr "$TESTDIR" - rm -f "$STATEFILE" ;; --all) ret=0 - echo -n "TEST: $TEST_DESCRIPTION "; + echo -n "TEST: $TEST_DESCRIPTION " ( test_setup test_setup_cleanup test_run - ret=$? - test_cleanup - rm -fr "$TESTDIR" - rm -f "$STATEFILE" - exit $ret ) </dev/null >"$TESTLOG" 2>&1 || ret=$? + test_cleanup if [ $ret -eq 0 ]; then rm "$TESTLOG" echo "[OK]" |