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/vdev_zaps/vdev_zaps.kshlib
+++ new/usr/src/test/zfs-tests/tests/functional/vdev_zaps/vdev_zaps.kshlib
1 1 #
2 2 # CDDL HEADER START
3 3 #
4 4 # This file and its contents are supplied under the terms of the
5 5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 6 # You may only use this file in accordance with the terms of version
|
↓ open down ↓ |
6 lines elided |
↑ open up ↑ |
7 7 # 1.0 of the CDDL.
8 8 #
9 9 # A full copy of the text of the CDDL should have accompanied this
10 10 # source. A copy of the CDDL is also available via the Internet at
11 11 # http://www.illumos.org/license/CDDL.
12 12 #
13 13 # CDDL HEADER END
14 14 #
15 15
16 16 #
17 -# Copyright (c) 2015 by Delphix. All rights reserved.
17 +# Copyright (c) 2015, 2016 by Delphix. All rights reserved.
18 18 #
19 19
20 20 function get_conf_section # regex conf
21 21 {
22 22 typeset dsk_line next_vd_line conf section
23 23 typeset regex="$1"
24 24 typeset conf="$2"
25 25
26 26 dsk_line=$(grep -n "$regex" "$conf" | awk -F: '{print $1}')
27 27 if [[ -z "$dsk_line" ]]; then
28 28 return
29 29 fi
30 30 next_vd_line=$(tail -n +$dsk_line "$conf" | \
31 31 grep -n "children\[" | awk -F: '{print $1}' | head -n 1)
32 32
33 33 if [[ -n "$next_vd_line" ]]; then
34 34 section=$(cat "$conf" | sed "1,${dsk_line}d" | head -n \
35 35 $(($next_vd_line - 2)))
36 36
37 37 else
38 38 section=$(tail -n +$dsk_line "$conf")
39 39 fi
40 40 echo "$section"
41 41 }
42 42
43 43 function get_leaf_vd_zap # dsk conf
44 44 {
45 45 typeset section=$(get_conf_section "$1" "$2")
46 46 echo "$section" | egrep \
47 47 "com.delphix:vdev_zap_leaf: [0-9]+" | awk '{print $2}'
48 48 }
49 49
50 50 function get_top_vd_zap # dsk conf
51 51 {
52 52 typeset section=$(get_conf_section "$1" "$2")
53 53 echo "$section" | egrep \
54 54 "com.delphix:vdev_zap_top: [0-9]+" | awk '{print $2}'
55 55 }
56 56
57 57 function assert_has_sentinel # conf
58 58 {
59 59 res=$(grep "com.delphix:has_per_vdev_zaps" "$1")
60 60 [[ -z "$res" ]] && log_fail "Pool missing ZAP feature sentinel value"
61 61 }
62 62
63 63 function assert_zap_common # pool vd lvl zapobj
64 64 {
65 65 typeset pool=$1
66 66 typeset vd="$2"
67 67 typeset lvl=$3
68 68 typeset zapobj=$4
69 69
70 70 if [[ -z "$zapobj" ]]; then
71 71 log_fail "$vd on $pool has no $lvl ZAP in config"
72 72 elif [[ -z "$(zdb -d $pool $zapobj | grep 'zap')" ]]; then
73 73 log_fail "$vd on $pool has no $lvl ZAP in MOS"
74 74 fi
75 75 }
76 76
77 77 function assert_top_zap # pool vd conf
78 78 {
79 79 typeset pool=$1
80 80 typeset vd="$2"
81 81 typeset conf=$3
82 82
83 83 top_zap=$(get_top_vd_zap "$vd" $conf)
84 84 assert_zap_common $pool "$vd" "top" $top_zap
85 85 }
86 86
87 87 function assert_leaf_zap # pool vd conf
88 88 {
89 89 typeset pool=$1
90 90 typeset vd="$2"
91 91 typeset conf=$3
92 92
93 93 leaf_zap=$(get_leaf_vd_zap "$vd" $conf)
94 94 assert_zap_common $pool "$vd" "leaf" $leaf_zap
95 95 }
96 96
|
↓ open down ↓ |
69 lines elided |
↑ open up ↑ |
97 97 #
98 98 # Code common to setup/teardown for each test.
99 99 #
100 100
101 101 function cleanup
102 102 {
103 103 if datasetexists $TESTPOOL ; then
104 104 log_must zpool destroy -f $TESTPOOL
105 105 fi
106 106 if [[ -e $conf ]]; then
107 - log_must $RM -f "$conf"
107 + log_must rm -f "$conf"
108 108 fi
109 109 if [[ -e $POOL2 ]]; then
110 110 log_must zpool destroy -f $POOL2
111 111 fi
112 112 }
113 113
114 114 log_onexit cleanup
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX