From: Dan Streetman Date: Tue, 13 Aug 2019 11:50:59 +0000 (-0400) Subject: test/test-functions: avoid stderr noise, only umount on cleanup if mountpoint X-Git-Tag: v243-rc2~22^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9e19a8b02848d63b34d68f8ecfdf028ec4ea4833;p=thirdparty%2Fsystemd.git test/test-functions: avoid stderr noise, only umount on cleanup if mountpoint Only umount it during cleanup if the $TESTDIR/root dir is a mountpoint. This avoids adding noise to the stderr log such as: mountpoint: /var/tmp/systemd-test.waLOFT/root: No such file or directory --- diff --git a/test/test-functions b/test/test-functions index 47a4fa81116..d988ec78da7 100644 --- a/test/test-functions +++ b/test/test-functions @@ -1668,12 +1668,16 @@ setup_suse() { inst_simple "/usr/lib/systemd/system/haveged.service" } +_umount_dir() { + if mountpoint -q $1; then + ddebug "umount $1" + umount $1 + fi +} + _test_setup_cleanup() { # only umount if create_empty_image_rootdir() was called to mount it - if [[ $TEST_SETUP_CLEANUP_ROOTDIR ]]; then - ddebug "umount $TESTDIR/root" - umount $TESTDIR/root - fi + [[ -z $TEST_SETUP_CLEANUP_ROOTDIR ]] || _umount_dir $TESTDIR/root } # can be overridden in specific test @@ -1685,10 +1689,7 @@ _test_cleanup() { # (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 + _umount_dir $TESTDIR/root if [[ $LOOPDEV && -b $LOOPDEV ]]; then ddebug "losetup -d $LOOPDEV" losetup -d $LOOPDEV