]>
Commit | Line | Data |
---|---|---|
6bb24f4d BB |
1 | #!/bin/bash |
2 | # | |
3 | # CDDL HEADER START | |
4 | # | |
5 | # The contents of this file are subject to the terms of the | |
6 | # Common Development and Distribution License, Version 1.0 only | |
7 | # (the "License"). You may not use this file except in compliance | |
8 | # with the License. | |
9 | # | |
10 | # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
11 | # or http://www.opensolaris.org/os/licensing. | |
12 | # See the License for the specific language governing permissions | |
13 | # and limitations under the License. | |
14 | # | |
15 | # When distributing Covered Code, include this CDDL HEADER in each | |
16 | # file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
17 | # If applicable, add the following below this CDDL HEADER, with the | |
18 | # fields enclosed by brackets "[]" replaced with your own identifying | |
19 | # information: Portions Copyright [yyyy] [name of copyright owner] | |
20 | # | |
21 | # CDDL HEADER END | |
22 | # | |
6bb24f4d | 23 | |
c8f9061f | 24 | BASE_DIR=$(dirname "$0") |
6bb24f4d | 25 | SCRIPT_COMMON=common.sh |
c8f9061f BB |
26 | if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then |
27 | . "${BASE_DIR}/${SCRIPT_COMMON}" | |
6bb24f4d BB |
28 | else |
29 | echo "Missing helper script ${SCRIPT_COMMON}" && exit 1 | |
30 | fi | |
31 | ||
6bb24f4d | 32 | PROG=zfs-tests.sh |
c8f9061f | 33 | VERBOSE="no" |
6bb24f4d | 34 | QUIET= |
c8f9061f BB |
35 | CLEANUP="yes" |
36 | CLEANUPALL="no" | |
37 | LOOPBACK="yes" | |
d7958b4c | 38 | FILESIZE="4G" |
6bb24f4d BB |
39 | RUNFILE=${RUNFILE:-"linux.run"} |
40 | FILEDIR=${FILEDIR:-/var/tmp} | |
41 | DISKS=${DISKS:-""} | |
d8fa599f GDN |
42 | SINGLETEST=() |
43 | SINGLETESTUSER="root" | |
271955da | 44 | TAGS="" |
9a810efb | 45 | ITERATIONS=1 |
00481e7d BB |
46 | ZFS_DBGMSG="$STF_SUITE/callbacks/zfs_dbgmsg.ksh" |
47 | ZFS_DMESG="$STF_SUITE/callbacks/zfs_dmesg.ksh" | |
379ca9cf OF |
48 | ZFS_MMP="$STF_SUITE/callbacks/zfs_mmp.ksh" |
49 | TESTFAIL_CALLBACKS=${TESTFAIL_CALLBACKS:-"$ZFS_DBGMSG:$ZFS_DMESG:$ZFS_MMP"} | |
c8f9061f BB |
50 | LOSETUP=${LOSETUP:-/sbin/losetup} |
51 | DMSETUP=${DMSETUP:-/sbin/dmsetup} | |
52 | ||
53 | # | |
54 | # Log an informational message when additional verbosity is enabled. | |
55 | # | |
56 | msg() { | |
57 | if [ "$VERBOSE" = "yes" ]; then | |
58 | echo "$@" | |
59 | fi | |
60 | } | |
61 | ||
62 | # | |
63 | # Log a failure message, cleanup, and return an error. | |
64 | # | |
65 | fail() { | |
66 | echo -e "$PROG: $1" >&2 | |
67 | cleanup | |
68 | exit 1 | |
69 | } | |
6bb24f4d BB |
70 | |
71 | # | |
72 | # Attempt to remove loopback devices and files which where created earlier | |
73 | # by this script to run the test framework. The '-k' option may be passed | |
74 | # to the script to suppress cleanup for debugging purposes. | |
75 | # | |
76 | cleanup() { | |
c8f9061f | 77 | if [ "$CLEANUP" = "no" ]; then |
6bb24f4d BB |
78 | return 0 |
79 | fi | |
80 | ||
c8f9061f | 81 | if [ "$LOOPBACK" = "yes" ]; then |
6bb24f4d | 82 | for TEST_LOOPBACK in ${LOOPBACKS}; do |
c552fbc5 | 83 | LOOP_DEV=$(basename "$TEST_LOOPBACK") |
c1d9abf9 | 84 | DM_DEV=$(sudo "${DMSETUP}" ls 2>/dev/null | \ |
c552fbc5 | 85 | grep "${LOOP_DEV}" | cut -f1) |
6bb24f4d BB |
86 | |
87 | if [ -n "$DM_DEV" ]; then | |
c1d9abf9 | 88 | sudo "${DMSETUP}" remove "${DM_DEV}" || |
6bb24f4d BB |
89 | echo "Failed to remove: ${DM_DEV}" |
90 | fi | |
91 | ||
92 | if [ -n "${TEST_LOOPBACK}" ]; then | |
c1d9abf9 | 93 | sudo "${LOSETUP}" -d "${TEST_LOOPBACK}" || |
6bb24f4d BB |
94 | echo "Failed to remove: ${TEST_LOOPBACK}" |
95 | fi | |
96 | done | |
97 | fi | |
98 | ||
99 | for TEST_FILE in ${FILES}; do | |
c552fbc5 | 100 | rm -f "${TEST_FILE}" &>/dev/null |
6bb24f4d | 101 | done |
c1d9abf9 | 102 | |
c8f9061f | 103 | if [ "$STF_PATH_REMOVE" = "yes" ] && [ -d "$STF_PATH" ]; then |
c1d9abf9 JWK |
104 | rm -Rf "$STF_PATH" |
105 | fi | |
6bb24f4d BB |
106 | } |
107 | trap cleanup EXIT | |
108 | ||
109 | # | |
110 | # Attempt to remove all testpools (testpool.XXX), unopened dm devices, | |
111 | # loopback devices, and files. This is a useful way to cleanup a previous | |
112 | # test run failure which has left the system in an unknown state. This can | |
113 | # be dangerous and should only be used in a dedicated test environment. | |
114 | # | |
115 | cleanup_all() { | |
c552fbc5 | 116 | local TEST_POOLS |
74698631 | 117 | TEST_POOLS=$(sudo "$ZPOOL" list -H -o name | grep testpool) |
c552fbc5 | 118 | local TEST_LOOPBACKS |
c1d9abf9 | 119 | TEST_LOOPBACKS=$(sudo "${LOSETUP}" -a|grep file-vdev|cut -f1 -d:) |
c552fbc5 GDN |
120 | local TEST_FILES |
121 | TEST_FILES=$(ls /var/tmp/file-vdev* 2>/dev/null) | |
6bb24f4d BB |
122 | |
123 | msg | |
124 | msg "--- Cleanup ---" | |
c552fbc5 | 125 | msg "Removing pool(s): $(echo "${TEST_POOLS}" | tr '\n' ' ')" |
6bb24f4d | 126 | for TEST_POOL in $TEST_POOLS; do |
74698631 | 127 | sudo "$ZPOOL" destroy "${TEST_POOL}" |
6bb24f4d BB |
128 | done |
129 | ||
c1d9abf9 | 130 | msg "Removing dm(s): $(sudo "${DMSETUP}" ls | |
6bb24f4d | 131 | grep loop | tr '\n' ' ')" |
c1d9abf9 | 132 | sudo "${DMSETUP}" remove_all |
6bb24f4d | 133 | |
c552fbc5 | 134 | msg "Removing loopback(s): $(echo "${TEST_LOOPBACKS}" | tr '\n' ' ')" |
6bb24f4d | 135 | for TEST_LOOPBACK in $TEST_LOOPBACKS; do |
c1d9abf9 | 136 | sudo "${LOSETUP}" -d "${TEST_LOOPBACK}" |
6bb24f4d BB |
137 | done |
138 | ||
c552fbc5 | 139 | msg "Removing files(s): $(echo "${TEST_FILES}" | tr '\n' ' ')" |
6bb24f4d | 140 | for TEST_FILE in $TEST_FILES; do |
c1d9abf9 | 141 | sudo rm -f "${TEST_FILE}" |
6bb24f4d BB |
142 | done |
143 | } | |
144 | ||
6bb24f4d BB |
145 | # |
146 | # Takes a name as the only arguments and looks for the following variations | |
147 | # on that name. If one is found it is returned. | |
148 | # | |
c8f9061f BB |
149 | # $RUNFILE_DIR/<name> |
150 | # $RUNFILE_DIR/<name>.run | |
6bb24f4d BB |
151 | # <name> |
152 | # <name>.run | |
153 | # | |
154 | find_runfile() { | |
155 | local NAME=$1 | |
156 | local RESULT="" | |
157 | ||
c8f9061f BB |
158 | if [ -f "$RUNFILE_DIR/$NAME" ]; then |
159 | RESULT="$RUNFILE_DIR/$NAME" | |
160 | elif [ -f "$RUNFILE_DIR/$NAME.run" ]; then | |
161 | RESULT="$RUNFILE_DIR/$NAME.run" | |
6bb24f4d BB |
162 | elif [ -f "$NAME" ]; then |
163 | RESULT="$NAME" | |
164 | elif [ -f "$NAME.run" ]; then | |
165 | RESULT="$NAME.run" | |
166 | fi | |
167 | ||
168 | echo "$RESULT" | |
169 | } | |
170 | ||
c1d9abf9 JWK |
171 | # |
172 | # Symlink file if it appears under any of the given paths. | |
173 | # | |
174 | create_links() { | |
175 | local dir_list="$1" | |
176 | local file_list="$2" | |
177 | ||
74698631 | 178 | [ -n "$STF_PATH" ] || fail "STF_PATH wasn't correctly set" |
c1d9abf9 JWK |
179 | |
180 | for i in $file_list; do | |
181 | for j in $dir_list; do | |
182 | [ ! -e "$STF_PATH/$i" ] || continue | |
183 | ||
74698631 GDN |
184 | if [ ! -d "$j/$i" ] && [ -e "$j/$i" ]; then |
185 | ln -s "$j/$i" "$STF_PATH/$i" || \ | |
c1d9abf9 JWK |
186 | fail "Couldn't link $i" |
187 | break | |
188 | fi | |
189 | done | |
190 | ||
74698631 | 191 | [ ! -e "$STF_PATH/$i" ] && STF_MISSING_BIN="$STF_MISSING_BIN$i " |
c1d9abf9 JWK |
192 | done |
193 | } | |
194 | ||
195 | # | |
196 | # Constrain the path to limit the available binaries to a known set. | |
197 | # When running in-tree a top level ./bin/ directory is created for | |
198 | # convenience, otherwise a temporary directory is used. | |
199 | # | |
200 | constrain_path() { | |
74698631 | 201 | . "$STF_SUITE/include/commands.cfg" |
c1d9abf9 | 202 | |
c8f9061f BB |
203 | if [ "$INTREE" = "yes" ]; then |
204 | # Constrained path set to ./zfs/bin/ | |
205 | STF_PATH="$BIN_DIR" | |
206 | STF_PATH_REMOVE="no" | |
207 | STF_MISSING_BIN="" | |
c1d9abf9 JWK |
208 | if [ ! -d "$STF_PATH" ]; then |
209 | mkdir "$STF_PATH" | |
c8f9061f | 210 | chmod 755 "$STF_PATH" || fail "Couldn't chmod $STF_PATH" |
c1d9abf9 | 211 | fi |
c8f9061f BB |
212 | |
213 | # Special case links for standard zfs utilities | |
214 | DIRS="$(find "$CMD_DIR" -type d \( ! -name .deps -a \ | |
215 | ! -name .libs \) -print | tr '\n' ' ')" | |
216 | create_links "$DIRS" "$ZFS_FILES" | |
217 | ||
218 | # Special case links for zfs test suite utilities | |
219 | DIRS="$(find "$STF_SUITE" -type d \( ! -name .deps -a \ | |
220 | ! -name .libs \) -print | tr '\n' ' ')" | |
221 | create_links "$DIRS" "$ZFSTEST_FILES" | |
c1d9abf9 | 222 | else |
c8f9061f | 223 | # Constrained path set to /var/tmp/constrained_path.* |
c1d9abf9 JWK |
224 | SYSTEMDIR=${SYSTEMDIR:-/var/tmp/constrained_path.XXXX} |
225 | STF_PATH=$(/bin/mktemp -d "$SYSTEMDIR") | |
c8f9061f BB |
226 | STF_PATH_REMOVE="yes" |
227 | STF_MISSING_BIN="" | |
c1d9abf9 | 228 | |
c8f9061f | 229 | chmod 755 "$STF_PATH" || fail "Couldn't chmod $STF_PATH" |
c1d9abf9 | 230 | |
c1d9abf9 JWK |
231 | # Special case links for standard zfs utilities |
232 | create_links "/bin /usr/bin /sbin /usr/sbin" "$ZFS_FILES" | |
233 | ||
c8f9061f BB |
234 | # Special case links for zfs test suite utilities |
235 | create_links "$STF_SUITE/bin" "$ZFSTEST_FILES" | |
c1d9abf9 JWK |
236 | fi |
237 | ||
c8f9061f BB |
238 | # Standard system utilities |
239 | create_links "/bin /usr/bin /sbin /usr/sbin" "$SYSTEM_FILES" | |
240 | ||
c1d9abf9 | 241 | # Exceptions |
74698631 | 242 | ln -fs "$STF_PATH/awk" "$STF_PATH/nawk" |
5c214ae3 BB |
243 | ln -fs /sbin/fsck.ext4 "$STF_PATH/fsck" |
244 | ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs" | |
74698631 GDN |
245 | ln -fs "$STF_PATH/gzip" "$STF_PATH/compress" |
246 | ln -fs "$STF_PATH/gunzip" "$STF_PATH/uncompress" | |
247 | ln -fs "$STF_PATH/exportfs" "$STF_PATH/share" | |
248 | ln -fs "$STF_PATH/exportfs" "$STF_PATH/unshare" | |
c1d9abf9 JWK |
249 | } |
250 | ||
6bb24f4d BB |
251 | # |
252 | # Output a useful usage message. | |
253 | # | |
254 | usage() { | |
255 | cat << EOF | |
256 | USAGE: | |
d25534f8 | 257 | $0 [hvqxkf] [-s SIZE] [-r RUNFILE] [-t PATH] [-u USER] |
6bb24f4d BB |
258 | |
259 | DESCRIPTION: | |
260 | ZFS Test Suite launch script | |
261 | ||
262 | OPTIONS: | |
263 | -h Show this message | |
264 | -v Verbose zfs-tests.sh output | |
265 | -q Quiet test-runner output | |
266 | -x Remove all testpools, dm, lo, and files (unsafe) | |
267 | -k Disable cleanup after test failure | |
268 | -f Use files only, disables block device tests | |
c8f9061f | 269 | -c Only create and populate constrained path |
9a810efb | 270 | -I NUM Number of iterations |
6bb24f4d | 271 | -d DIR Use DIR for files and loopback devices |
d7958b4c | 272 | -s SIZE Use vdevs of SIZE (default: 4G) |
6bb24f4d | 273 | -r RUNFILE Run tests in RUNFILE (default: linux.run) |
d25534f8 | 274 | -t PATH Run single test at PATH relative to test suite |
271955da | 275 | -T TAGS Comma separated list of tags (default: 'functional') |
d8fa599f | 276 | -u USER Run single test as USER (default: root) |
6bb24f4d BB |
277 | |
278 | EXAMPLES: | |
279 | # Run the default (linux) suite of tests and output the configuration used. | |
280 | $0 -v | |
281 | ||
282 | # Run a smaller suite of tests designed to run more quickly. | |
283 | $0 -r linux-fast | |
284 | ||
285 | # Cleanup a previous run of the test suite prior to testing, run the | |
286 | # default (linux) suite of tests and perform no cleanup on exit. | |
e6123796 | 287 | $0 -x |
6bb24f4d BB |
288 | |
289 | EOF | |
290 | } | |
291 | ||
9a810efb | 292 | while getopts 'hvqxkfcd:s:r:?t:T:u:I:' OPTION; do |
6bb24f4d BB |
293 | case $OPTION in |
294 | h) | |
295 | usage | |
296 | exit 1 | |
297 | ;; | |
298 | v) | |
c552fbc5 | 299 | # shellcheck disable=SC2034 |
c8f9061f | 300 | VERBOSE="yes" |
6bb24f4d BB |
301 | ;; |
302 | q) | |
303 | QUIET="-q" | |
304 | ;; | |
305 | x) | |
c8f9061f | 306 | CLEANUPALL="yes" |
6bb24f4d BB |
307 | ;; |
308 | k) | |
c8f9061f | 309 | CLEANUP="no" |
6bb24f4d BB |
310 | ;; |
311 | f) | |
c8f9061f BB |
312 | LOOPBACK="no" |
313 | ;; | |
314 | c) | |
315 | constrain_path | |
316 | exit | |
6bb24f4d BB |
317 | ;; |
318 | d) | |
319 | FILEDIR="$OPTARG" | |
320 | ;; | |
9a810efb GDN |
321 | I) |
322 | ITERATIONS="$OPTARG" | |
323 | if [ "$ITERATIONS" -le 0 ]; then | |
324 | fail "Iterations must be greater than 0." | |
325 | fi | |
326 | ;; | |
6bb24f4d BB |
327 | s) |
328 | FILESIZE="$OPTARG" | |
329 | ;; | |
330 | r) | |
331 | RUNFILE="$OPTARG" | |
332 | ;; | |
d8fa599f GDN |
333 | t) |
334 | if [ ${#SINGLETEST[@]} -ne 0 ]; then | |
335 | fail "-t can only be provided once." | |
336 | fi | |
337 | SINGLETEST+=("$OPTARG") | |
338 | ;; | |
9a810efb GDN |
339 | T) |
340 | TAGS="$OPTARG" | |
341 | ;; | |
d8fa599f GDN |
342 | u) |
343 | SINGLETESTUSER="$OPTARG" | |
344 | ;; | |
6bb24f4d BB |
345 | ?) |
346 | usage | |
347 | exit | |
348 | ;; | |
349 | esac | |
350 | done | |
351 | ||
352 | shift $((OPTIND-1)) | |
353 | ||
354 | FILES=${FILES:-"$FILEDIR/file-vdev0 $FILEDIR/file-vdev1 $FILEDIR/file-vdev2"} | |
355 | LOOPBACKS=${LOOPBACKS:-""} | |
356 | ||
d8fa599f | 357 | if [ ${#SINGLETEST[@]} -ne 0 ]; then |
271955da | 358 | if [ -n "$TAGS" ]; then |
359 | fail "-t and -T are mutually exclusive." | |
360 | fi | |
c8f9061f | 361 | RUNFILE_DIR="/var/tmp" |
d8fa599f GDN |
362 | RUNFILE="zfs-tests.$$.run" |
363 | SINGLEQUIET="False" | |
364 | ||
365 | if [ -n "$QUIET" ]; then | |
366 | SINGLEQUIET="True" | |
367 | fi | |
368 | ||
c8f9061f | 369 | cat >$RUNFILE_DIR/$RUNFILE << EOF |
d8fa599f GDN |
370 | [DEFAULT] |
371 | pre = | |
372 | quiet = $SINGLEQUIET | |
373 | pre_user = root | |
374 | user = $SINGLETESTUSER | |
375 | timeout = 600 | |
376 | post_user = root | |
377 | post = | |
378 | outputdir = /var/tmp/test_results | |
379 | EOF | |
380 | for t in "${SINGLETEST[@]}" | |
381 | do | |
382 | SINGLETESTDIR=$(dirname "$t") | |
383 | SINGLETESTFILE=$(basename "$t") | |
384 | SETUPSCRIPT= | |
385 | CLEANUPSCRIPT= | |
386 | ||
d25534f8 | 387 | if [ -f "$STF_SUITE/$SINGLETESTDIR/setup.ksh" ]; then |
d8fa599f GDN |
388 | SETUPSCRIPT="setup" |
389 | fi | |
390 | ||
d25534f8 | 391 | if [ -f "$STF_SUITE/$SINGLETESTDIR/cleanup.ksh" ]; then |
d8fa599f GDN |
392 | CLEANUPSCRIPT="cleanup" |
393 | fi | |
394 | ||
c8f9061f | 395 | cat >>$RUNFILE_DIR/$RUNFILE << EOF |
d8fa599f GDN |
396 | |
397 | [$SINGLETESTDIR] | |
398 | tests = ['$SINGLETESTFILE'] | |
399 | pre = $SETUPSCRIPT | |
400 | post = $CLEANUPSCRIPT | |
271955da | 401 | tags = ['functional'] |
d8fa599f GDN |
402 | EOF |
403 | done | |
404 | fi | |
405 | ||
271955da | 406 | # |
407 | # Use default tag if none was specified | |
408 | # | |
409 | TAGS=${TAGS:='functional'} | |
410 | ||
6bb24f4d BB |
411 | # |
412 | # Attempt to locate the runfile describing the test workload. | |
413 | # | |
414 | if [ -n "$RUNFILE" ]; then | |
415 | SAVED_RUNFILE="$RUNFILE" | |
416 | RUNFILE=$(find_runfile "$RUNFILE") | |
417 | [ -z "$RUNFILE" ] && fail "Cannot find runfile: $SAVED_RUNFILE" | |
418 | fi | |
419 | ||
420 | if [ ! -r "$RUNFILE" ]; then | |
421 | fail "Cannot read runfile: $RUNFILE" | |
422 | fi | |
423 | ||
424 | # | |
425 | # This script should not be run as root. Instead the test user, which may | |
426 | # be a normal user account, needs to be configured such that it can | |
427 | # run commands via sudo passwordlessly. | |
428 | # | |
c552fbc5 | 429 | if [ "$(id -u)" = "0" ]; then |
6bb24f4d BB |
430 | fail "This script must not be run as root." |
431 | fi | |
432 | ||
c552fbc5 | 433 | if [ "$(sudo whoami)" != "root" ]; then |
6bb24f4d BB |
434 | fail "Passwordless sudo access required." |
435 | fi | |
436 | ||
c1d9abf9 | 437 | # |
c8f9061f | 438 | # Constrain the available binaries to a known set. |
c1d9abf9 JWK |
439 | # |
440 | constrain_path | |
441 | ||
e6123796 JX |
442 | # |
443 | # Check if ksh exists | |
444 | # | |
74698631 | 445 | [ -e "$STF_PATH/ksh" ] || fail "This test suite requires ksh." |
3f03fc8d BB |
446 | [ -e "$STF_SUITE/include/default.cfg" ] || fail \ |
447 | "Missing $STF_SUITE/include/default.cfg file." | |
e6123796 | 448 | |
6bb24f4d | 449 | # |
c8f9061f | 450 | # Verify the ZFS module stack is loaded. |
6bb24f4d | 451 | # |
c1d9abf9 | 452 | sudo "${ZFS_SH}" &>/dev/null |
6bb24f4d BB |
453 | |
454 | # | |
455 | # Attempt to cleanup all previous state for a new test run. | |
456 | # | |
c8f9061f | 457 | if [ "$CLEANUPALL" = "yes" ]; then |
6bb24f4d BB |
458 | cleanup_all |
459 | fi | |
460 | ||
461 | # | |
462 | # By default preserve any existing pools | |
3fd3e56c | 463 | # NOTE: Since 'zpool list' outputs a newline-delimited list convert $KEEP from |
464 | # space-delimited to newline-delimited. | |
6bb24f4d BB |
465 | # |
466 | if [ -z "${KEEP}" ]; then | |
3fd3e56c | 467 | KEEP="$(sudo "$ZPOOL" list -H -o name)" |
6bb24f4d BB |
468 | if [ -z "${KEEP}" ]; then |
469 | KEEP="rpool" | |
470 | fi | |
3fd3e56c | 471 | else |
472 | KEEP="$(echo -e "${KEEP//[[:blank:]]/\n}")" | |
6bb24f4d BB |
473 | fi |
474 | ||
3fd3e56c | 475 | # |
476 | # NOTE: The following environment variables are undocumented | |
477 | # and should be used for testing purposes only: | |
478 | # | |
479 | # __ZFS_POOL_EXCLUDE - don't iterate over the pools it lists | |
480 | # __ZFS_POOL_RESTRICT - iterate only over the pools it lists | |
481 | # | |
482 | # See libzfs/libzfs_config.c for more information. | |
483 | # | |
484 | __ZFS_POOL_EXCLUDE="$(echo "$KEEP" | sed ':a;N;s/\n/ /g;ba')" | |
d21d5b82 | 485 | |
74698631 | 486 | . "$STF_SUITE/include/default.cfg" |
c1d9abf9 | 487 | |
6bb24f4d BB |
488 | msg |
489 | msg "--- Configuration ---" | |
490 | msg "Runfile: $RUNFILE" | |
491 | msg "STF_TOOLS: $STF_TOOLS" | |
492 | msg "STF_SUITE: $STF_SUITE" | |
c1d9abf9 | 493 | msg "STF_PATH: $STF_PATH" |
6bb24f4d BB |
494 | |
495 | # | |
496 | # No DISKS have been provided so a basic file or loopback based devices | |
497 | # must be created for the test suite to use. | |
498 | # | |
499 | if [ -z "${DISKS}" ]; then | |
500 | # | |
501 | # Create sparse files for the test suite. These may be used | |
502 | # directory or have loopback devices layered on them. | |
503 | # | |
504 | for TEST_FILE in ${FILES}; do | |
505 | [ -f "$TEST_FILE" ] && fail "Failed file exists: ${TEST_FILE}" | |
c552fbc5 | 506 | truncate -s "${FILESIZE}" "${TEST_FILE}" || |
6bb24f4d | 507 | fail "Failed creating: ${TEST_FILE} ($?)" |
5c596ba7 TC |
508 | if [[ "$DISKS" ]]; then |
509 | DISKS="$DISKS $TEST_FILE" | |
510 | else | |
511 | DISKS="$TEST_FILE" | |
512 | fi | |
6bb24f4d BB |
513 | done |
514 | ||
515 | # | |
516 | # If requested setup loopback devices backed by the sparse files. | |
517 | # | |
c8f9061f | 518 | if [ "$LOOPBACK" = "yes" ]; then |
6bb24f4d | 519 | DISKS="" |
c8f9061f BB |
520 | |
521 | test -x "$LOSETUP" || fail "$LOSETUP utility must be installed" | |
6bb24f4d BB |
522 | |
523 | for TEST_FILE in ${FILES}; do | |
c1d9abf9 JWK |
524 | TEST_LOOPBACK=$(sudo "${LOSETUP}" -f) |
525 | sudo "${LOSETUP}" "${TEST_LOOPBACK}" "${TEST_FILE}" || | |
6bb24f4d BB |
526 | fail "Failed: ${TEST_FILE} -> ${TEST_LOOPBACK}" |
527 | LOOPBACKS="${LOOPBACKS}${TEST_LOOPBACK} " | |
c552fbc5 | 528 | BASELOOPBACKS=$(basename "$TEST_LOOPBACK") |
5c596ba7 TC |
529 | if [[ "$DISKS" ]]; then |
530 | DISKS="$DISKS $BASELOOPBACKS" | |
531 | else | |
532 | DISKS="$BASELOOPBACKS" | |
533 | fi | |
6bb24f4d BB |
534 | done |
535 | fi | |
536 | fi | |
537 | ||
c8f9061f | 538 | NUM_DISKS=$(echo "${DISKS}" | awk '{print NF}') |
c552fbc5 | 539 | [ "$NUM_DISKS" -lt 3 ] && fail "Not enough disks ($NUM_DISKS/3 minimum)" |
6bb24f4d BB |
540 | |
541 | # | |
542 | # Disable SELinux until the ZFS Test Suite has been updated accordingly. | |
543 | # | |
c1d9abf9 JWK |
544 | if [ -x "$STF_PATH/setenforce" ]; then |
545 | sudo setenforce permissive &>/dev/null | |
6bb24f4d BB |
546 | fi |
547 | ||
00481e7d | 548 | # |
27ef66ef | 549 | # Enable internal ZFS debug log and clear it. |
00481e7d BB |
550 | # |
551 | if [ -e /sys/module/zfs/parameters/zfs_dbgmsg_enable ]; then | |
552 | sudo /bin/sh -c "echo 1 >/sys/module/zfs/parameters/zfs_dbgmsg_enable" | |
553 | sudo /bin/sh -c "echo 0 >/proc/spl/kstat/zfs/dbgmsg" | |
554 | fi | |
555 | ||
6bb24f4d BB |
556 | msg "FILEDIR: $FILEDIR" |
557 | msg "FILES: $FILES" | |
558 | msg "LOOPBACKS: $LOOPBACKS" | |
559 | msg "DISKS: $DISKS" | |
560 | msg "NUM_DISKS: $NUM_DISKS" | |
561 | msg "FILESIZE: $FILESIZE" | |
9a810efb GDN |
562 | msg "ITERATIONS: $ITERATIONS" |
563 | msg "TAGS: $TAGS" | |
6bb24f4d | 564 | msg "Keep pool(s): $KEEP" |
c1d9abf9 | 565 | msg "Missing util(s): $STF_MISSING_BIN" |
6bb24f4d BB |
566 | msg "" |
567 | ||
568 | export STF_TOOLS | |
569 | export STF_SUITE | |
c1d9abf9 | 570 | export STF_PATH |
6bb24f4d | 571 | export DISKS |
3fd3e56c | 572 | export FILEDIR |
6bb24f4d | 573 | export KEEP |
d21d5b82 | 574 | export __ZFS_POOL_EXCLUDE |
00481e7d | 575 | export TESTFAIL_CALLBACKS |
c1d9abf9 | 576 | export PATH=$STF_PATH |
6bb24f4d | 577 | |
e4a3297a BB |
578 | RESULTS_FILE=$(mktemp -u -t zts-results.XXXX -p "$FILEDIR") |
579 | REPORT_FILE=$(mktemp -u -t zts-report.XXXX -p "$FILEDIR") | |
580 | ||
581 | # | |
582 | # Run all the tests as specified. | |
583 | # | |
9a810efb GDN |
584 | msg "${TEST_RUNNER} ${QUIET} -c ${RUNFILE} -T ${TAGS} -i ${STF_SUITE}" \ |
585 | "-I ${ITERATIONS}" | |
586 | ${TEST_RUNNER} ${QUIET} -c "${RUNFILE}" -T "${TAGS}" -i "${STF_SUITE}" \ | |
e4a3297a BB |
587 | -I "${ITERATIONS}" 2>&1 | tee "$RESULTS_FILE" |
588 | ||
589 | # | |
590 | # Analyze the results. | |
591 | # | |
592 | set -o pipefail | |
593 | ${ZTS_REPORT} "$RESULTS_FILE" | tee "$REPORT_FILE" | |
6bb24f4d | 594 | RESULT=$? |
e4a3297a BB |
595 | set +o pipefail |
596 | ||
597 | RESULTS_DIR=$(awk '/^Log directory/ { print $3 }' "$RESULTS_FILE") | |
598 | if [ -d "$RESULTS_DIR" ]; then | |
599 | cat "$RESULTS_FILE" "$REPORT_FILE" >"$RESULTS_DIR/results" | |
600 | fi | |
601 | ||
602 | rm -f "$RESULTS_FILE" "$REPORT_FILE" | |
6bb24f4d | 603 | |
d8fa599f | 604 | if [ ${#SINGLETEST[@]} -ne 0 ]; then |
d25534f8 | 605 | rm -f "$RUNFILE" &>/dev/null |
d8fa599f GDN |
606 | fi |
607 | ||
6bb24f4d | 608 | exit ${RESULT} |