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_011_pos.ksh
+++ new/usr/src/test/zfs-tests/tests/functional/snapshot/snapshot_011_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 # use 'snapshot -r' to create a snapshot tree, add some files to one child
38 38 # filesystem, rollback the child filesystem snapshot, verify that the child
39 39 # filesystem gets back to the status while taking the snapshot.
40 40 #
41 41 # STRATEGY:
42 42 # 1. Add some files to a target child filesystem
43 43 # 2. snapshot -r the parent filesystem
44 44 # 3. Add some other files to the target child filesystem
|
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
45 45 # 4. rollback the child filesystem snapshot
46 46 # 5. verify that the child filesystem get back to the status while being
47 47 # snapshot'd
48 48 #
49 49
50 50 verify_runnable "both"
51 51
52 52 function cleanup
53 53 {
54 54 snapexists $SNAPPOOL && \
55 - log_must $ZFS destroy -r $SNAPPOOL
55 + log_must zfs destroy -r $SNAPPOOL
56 56
57 57 [[ -e $TESTDIR ]] && \
58 - log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
58 + log_must rm -rf $TESTDIR/* > /dev/null 2>&1
59 59 }
60 60
61 61 log_assert "Verify that rollback to a snapshot created by snapshot -r succeeds."
62 62 log_onexit cleanup
63 63
64 64 [[ -n $TESTDIR ]] && \
65 - log_must $RM -rf $TESTDIR/* > /dev/null 2>&1
65 + log_must rm -rf $TESTDIR/* > /dev/null 2>&1
66 66
67 67 typeset -i COUNT=10
68 68
69 69 log_note "Populate the $TESTDIR directory (prior to snapshot)"
70 70 typeset -i i=0
71 71 while (( i < COUNT )); do
72 - log_must $FILE_WRITE -o create -f $TESTDIR/before_file$i \
72 + log_must file_write -o create -f $TESTDIR/before_file$i \
73 73 -b $BLOCKSZ -c $NUM_WRITES -d $i
74 74
75 75 (( i = i + 1 ))
76 76 done
77 77
78 -log_must $ZFS snapshot -r $SNAPPOOL
78 +log_must zfs snapshot -r $SNAPPOOL
79 79
80 -FILE_COUNT=`$LS -Al $SNAPDIR | $GREP -v "total" | wc -l`
80 +FILE_COUNT=`ls -Al $SNAPDIR | grep -v "total" | wc -l`
81 81 if (( FILE_COUNT != COUNT )); then
82 - $LS -Al $SNAPDIR
82 + ls -Al $SNAPDIR
83 83 log_fail "AFTER: $SNAPFS contains $FILE_COUNT files(s)."
84 84 fi
85 85
86 86 log_note "Populate the $TESTDIR directory (post snapshot)"
87 87 typeset -i i=0
88 88 while (( i < COUNT )); do
89 - log_must $FILE_WRITE -o create -f $TESTDIR/after_file$i \
89 + log_must file_write -o create -f $TESTDIR/after_file$i \
90 90 -b $BLOCKSZ -c $NUM_WRITES -d $i
91 91
92 92 (( i = i + 1 ))
93 93 done
94 94
95 95 #
96 96 # Now rollback to latest snapshot
97 97 #
98 -log_must $ZFS rollback $SNAPFS
98 +log_must zfs rollback $SNAPFS
99 99
100 -FILE_COUNT=`$LS -Al $TESTDIR/after* 2> /dev/null | $GREP -v "total" | wc -l`
100 +FILE_COUNT=`ls -Al $TESTDIR/after* 2> /dev/null | grep -v "total" | wc -l`
101 101 if (( FILE_COUNT != 0 )); then
102 - $LS -Al $TESTDIR
102 + ls -Al $TESTDIR
103 103 log_fail "$TESTDIR contains $FILE_COUNT after* files(s)."
104 104 fi
105 105
106 -FILE_COUNT=`$LS -Al $TESTDIR/before* 2> /dev/null \
107 - | $GREP -v "total" | wc -l`
106 +FILE_COUNT=`ls -Al $TESTDIR/before* 2> /dev/null \
107 + | grep -v "total" | wc -l`
108 108 if (( FILE_COUNT != $COUNT )); then
109 - $LS -Al $TESTDIR
109 + ls -Al $TESTDIR
110 110 log_fail "$TESTDIR contains $FILE_COUNT before* files(s)."
111 111 fi
112 112
113 113 log_pass "Rollback with child snapshot works as expected."
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX