ZTS: zfs_mount_all_fail leaves /var/tmp/testrootPIDNUM directory around

Before we can remove test files, we need to unmount datasets
used by test first.

See also: zfs_mount_all_mountpoints.ksh

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Toomas Soome <tsoome@me.com>
Closes #16914
This commit is contained in:
Toomas Soome 2025-01-02 23:29:12 +02:00 committed by Brian Behlendorf
parent 939e9f0b6a
commit a55b6fe94a

View File

@ -16,6 +16,7 @@
# #
# Copyright (c) 2017 by Delphix. All rights reserved. # Copyright (c) 2017 by Delphix. All rights reserved.
# Copyright 2024 MNX Cloud, Inc.
# #
. $STF_SUITE/include/libtest.shlib . $STF_SUITE/include/libtest.shlib
@ -44,8 +45,9 @@ typeset fscount=10
function setup_all function setup_all
{ {
# Create $fscount filesystems at the top level of $path # Create $fscount filesystems at the top level of $path
for ((i=0; i<$fscount; i++)); do for ((i=0; i<fscount; i++)); do
setup_filesystem "$DISKS" "$TESTPOOL" $i "$path/$i" ctr setup_filesystem "$DISKS" "$TESTPOOL" $i "$path/$i" ctr
filesystems+=($i)
done done
zfs list -r $TESTPOOL zfs list -r $TESTPOOL
@ -58,6 +60,12 @@ function cleanup_all
export __ZFS_POOL_RESTRICT="$TESTPOOL" export __ZFS_POOL_RESTRICT="$TESTPOOL"
log_must zfs $unmountall log_must zfs $unmountall
unset __ZFS_POOL_RESTRICT unset __ZFS_POOL_RESTRICT
# make sure we leave $TESTPOOL mounted
log_must zfs mount $TESTPOOL
for fs in ${filesystems[@]}; do
cleanup_filesystem "$TESTPOOL" "$fs"
done
[[ -d ${TEST_BASE_DIR%%/}/testroot$$ ]] && \ [[ -d ${TEST_BASE_DIR%%/}/testroot$$ ]] && \
rm -rf ${TEST_BASE_DIR%%/}/testroot$$ rm -rf ${TEST_BASE_DIR%%/}/testroot$$
@ -76,7 +84,7 @@ log_must zfs $unmountall
unset __ZFS_POOL_RESTRICT unset __ZFS_POOL_RESTRICT
# All of our filesystems should be unmounted at this point # All of our filesystems should be unmounted at this point
for ((i=0; i<$fscount; i++)); do for ((i=0; i<fscount; i++)); do
log_mustnot mounted "$TESTPOOL/$i" log_mustnot mounted "$TESTPOOL/$i"
done done
@ -98,7 +106,7 @@ log_mustnot mounted "$TESTPOOL/0"
unset __ZFS_POOL_RESTRICT unset __ZFS_POOL_RESTRICT
# All other filesystems should be mounted # All other filesystems should be mounted
for ((i=1; i<$fscount; i++)); do for ((i=1; i<fscount; i++)); do
log_must mounted "$TESTPOOL/$i" log_must mounted "$TESTPOOL/$i"
done done