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_006_pos.ksh
+++ new/usr/src/test/zfs-tests/tests/functional/snapshot/snapshot_006_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 2007 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 # An archive of a zfs dataset and an archive of its snapshot
38 38 # changed sinced the snapshot was taken.
39 39 #
40 40 # STRATEGY:
41 41 # 1) Create some files in a ZFS dataset
42 42 # 2) Create a tarball of the dataset
43 43 # 3) Create a snapshot of the dataset
44 44 # 4) Remove all the files in the original dataset
45 45 # 5) Create a tarball of the snapshot
46 46 # 6) Extract each tarball and compare directory structures
47 47 #
48 48
|
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
49 49 verify_runnable "both"
50 50
51 51 function cleanup
52 52 {
53 53 if [[ -d $CWD ]]; then
54 54 cd $CWD || log_fail "Could not cd $CWD"
55 55 fi
56 56
57 57 snapexists $SNAPCTR
58 58 if [[ $? -eq 0 ]]; then
59 - log_must $ZFS destroy $SNAPCTR
59 + log_must zfs destroy $SNAPCTR
60 60 fi
61 61
62 62 if [[ -e $SNAPDIR1 ]]; then
63 - log_must $RM -rf $SNAPDIR1 > /dev/null 2>&1
63 + log_must rm -rf $SNAPDIR1 > /dev/null 2>&1
64 64 fi
65 65
66 66 if [[ -e $TESTDIR1 ]]; then
67 - log_must $RM -rf $TESTDIR1/* > /dev/null 2>&1
67 + log_must rm -rf $TESTDIR1/* > /dev/null 2>&1
68 68 fi
69 69
70 70 if [[ -e /tmp/zfs_snapshot2.$$ ]]; then
71 - log_must $RM -rf /tmp/zfs_snapshot2.$$ > /dev/null 2>&1
71 + log_must rm -rf /tmp/zfs_snapshot2.$$ > /dev/null 2>&1
72 72 fi
73 73
74 74 }
75 75
76 76 log_assert "Verify that an archive of a dataset is identical to " \
77 77 "an archive of the dataset's snapshot."
78 78
79 79 log_onexit cleanup
80 80
81 81 typeset -i COUNT=21
82 82 typeset OP=create
83 83
84 -[[ -n $TESTDIR1 ]] && $RM -rf $TESTDIR1/* > /dev/null 2>&1
84 +[[ -n $TESTDIR1 ]] && rm -rf $TESTDIR1/* > /dev/null 2>&1
85 85
86 86 log_note "Create files in the zfs dataset ..."
87 87
88 88 typeset i=1
89 89 while [ $i -lt $COUNT ]; do
90 - log_must $FILE_WRITE -o $OP -f $TESTDIR1/file$i \
90 + log_must file_write -o $OP -f $TESTDIR1/file$i \
91 91 -b $BLOCKSZ -c $NUM_WRITES -d $DATA
92 92
93 93 (( i = i + 1 ))
94 94 done
95 95
96 96 log_note "Create a tarball from $TESTDIR1 contents..."
97 97 CWD=$PWD
98 98 cd $TESTDIR1 || log_fail "Could not cd $TESTDIR1"
99 -log_must $TAR cf $TESTDIR1/tarball.original.tar file*
99 +log_must tar cf $TESTDIR1/tarball.original.tar file*
100 100 cd $CWD || log_fail "Could not cd $CWD"
101 101
102 102 log_note "Create a snapshot and mount it..."
103 -log_must $ZFS snapshot $SNAPCTR
103 +log_must zfs snapshot $SNAPCTR
104 104
105 105 log_note "Remove all of the original files..."
106 -log_must $RM -f $TESTDIR1/file* > /dev/null 2>&1
106 +log_must rm -f $TESTDIR1/file* > /dev/null 2>&1
107 107
108 108 log_note "Create tarball of snapshot..."
109 109 CWD=$PWD
110 110 cd $SNAPDIR1 || log_fail "Could not cd $SNAPDIR1"
111 -log_must $TAR cf $TESTDIR1/tarball.snapshot.tar file*
111 +log_must tar cf $TESTDIR1/tarball.snapshot.tar file*
112 112 cd $CWD || log_fail "Could not cd $CWD"
113 113
114 -log_must $MKDIR $TESTDIR1/original
115 -log_must $MKDIR $TESTDIR1/snapshot
114 +log_must mkdir $TESTDIR1/original
115 +log_must mkdir $TESTDIR1/snapshot
116 116
117 117 CWD=$PWD
118 118 cd $TESTDIR1/original || log_fail "Could not cd $TESTDIR1/original"
119 -log_must $TAR xf $TESTDIR1/tarball.original.tar
119 +log_must tar xf $TESTDIR1/tarball.original.tar
120 120
121 121 cd $TESTDIR1/snapshot || log_fail "Could not cd $TESTDIR1/snapshot"
122 -log_must $TAR xf $TESTDIR1/tarball.snapshot.tar
122 +log_must tar xf $TESTDIR1/tarball.snapshot.tar
123 123
124 124 cd $CWD || log_fail "Could not cd $CWD"
125 125
126 -$DIRCMP $TESTDIR1/original $TESTDIR1/snapshot > /tmp/zfs_snapshot2.$$
127 -$GREP different /tmp/zfs_snapshot2.$$ >/dev/null 2>&1
126 +dircmp $TESTDIR1/original $TESTDIR1/snapshot > /tmp/zfs_snapshot2.$$
127 +grep different /tmp/zfs_snapshot2.$$ >/dev/null 2>&1
128 128 if [[ $? -ne 1 ]]; then
129 129 log_fail "Directory structures differ."
130 130 fi
131 131
132 132 log_pass "Directory structures match."
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX