1 #
2 # CDDL HEADER START
3 #
4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
7 # 1.0 of the CDDL.
8 #
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
12 #
13 # CDDL HEADER END
14 #
15
16 #
17 # Copyright (c) 2015 by Delphix. All rights reserved.
18 #
19
20 function get_conf_section # regex conf
21 {
22 typeset dsk_line next_vd_line conf section
23 typeset regex="$1"
24 typeset conf="$2"
25
26 dsk_line=$(grep -n "$regex" "$conf" | awk -F: '{print $1}')
27 if [[ -z "$dsk_line" ]]; then
28 return
29 fi
30 next_vd_line=$(tail -n +$dsk_line "$conf" | \
31 grep -n "children\[" | awk -F: '{print $1}' | head -n 1)
32
33 if [[ -n "$next_vd_line" ]]; then
34 section=$(cat "$conf" | sed "1,${dsk_line}d" | head -n \
35 $(($next_vd_line - 2)))
36
37 else
87 function assert_leaf_zap # pool vd conf
88 {
89 typeset pool=$1
90 typeset vd="$2"
91 typeset conf=$3
92
93 leaf_zap=$(get_leaf_vd_zap "$vd" $conf)
94 assert_zap_common $pool "$vd" "leaf" $leaf_zap
95 }
96
97 #
98 # Code common to setup/teardown for each test.
99 #
100
101 function cleanup
102 {
103 if datasetexists $TESTPOOL ; then
104 log_must zpool destroy -f $TESTPOOL
105 fi
106 if [[ -e $conf ]]; then
107 log_must $RM -f "$conf"
108 fi
109 if [[ -e $POOL2 ]]; then
110 log_must zpool destroy -f $POOL2
111 fi
112 }
113
114 log_onexit cleanup
|
1 #
2 # CDDL HEADER START
3 #
4 # This file and its contents are supplied under the terms of the
5 # Common Development and Distribution License ("CDDL"), version 1.0.
6 # You may only use this file in accordance with the terms of version
7 # 1.0 of the CDDL.
8 #
9 # A full copy of the text of the CDDL should have accompanied this
10 # source. A copy of the CDDL is also available via the Internet at
11 # http://www.illumos.org/license/CDDL.
12 #
13 # CDDL HEADER END
14 #
15
16 #
17 # Copyright (c) 2015, 2016 by Delphix. All rights reserved.
18 #
19
20 function get_conf_section # regex conf
21 {
22 typeset dsk_line next_vd_line conf section
23 typeset regex="$1"
24 typeset conf="$2"
25
26 dsk_line=$(grep -n "$regex" "$conf" | awk -F: '{print $1}')
27 if [[ -z "$dsk_line" ]]; then
28 return
29 fi
30 next_vd_line=$(tail -n +$dsk_line "$conf" | \
31 grep -n "children\[" | awk -F: '{print $1}' | head -n 1)
32
33 if [[ -n "$next_vd_line" ]]; then
34 section=$(cat "$conf" | sed "1,${dsk_line}d" | head -n \
35 $(($next_vd_line - 2)))
36
37 else
87 function assert_leaf_zap # pool vd conf
88 {
89 typeset pool=$1
90 typeset vd="$2"
91 typeset conf=$3
92
93 leaf_zap=$(get_leaf_vd_zap "$vd" $conf)
94 assert_zap_common $pool "$vd" "leaf" $leaf_zap
95 }
96
97 #
98 # Code common to setup/teardown for each test.
99 #
100
101 function cleanup
102 {
103 if datasetexists $TESTPOOL ; then
104 log_must zpool destroy -f $TESTPOOL
105 fi
106 if [[ -e $conf ]]; then
107 log_must rm -f "$conf"
108 fi
109 if [[ -e $POOL2 ]]; then
110 log_must zpool destroy -f $POOL2
111 fi
112 }
113
114 log_onexit cleanup
|