]> git.proxmox.com Git - mirror_zfs.git/blame - tests/zfs-tests/tests/functional/cli_root/zfs_mount/zfs_mount_all_fail.ksh
Update ZTS to work on FreeBSD
[mirror_zfs.git] / tests / zfs-tests / tests / functional / cli_root / zfs_mount / zfs_mount_all_fail.ksh
CommitLineData
a10d50f9
SR
1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
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
8# 1.0 of the CDDL.
9#
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.
13#
14# CDDL HEADER END
15#
16
17#
18# Copyright (c) 2017 by Delphix. All rights reserved.
19#
20
21. $STF_SUITE/include/libtest.shlib
22. $STF_SUITE/tests/functional/cli_root/zfs_mount/zfs_mount.kshlib
23
24# DESCRIPTION:
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.
28#
29# STRATEGY:
30# 1. Create zfs filesystems
31# 2. Unmount a leaf filesystem
32# 3. Create a file in the above filesystem's mountpoint
7839c4b5
MM
33# 4. Verify that 'zfs mount -a' fails to mount the above if on Linux
34# or succeeds if on FreeBSD
a10d50f9
SR
35# 5. Verify that all other filesystems were mounted
36#
37
38verify_runnable "both"
39
40typeset -a filesystems
41typeset path=${TEST_BASE_DIR%%/}/testroot$$/$TESTPOOL
42typeset fscount=10
43
44function setup_all
45{
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
49 done
50
51 zfs list -r $TESTPOOL
52
53 return 0
54}
55
56function cleanup_all
57{
58 export __ZFS_POOL_RESTRICT="$TESTPOOL"
59 log_must zfs $unmountall
60 unset __ZFS_POOL_RESTRICT
61
62 [[ -d ${TEST_BASE_DIR%%/}/testroot$$ ]] && \
63 rm -rf ${TEST_BASE_DIR%%/}/testroot$$
64}
65
66log_onexit cleanup_all
67
68log_must setup_all
69
70#
71# Unmount all of the above so that we can create the stray file
72# in one of the mountpoint directories.
73#
74export __ZFS_POOL_RESTRICT="$TESTPOOL"
75log_must zfs $unmountall
76unset __ZFS_POOL_RESTRICT
77
78# All of our filesystems should be unmounted at this point
79for ((i=0; i<$fscount; i++)); do
80 log_mustnot mounted "$TESTPOOL/$i"
81done
82
83# Create a stray file in one filesystem's mountpoint
84touch $path/0/strayfile
85
7839c4b5 86# Verify that zfs mount -a fails on Linux or succeeds on FreeBSD
a10d50f9 87export __ZFS_POOL_RESTRICT="$TESTPOOL"
7839c4b5
MM
88if is_linux; then
89 log_mustnot zfs $mountall
90 log_mustnot mounted "$TESTPOOL/0"
91 typeset behaved="failed"
92else
93 log_must zfs $mountall
94 log_must mounted "$TESTPOOL/0"
95 typeset behaved="succeeded"
96fi
a10d50f9
SR
97unset __ZFS_POOL_RESTRICT
98
7839c4b5 99# All other filesystems should be mounted
a10d50f9
SR
100for ((i=1; i<$fscount; i++)); do
101 log_must mounted "$TESTPOOL/$i"
102done
103
7839c4b5 104log_pass "'zfs $mountall' $behaved as expected."