comparison usr/src/test/zfs-tests/tests/functional/cli_root/zfs_set/canmount_002_pos.ksh @ 13899:0bcf78798346

3311 Want a test framework for arbitrary OS unit tests 3312 Add a testrunner package for OS unit tests 3313 Add a testrunner package to convert ZFS tests from STF Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com> Reviewed by: Will Guyette <will.guyette@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: Henrik Mattson <henrik.mattson@delphix.com> Reviewed by: Sonu Pillai <sonu.pillai@delphix.com> Reviewed by: Christopher Siden <chris.siden@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Richard Lowe <richlowe@richlowe.net>
author John Wren Kennedy <john.kennedy@delphix.com>
date Wed, 05 Dec 2012 22:04:50 -0500
parents
children
comparison
equal deleted inserted replaced
13898:7f822b09519b 13899:0bcf78798346
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 #
29 # Copyright (c) 2012 by Delphix. All rights reserved.
30 #
31
32 . $STF_SUITE/include/libtest.shlib
33 . $STF_SUITE/tests/functional/cli_root/zfs_set/zfs_set_common.kshlib
34
35 #
36 # DESCRIPTION:
37 # Setting valid canmount to filesystem, it is successful.
38 # Whatever is set to volume or snapshot, it is failed.
39 # 'zfs set canmount=noauto <fs>'
40 #
41 # STRATEGY:
42 # 1. Setup a pool and create fs, volume, snapshot clone within it.
43 # 2. Set canmount=noauto for each dataset and check the retuen value
44 # and check if it still can be mounted by mount -a.
45 # 3. mount each dataset(except volume) to see if it can be mounted.
46 #
47
48 verify_runnable "both"
49
50 set -A dataset_pos \
51 "$TESTPOOL/$TESTFS" "$TESTPOOL/$TESTCTR" "$TESTPOOL/$TESTCLONE"
52
53 if is_global_zone ; then
54 set -A dataset_neg \
55 "$TESTPOOL/$TESTVOL" "$TESTPOOL/$TESTFS@$TESTSNAP" \
56 "$TESTPOOL/$TESTVOL@$TESTSNAP" "$TESTPOOL/$TESTCLONE1"
57 else
58 set -A dataset_neg \
59 "$TESTPOOL/$TESTFS@$TESTSNAP" "$TESTPOOL/$TESTVOL@$TESTSNAP"
60 fi
61
62 function cleanup
63 {
64 i=0
65 while (( i < ${#dataset_pos[*]} )); do
66 ds=${dataset_pos[i]}
67 if datasetexists $ds; then
68 log_must $ZFS set mountpoint=${old_mnt[i]} $ds
69 log_must $ZFS set canmount=${old_canmount[i]} $ds
70 fi
71 (( i = i + 1 ))
72 done
73
74 ds=$TESTPOOL/$TESTCLONE
75 if datasetexists $ds; then
76 mntp=$(get_prop mountpoint $ds)
77 log_must $ZFS destroy $ds
78 if [[ -d $mntp ]]; then
79 $RM -fr $mntp
80 fi
81 fi
82
83 if snapexists $TESTPOOL/$TESTFS@$TESTSNAP ; then
84 log_must $ZFS destroy -R $TESTPOOL/$TESTFS@$TESTSNAP
85 fi
86 if snapexists $TESTPOOL/$TESTVOL@$TESTSNAP ; then
87 log_must $ZFS destroy -R $TESTPOOL/$TESTVOL@$TESTSNAP
88 fi
89
90 $ZFS unmount -a > /dev/null 2>&1
91 log_must $ZFS mount -a
92
93 if [[ -d $tmpmnt ]]; then
94 $RM -fr $tmpmnt
95 fi
96 }
97
98 log_assert "Setting canmount=noauto to file system, it must be successful."
99 log_onexit cleanup
100
101 set -A old_mnt
102 set -A old_canmount
103 typeset tmpmnt=/tmpmount$$
104 typeset ds
105
106 log_must $ZFS snapshot $TESTPOOL/$TESTFS@$TESTSNAP
107 log_must $ZFS snapshot $TESTPOOL/$TESTVOL@$TESTSNAP
108 log_must $ZFS clone $TESTPOOL/$TESTFS@$TESTSNAP $TESTPOOL/$TESTCLONE
109 log_must $ZFS clone $TESTPOOL/$TESTVOL@$TESTSNAP $TESTPOOL/$TESTCLONE1
110
111 typeset -i i=0
112 while (( i < ${#dataset_pos[*]} )); do
113 ds=${dataset_pos[i]}
114 old_mnt[i]=$(get_prop mountpoint $ds)
115 old_canmount[i]=$(get_prop canmount $ds)
116 (( i = i + 1 ))
117 done
118
119 i=0
120 while (( i < ${#dataset_pos[*]} )) ; do
121 dataset=${dataset_pos[i]}
122 set_n_check_prop "noauto" "canmount" "$dataset"
123 log_must $ZFS set mountpoint=$tmpmnt $dataset
124 if ismounted $dataset; then
125 $ZFS unmount -a > /dev/null 2>&1
126 log_must mounted $dataset
127 log_must $ZFS unmount $dataset
128 log_must unmounted $dataset
129 log_must $ZFS mount -a
130 log_must unmounted $dataset
131 else
132 log_must $ZFS mount -a
133 log_must unmounted $dataset
134 $ZFS unmount -a > /dev/null 2>&1
135 log_must unmounted $dataset
136 fi
137
138 log_must $ZFS mount $dataset
139 log_must mounted $dataset
140 log_must $ZFS set canmount="${old_canmount[i]}" $dataset
141 log_must $ZFS set mountpoint="${old_mnt[i]}" $dataset
142 (( i = i + 1 ))
143 done
144
145 for dataset in "${dataset_neg[@]}" ; do
146 set_n_check_prop "noauto" "canmount" "$dataset" "false"
147 log_mustnot ismounted $dataset
148 done
149
150 log_pass "Setting canmount=noauto to filesystem pass."