Print this page
NEX-10144 zfs-tests/bin/zfstest should allow DISKS=(zvols)
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-2637 Change to zfs test
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/test/zfs-tests/cmd/scripts/zfstest.ksh
+++ new/usr/src/test/zfs-tests/cmd/scripts/zfstest.ksh
1 1 #!/usr/bin/ksh
2 2
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
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
14 14 #
15 15 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
16 16 # Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
17 17 # Copyright 2016 Nexenta Systems, Inc.
18 18 #
19 19
20 20 export PATH="/usr/bin"
21 21 export NOINUSE_CHECK=1
22 22 export STF_SUITE="/opt/zfs-tests"
23 23 export STF_TOOLS="/opt/test-runner/stf"
24 24 export PATHDIR=""
25 25 runner="/opt/test-runner/bin/run"
26 26 auto_detect=false
27 27
28 28 if [[ -z "$TESTFAIL_CALLBACKS" ]] ; then
29 29 export TESTFAIL_CALLBACKS="$STF_SUITE/callbacks/zfs_dbgmsg"
30 30 fi
31 31
32 32 function fail
33 33 {
34 34 echo $1
35 35 exit ${2:-1}
36 36 }
37 37
38 38 function find_disks
39 39 {
40 40 typeset all_disks=$(echo '' | sudo -k format | awk \
41 41 '/c[0-9]/ {print $2}')
42 42 typeset used_disks=$(zpool status | awk \
43 43 '/c[0-9]+(t[0-9a-f]+)?d[0-9]+/ {print $1}' | sed -E \
44 44 's/(s|p)[0-9]+//g')
45 45
46 46 typeset disk used avail_disks
47 47 for disk in $all_disks; do
48 48 for used in $used_disks; do
49 49 [[ "$disk" = "$used" ]] && continue 2
50 50 done
51 51 [[ -n $avail_disks ]] && avail_disks="$avail_disks $disk"
52 52 [[ -z $avail_disks ]] && avail_disks="$disk"
53 53 done
54 54
55 55 echo $avail_disks
56 56 }
57 57
58 58 function find_rpool
59 59 {
60 60 typeset ds=$(mount | awk '/^\/ / {print $3}')
61 61 echo ${ds%%/*}
62 62 }
|
↓ open down ↓ |
62 lines elided |
↑ open up ↑ |
63 63
64 64 function find_runfile
65 65 {
66 66 typeset distro=
67 67 if [[ -d /opt/delphix && -h /etc/delphix/version ]]; then
68 68 distro=delphix
69 69 elif [[ 0 -ne $(grep -c OpenIndiana /etc/release 2>/dev/null) ]]; then
70 70 distro=openindiana
71 71 elif [[ 0 -ne $(grep -c OmniOS /etc/release 2>/dev/null) ]]; then
72 72 distro=omnios
73 + elif [[ 0 -ne $(grep -c Nexenta /etc/release 2>/dev/null) ]]; then
74 + distro=nexenta
73 75 fi
74 76
75 77 [[ -n $distro ]] && echo $STF_SUITE/runfiles/$distro.run
76 78 }
77 79
78 80 function verify_id
79 81 {
80 82 [[ $(id -u) = "0" ]] && fail "This script must not be run as root."
81 83
82 84 sudo -k -n id >/dev/null 2>&1
83 85 [[ $? -eq 0 ]] || fail "User must be able to sudo without a password."
84 86 }
85 87
86 88 function verify_disks
87 89 {
88 90 typeset disk
89 91 typeset path
90 92 for disk in $DISKS; do
91 93 case $disk in
92 94 /*) path=$disk;;
93 95 *) path=/dev/rdsk/${disk}s0
94 96 esac
95 97 sudo -k prtvtoc $path >/dev/null 2>&1
96 98 [[ $? -eq 0 ]] || return 1
97 99 done
98 100 return 0
99 101 }
100 102
101 103 function create_links
102 104 {
103 105 typeset dir=$1
104 106 typeset file_list=$2
105 107
106 108 [[ -n $PATHDIR ]] || fail "PATHDIR wasn't correctly set"
107 109
108 110 for i in $file_list; do
109 111 [[ ! -e $PATHDIR/$i ]] || fail "$i already exists"
110 112 ln -s $dir/$i $PATHDIR/$i || fail "Couldn't link $i"
111 113 done
112 114
113 115 }
114 116
115 117 function constrain_path
116 118 {
117 119 . $STF_SUITE/include/commands.cfg
118 120
119 121 PATHDIR=$(/usr/bin/mktemp -d /var/tmp/constrained_path.XXXX)
120 122 chmod 755 $PATHDIR || fail "Couldn't chmod $PATHDIR"
121 123
122 124 create_links "/usr/bin" "$USR_BIN_FILES"
123 125 create_links "/usr/sbin" "$USR_SBIN_FILES"
124 126 create_links "/sbin" "$SBIN_FILES"
125 127 create_links "/opt/zfs-tests/bin" "$ZFSTEST_FILES"
126 128
127 129 # Special case links
128 130 ln -s /usr/gnu/bin/dd $PATHDIR/gnu_dd
129 131 }
130 132
131 133 constrain_path
132 134 export PATH=$PATHDIR
133 135
134 136 verify_id
135 137 while getopts ac:q c; do
136 138 case $c in
137 139 'a')
138 140 auto_detect=true
139 141 ;;
140 142 'c')
141 143 runfile=$OPTARG
142 144 [[ -f $runfile ]] || fail "Cannot read file: $runfile"
143 145 ;;
144 146 'q')
145 147 quiet='-q'
146 148 ;;
147 149 esac
148 150 done
149 151 shift $((OPTIND - 1))
150 152
151 153 # If the user specified -a, then use free disks, otherwise use those in $DISKS.
152 154 if $auto_detect; then
153 155 export DISKS=$(find_disks)
154 156 elif [[ -z $DISKS ]]; then
155 157 fail "\$DISKS not set in env, and -a not specified."
156 158 else
157 159 verify_disks || fail "Couldn't verify all the disks in \$DISKS"
158 160 fi
159 161
160 162 # Add the root pool to $KEEP according to its contents.
161 163 # It's ok to list it twice.
162 164 if [[ -z $KEEP ]]; then
163 165 KEEP="$(find_rpool)"
164 166 else
165 167 KEEP+=" $(find_rpool)"
166 168 fi
167 169
168 170 export __ZFS_POOL_EXCLUDE="$KEEP"
169 171 export KEEP="^$(echo $KEEP | sed 's/ /$|^/g')\$"
170 172
171 173 [[ -z $runfile ]] && runfile=$(find_runfile)
172 174 [[ -z $runfile ]] && fail "Couldn't determine distro"
173 175
174 176 . $STF_SUITE/include/default.cfg
175 177
176 178 num_disks=$(echo $DISKS | awk '{print NF}')
177 179 [[ $num_disks -lt 3 ]] && fail "Not enough disks to run ZFS Test Suite"
178 180
179 181 # Ensure user has only basic privileges.
180 182 ppriv -s EIP=basic -e $runner $quiet -c $runfile
181 183 ret=$?
182 184
183 185 rm -rf $PATHDIR || fail "Couldn't remove $PATHDIR"
184 186
185 187 exit $ret
|
↓ open down ↓ |
103 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX