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