diff options
author | Dan Streetman <ddstreet@canonical.com> | 2019-08-13 07:50:59 -0400 |
---|---|---|
committer | Dan Streetman <ddstreet@canonical.com> | 2019-08-17 12:28:41 -0400 |
commit | 9e19a8b02848d63b34d68f8ecfdf028ec4ea4833 (patch) | |
tree | 0e056119208dd38a1a79af1958764a0eb7dbb2c7 /test | |
parent | 3a2acd9ee0fa03e8ae2e5865c85ca0268d51b98b (diff) | |
download | systemd-9e19a8b02848d63b34d68f8ecfdf028ec4ea4833.tar.gz |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/test-functions | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/test/test-functions b/test/test-functions index 47a4fa8111..d988ec78da 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 |