Print this page
7290 ZFS test suite needs to control what utilities it can run
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/test/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh
+++ new/usr/src/test/zfs-tests/tests/functional/snapshot/clone_001_pos.ksh
1 1 #! /bin/ksh -p
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
|
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27
28 28 #
29 -# Copyright (c) 2013 by Delphix. All rights reserved.
29 +# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
30 30 #
31 31
32 32 . $STF_SUITE/include/libtest.shlib
33 33 . $STF_SUITE/tests/functional/snapshot/snapshot.cfg
34 34
35 35 #
36 36 # DESCRIPTION:
37 37 # Create a snapshot from regular filesystem, volume,
38 38 # or filesystem upon volume, Build a clone file system
39 39 # from the snapshot and verify new files can be written.
40 40 #
41 41 # STRATEGY:
42 42 # 1. Create snapshot use 3 combination:
43 43 # - Regular filesystem
44 44 # - Regular volume
45 45 # - Filesystem upon volume
46 46 # 2. Clone a new file system from the snapshot
47 47 # 3. Verify the cloned file system is writable
48 48 #
49 49
50 50 verify_runnable "both"
51 51
52 52 # Setup array, 4 elements as a group, refer to:
53 53 # i+0: name of a snapshot
54 54 # i+1: mountpoint of the snapshot
|
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
55 55 # i+2: clone created from the snapshot
56 56 # i+3: mountpoint of the clone
57 57
58 58 set -A args "$SNAPFS" "$SNAPDIR" "$TESTPOOL/$TESTCLONE" "$TESTDIR.0" \
59 59 "$SNAPFS1" "$SNAPDIR3" "$TESTPOOL/$TESTCLONE1" "" \
60 60 "$SNAPFS2" "$SNAPDIR2" "$TESTPOOL1/$TESTCLONE2" "$TESTDIR.2"
61 61
62 62 function setup_all
63 63 {
64 64 create_pool $TESTPOOL1 /dev/zvol/dsk/$TESTPOOL/$TESTVOL
65 - log_must $ZFS create $TESTPOOL1/$TESTFS
66 - log_must $ZFS set mountpoint=$TESTDIR2 $TESTPOOL1/$TESTFS
65 + log_must zfs create $TESTPOOL1/$TESTFS
66 + log_must zfs set mountpoint=$TESTDIR2 $TESTPOOL1/$TESTFS
67 67
68 68 return 0
69 69 }
70 70
71 71 function cleanup_all
72 72 {
73 73 typeset -i i=0
74 74
75 75 i=0
76 76 while (( i < ${#args[*]} )); do
77 77 snapexists ${args[i]} && \
78 - log_must $ZFS destroy -Rf ${args[i]}
78 + log_must zfs destroy -Rf ${args[i]}
79 79
80 80 [[ -d ${args[i+3]} ]] && \
81 - log_must $RM -rf ${args[i+3]}
81 + log_must rm -rf ${args[i+3]}
82 82
83 83 [[ -d ${args[i+1]} ]] && \
84 - log_must $RM -rf ${args[i+1]}
84 + log_must rm -rf ${args[i+1]}
85 85
86 86 (( i = i + 4 ))
87 87 done
88 88
89 89 datasetexists $TESTPOOL1/$TESTFS && \
90 - log_must $ZFS destroy -f $TESTPOOL1/$TESTFS
90 + log_must zfs destroy -f $TESTPOOL1/$TESTFS
91 91
92 92 destroy_pool $TESTPOOL1
93 93
94 94 [[ -d $TESTDIR2 ]] && \
95 - log_must $RM -rf $TESTDIR2
95 + log_must rm -rf $TESTDIR2
96 96
97 97 return 0
98 98 }
99 99
100 100 log_assert "Verify a cloned file system is writable."
101 101
102 102 log_onexit cleanup_all
103 103
104 104 setup_all
105 105
106 106 [[ -n $TESTDIR ]] && \
107 - log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
107 + log_must rm -rf $TESTDIR/* > /dev/null 2>&1
108 108
109 109 typeset -i COUNT=10
110 110 typeset -i i=0
111 111
112 112 for mtpt in $TESTDIR $TESTDIR2 ; do
113 113 log_note "Populate the $mtpt directory (prior to snapshot)"
114 114 typeset -i j=1
115 115 while [[ $j -le $COUNT ]]; do
116 - log_must $FILE_WRITE -o create -f $mtpt/before_file$j \
116 + log_must file_write -o create -f $mtpt/before_file$j \
117 117 -b $BLOCKSZ -c $NUM_WRITES -d $j
118 118
119 119 (( j = j + 1 ))
120 120 done
121 121 done
122 122
123 123 while (( i < ${#args[*]} )); do
124 124 #
125 125 # Take a snapshot of the test file system.
126 126 #
127 - log_must $ZFS snapshot ${args[i]}
127 + log_must zfs snapshot ${args[i]}
128 128
129 129 #
130 130 # Clone a new file system from the snapshot
131 131 #
132 - log_must $ZFS clone ${args[i]} ${args[i+2]}
132 + log_must zfs clone ${args[i]} ${args[i+2]}
133 133 if [[ -n ${args[i+3]} ]] ; then
134 - log_must $ZFS set mountpoint=${args[i+3]} ${args[i+2]}
134 + log_must zfs set mountpoint=${args[i+3]} ${args[i+2]}
135 135
136 - FILE_COUNT=`$LS -Al ${args[i+3]} | $GREP -v "total" \
137 - | $GREP -v "\.zfs" | wc -l`
136 + FILE_COUNT=`ls -Al ${args[i+3]} | grep -v "total" \
137 + | grep -v "\.zfs" | wc -l`
138 138 if [[ $FILE_COUNT -ne $COUNT ]]; then
139 - $LS -Al ${args[i+3]}
139 + ls -Al ${args[i+3]}
140 140 log_fail "AFTER: ${args[i+3]} contains $FILE_COUNT files(s)."
141 141 fi
142 142
143 143 log_note "Verify the ${args[i+3]} directory is writable"
144 144 j=1
145 145 while [[ $j -le $COUNT ]]; do
146 - log_must $FILE_WRITE -o create -f ${args[i+3]}/after_file$j \
146 + log_must file_write -o create -f ${args[i+3]}/after_file$j \
147 147 -b $BLOCKSZ -c $NUM_WRITES -d $j
148 148 (( j = j + 1 ))
149 149 done
150 150
151 - FILE_COUNT=`$LS -Al ${args[i+3]}/after* | $GREP -v "total" | wc -l`
151 + FILE_COUNT=`ls -Al ${args[i+3]}/after* | grep -v "total" | wc -l`
152 152 if [[ $FILE_COUNT -ne $COUNT ]]; then
153 - $LS -Al ${args[i+3]}
153 + ls -Al ${args[i+3]}
154 154 log_fail "${args[i+3]} contains $FILE_COUNT after* files(s)."
155 155 fi
156 156 fi
157 157
158 158 (( i = i + 4 ))
159 159 done
160 160
161 161 log_pass "The clone file system is writable."
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX