]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test/test-functions: avoid stderr noise, only umount on cleanup if mountpoint
authorDan Streetman <ddstreet@canonical.com>
Tue, 13 Aug 2019 11:50:59 +0000 (07:50 -0400)
committerDan Streetman <ddstreet@canonical.com>
Sat, 17 Aug 2019 16:28:41 +0000 (12:28 -0400)
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

test/test-functions

index 47a4fa81116181008a7f15b714e84525a5f9b4f2..d988ec78da7a026768b68baa289f8a165a14400b 100644 (file)
@@ -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