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_015_pos.ksh
+++ new/usr/src/test/zfs-tests/tests/functional/snapshot/snapshot_015_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]
19 19 #
|
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
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 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 . $STF_SUITE/tests/functional/cli_root/zfs_rollback/zfs_rollback_common.kshlib
36 36
37 37 #
38 38 # DESCRIPTION:
39 39 # Verify snapshot can be created or destroy via mkdir or rm
40 40 # in .zfs/snapshot.
41 41 #
42 42 # STRATEGY:
43 43 # 1. Verify make directories only successfully in .zfs/snapshot.
44 44 # 2. Verify snapshot can be created and destroy via mkdir and remove
45 45 # directories in .zfs/snapshot.
46 46 # 3. Verify rollback to previous snapshot can succeed.
|
↓ open down ↓ |
6 lines elided |
↑ open up ↑ |
47 47 # 4. Verify remove directory in snapdir can destroy snapshot.
48 48 #
49 49
50 50 verify_runnable "both"
51 51
52 52 function cleanup
53 53 {
54 54 typeset -i i=0
55 55 while ((i < snap_cnt)); do
56 56 typeset snap=$fs@snap.$i
57 - datasetexists $snap && log_must $ZFS destroy -f $snap
57 + datasetexists $snap && log_must zfs destroy -f $snap
58 58
59 59 ((i += 1))
60 60 done
61 61 }
62 62
63 -$ZFS 2>&1 | $GREP "allow" > /dev/null
63 +zfs 2>&1 | grep "allow" > /dev/null
64 64 (($? != 0)) && log_unsupported
65 65
66 66 log_assert "Verify snapshot can be created via mkdir in .zfs/snapshot."
67 67 log_onexit cleanup
68 68
69 69 fs=$TESTPOOL/$TESTFS
70 70 # Verify all the other directories are readonly.
71 71 mntpnt=$(get_prop mountpoint $fs)
72 72 snapdir=$mntpnt/.zfs
73 73 set -A ro_dirs "$snapdir" "$snapdir/snap" "$snapdir/snapshot"
74 74 for dir in ${ro_dirs[@]}; do
75 75 if [[ -d $dir ]]; then
76 - log_mustnot $RM -rf $dir
77 - log_mustnot $TOUCH $dir/testfile
76 + log_mustnot rm -rf $dir
77 + log_mustnot touch $dir/testfile
78 78 else
79 - log_mustnot $MKDIR $dir
79 + log_mustnot mkdir $dir
80 80 fi
81 81 done
82 82
83 83 # Verify snapshot can be created via mkdir in .zfs/snapshot
84 84 typeset -i snap_cnt=5
85 85 typeset -i cnt=0
86 86 while ((cnt < snap_cnt)); do
87 87 testfile=$mntpnt/testfile.$cnt
88 - log_must $MKFILE 1M $testfile
89 - log_must $MKDIR $snapdir/snapshot/snap.$cnt
88 + log_must mkfile 1M $testfile
89 + log_must mkdir $snapdir/snapshot/snap.$cnt
90 90 if ! datasetexists $fs@snap.$cnt ; then
91 91 log_fail "ERROR: $fs@snap.$cnt should exists."
92 92 fi
93 93
94 94 ((cnt += 1))
95 95 done
96 96
97 97 # Verify rollback to previous snapshot succeed.
98 98 ((cnt = RANDOM % snap_cnt))
99 -log_must $ZFS rollback -r $fs@snap.$cnt
99 +log_must zfs rollback -r $fs@snap.$cnt
100 100
101 101 typeset -i i=0
102 102 while ((i < snap_cnt)); do
103 103 testfile=$mntpnt/testfile.$i
104 104 if ((i <= cnt)); then
105 105 if [[ ! -f $testfile ]]; then
106 106 log_fail "ERROR: $testfile should exists."
107 107 fi
108 108 else
109 109 if [[ -f $testfile ]]; then
110 110 log_fail "ERROR: $testfile should not exists."
111 111 fi
112 112 fi
113 113
114 114 ((i += 1))
115 115 done
116 116
117 117 # Verify remove directory in snapdir can destroy snapshot.
118 -log_must $RMDIR $snapdir/snapshot/snap.$cnt
118 +log_must rmdir $snapdir/snapshot/snap.$cnt
119 119 log_mustnot datasetexists $fs@snap.$cnt
120 120
121 121 log_pass "Verify snapshot can be created via mkdir in .zfs/snapshot passed."
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX