]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_all_fail.ksh
5 # This file and its contents are supplied under the terms of the
6 # Common Development and Distribution License ("CDDL"), version 1.0.
7 # You may only use this file in accordance with the terms of version
10 # A full copy of the text of the CDDL should have accompanied this
11 # source. A copy of the CDDL is also available via the Internet at
12 # http://www.illumos.org/license/CDDL.
18 # Copyright (c) 2017 by Delphix. All rights reserved.
21 .
$STF_SUITE/include
/libtest.shlib
22 .
$STF_SUITE/tests
/functional
/cli_root
/zfs_mount
/zfs_mount.kshlib
25 # Verify that if 'zfs mount -a' fails to mount one filesystem,
26 # the command fails with a non-zero error code, but all other
27 # filesystems are mounted.
30 # 1. Create zfs filesystems
31 # 2. Unmount a leaf filesystem
32 # 3. Create a file in the above filesystem's mountpoint
33 # 4. Verify that 'zfs mount -a' fails to mount the above if on Linux
34 # or succeeds if on FreeBSD
35 # 5. Verify that all other filesystems were mounted
38 verify_runnable
"both"
40 typeset
-a filesystems
41 typeset path
=${TEST_BASE_DIR%%/}/testroot$$
/$TESTPOOL
46 # Create $fscount filesystems at the top level of $path
47 for ((i
=0; i
<$fscount; i
++)); do
48 setup_filesystem
"$DISKS" "$TESTPOOL" $i "$path/$i" ctr
58 export __ZFS_POOL_RESTRICT
="$TESTPOOL"
59 log_must zfs
$unmountall
60 unset __ZFS_POOL_RESTRICT
62 [[ -d ${TEST_BASE_DIR%%/}/testroot$$
]] && \
63 rm -rf ${TEST_BASE_DIR%%/}/testroot$$
66 log_onexit cleanup_all
71 # Unmount all of the above so that we can create the stray file
72 # in one of the mountpoint directories.
74 export __ZFS_POOL_RESTRICT
="$TESTPOOL"
75 log_must zfs
$unmountall
76 unset __ZFS_POOL_RESTRICT
78 # All of our filesystems should be unmounted at this point
79 for ((i
=0; i
<$fscount; i
++)); do
80 log_mustnot mounted
"$TESTPOOL/$i"
83 # Create a stray file in one filesystem's mountpoint
84 touch $path/0/strayfile
86 # Verify that zfs mount -a fails on Linux or succeeds on FreeBSD
87 export __ZFS_POOL_RESTRICT
="$TESTPOOL"
89 log_mustnot zfs
$mountall
90 log_mustnot mounted
"$TESTPOOL/0"
91 typeset behaved
="failed"
93 log_must zfs
$mountall
94 log_must mounted
"$TESTPOOL/0"
95 typeset behaved
="succeeded"
97 unset __ZFS_POOL_RESTRICT
99 # All other filesystems should be mounted
100 for ((i
=1; i
<$fscount; i
++)); do
101 log_must mounted
"$TESTPOOL/$i"
104 log_pass
"'zfs $mountall' $behaved as expected."