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/snapshot_017_pos.ksh
+++ new/usr/src/test/zfs-tests/tests/functional/snapshot/snapshot_017_pos.ksh
1 1 #!/usr/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]
19 19 #
|
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 # CDDL HEADER END
21 21 #
22 22
23 23 #
24 24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 25 # Use is subject to license terms.
26 26 #
27 27
28 28
29 29 #
30 -# Copyright (c) 2013 by Delphix. All rights reserved.
30 +# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
31 31 #
32 32
33 33 . $STF_SUITE/include/libtest.shlib
34 34 . $STF_SUITE/tests/functional/snapshot/snapshot.cfg
35 35
36 36 #
37 37 # DESCRIPTION:
38 38 #
39 39 # Directory structure of snapshots reflects filesystem structure.
40 40 #
41 41 # STRATEGY:
42 42 #
43 43 # This test makes sure that the directory structure of snapshots is
44 44 # a proper reflection of the filesystem the snapshot was taken of.
45 45 #
46 46 # 1. Create a simple directory structure of files and directories
47 47 # 2. Take a snapshot of the filesystem
48 48 # 3. Modify original filesystem
49 49 # 4. Walk down the snapshot directory structure verifying it
|
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
50 50 # checking with both absolute and relative paths
51 51 #
52 52
53 53 verify_runnable "both"
54 54
55 55 function cleanup
56 56 {
57 57 cd $SAVED_DIR
58 58
59 59 if datasetexists $TESTPOOL/$TESTFS ; then
60 - log_must $ZFS destroy -Rf $TESTPOOL/$TESTFS
60 + log_must zfs destroy -Rf $TESTPOOL/$TESTFS
61 61 fi
62 62
63 - log_must $ZFS create $TESTPOOL/$TESTFS
64 - log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
63 + log_must zfs create $TESTPOOL/$TESTFS
64 + log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
65 65 }
66 66
67 67 function verify_structure {
68 68
69 69 # check absolute paths
70 70 DIR=$PWD
71 71 verify_file $DIR/file1
72 72 verify_file $DIR/file2
73 73 verify_file $DIR/dir1/file3
74 74 verify_file $DIR/dir1/file4
75 75 verify_file $DIR/dir1/dir2/file5
76 76 verify_file $DIR/dir1/dir2/file6
77 77
78 78 verify_no_file $DIR/file99
79 79
80 80 # check relative paths
81 81 verify_file ./file1
82 82 verify_file ./file2
83 83 verify_file ./dir1/file3
84 84 verify_file ./dir1/file4
85 85 verify_file ./dir1/dir2/file5
86 86 verify_file ./dir1/dir2/file6
87 87
88 88 cd dir1
89 89 verify_file ../file1
90 90 verify_file ../file2
91 91 verify_file ./file3
92 92 verify_file ./file4
93 93
94 94 verify_no_file ../file99
95 95
96 96 cd dir2
97 97 verify_file ./file5
98 98 verify_file ./file6
99 99 verify_file ../file3
100 100 verify_file ../file4
101 101 verify_no_file ../file99
102 102
103 103 verify_file ../../file1
104 104 verify_file ../../file2
105 105 verify_no_file ../../file99
106 106 }
107 107
108 108 function verify_file {
109 109 if [ ! -e $1 ]
110 110 then
111 111 log_note "Working dir is $PWD"
112 112 log_fail "File $1 does not exist!"
113 113 fi
114 114 }
115 115
116 116 function verify_no_file {
117 117 if [ -e $1 ]
118 118 then
119 119 log_note "Working dir is $PWD"
120 120 log_fail "File $1 exists when it should not!"
121 121 fi
122 122 }
123 123
124 124 function verify_dir {
125 125 if [ ! -d $1 ]
126 126 then
127 127 log_note "Working dir is $PWD"
128 128 log_fail "Directory $1 does not exist!"
129 129 fi
130 130 }
131 131
132 132 log_assert "Directory structure of snapshots reflects filesystem structure."
133 133 log_onexit cleanup
134 134
135 135 SAVED_DIR=$PWD
136 136
137 137 #
|
↓ open down ↓ |
63 lines elided |
↑ open up ↑ |
138 138 # Create a directory structure with the following files
139 139 #
140 140 # ./file1
141 141 # ./file2
142 142 # ./dir1/file3
143 143 # ./dir1/file4
144 144 # ./dir1/dir2/file5
145 145 # ./dir1/dir2/file6
146 146
147 147 cd $TESTDIR
148 -$MKFILE 10m file1
149 -$MKFILE 20m file2
150 -$MKDIR dir1
148 +mkfile 10m file1
149 +mkfile 20m file2
150 +mkdir dir1
151 151 cd dir1
152 -$MKFILE 10m file3
153 -$MKFILE 20m file4
154 -$MKDIR dir2
152 +mkfile 10m file3
153 +mkfile 20m file4
154 +mkdir dir2
155 155 cd dir2
156 -$MKFILE 10m file5
157 -$MKFILE 20m file6
156 +mkfile 10m file5
157 +mkfile 20m file6
158 158
159 159 # Now walk the directory structure verifying it
160 160 cd $TESTDIR
161 161 verify_structure
162 162
163 163 # Take snapshots
164 -log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap_a
165 -log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap_b
164 +log_must zfs snapshot $TESTPOOL/$TESTFS@snap_a
165 +log_must zfs snapshot $TESTPOOL/$TESTFS@snap_b
166 166
167 167 # Change the filesystem structure by renaming files in the original structure
168 168 # The snapshot file structure should not change
169 169 cd $TESTDIR
170 -log_must $MV file2 file99
170 +log_must mv file2 file99
171 171 cd dir1
172 -log_must $MV file4 file99
172 +log_must mv file4 file99
173 173 cd dir2
174 -log_must $MV file6 file99
174 +log_must mv file6 file99
175 175
176 176 # verify the top level snapshot directories
177 177 verify_dir $TESTDIR/.zfs
178 178 verify_dir $TESTDIR/.zfs/snapshot
179 179 verify_dir $TESTDIR/.zfs/snapshot/snap_a
180 180 verify_dir $TESTDIR/.zfs/snapshot/snap_b
181 181
182 182 cd $TESTDIR/.zfs/snapshot/snap_a
183 183 verify_structure
184 184
185 185 cd $TESTDIR/.zfs/snapshot/snap_b
186 186 verify_structure
187 187
188 188 cd $TESTDIR/.zfs
189 189 verify_dir snapshot
190 190 cd $TESTDIR/.zfs/snapshot
191 191 verify_dir snap_a
192 192 verify_dir snap_b
193 193
194 194 cd snap_a
195 195 verify_dir ../snap_a
196 196 verify_dir ../snap_b
197 197
198 198 cd ..
199 199 verify_dir snap_a
200 200 verify_dir snap_b
201 201
202 202 log_pass "Directory structure of snapshots reflects filesystem structure."
|
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX