Merge "Ignore missing path in unmount_dir"

This commit is contained in:
Jenkins 2017-04-07 15:59:47 +00:00 committed by Gerrit Code Review
commit 347833856e
3 changed files with 11 additions and 5 deletions

View File

@ -346,7 +346,7 @@ function unmount_dir {
if [ ! -d $dir ]; then
echo "*** $dir is not a directory"
return 1
return 0
fi
# get rid of any symlink elements in the incoming path, because

View File

@ -121,9 +121,7 @@ function finalise_base () {
fi
fi
# Cleanup /tmp in the guest, so there is less cruft left there
if [ -d "$TMP_MOUNT_PATH/tmp" ]; then
unmount_dir $TMP_MOUNT_PATH/tmp
fi
find $TMP_MOUNT_PATH/tmp -maxdepth 1 -mindepth 1 | xargs sudo rm -rf --one-file-system
# Truncate /var/log files in preparation for first boot
sudo find ${TMP_MOUNT_PATH}/var/log -type f -exec cp /dev/null '{}' \;

View File

@ -6,7 +6,7 @@
# need a human in the loop. Thus it's mostly useful for developers
# during testing, but not so great for CI
source ../lib/common-functions
source ../diskimage_builder/lib/common-functions
#
# Directory mounting and unmounting
@ -44,6 +44,14 @@ else
echo "*** PASS all directories unmounted"
fi
# unmount missing dir
if unmount_dir /this/path/does/not/exist/but/this/should/not/fail; then
echo "*** PASS unmount_dir ignored a missing path"
else
echo "*** FAILED unmount_dir should ignore missing paths"
return 1
fi
# cleanup
rm -rf $TMP_DIR