xref: /freebsd/sys/contrib/openzfs/scripts/zfs-tests.sh (revision 681ce946f33e75c590e97c53076e86dff1fe8f4a)
1eda14cbcSMatt Macy#!/bin/sh
2eda14cbcSMatt Macy#
3eda14cbcSMatt Macy# CDDL HEADER START
4eda14cbcSMatt Macy#
5eda14cbcSMatt Macy# The contents of this file are subject to the terms of the
6eda14cbcSMatt Macy# Common Development and Distribution License, Version 1.0 only
7eda14cbcSMatt Macy# (the "License").  You may not use this file except in compliance
8eda14cbcSMatt Macy# with the License.
9eda14cbcSMatt Macy#
10eda14cbcSMatt Macy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11eda14cbcSMatt Macy# or http://www.opensolaris.org/os/licensing.
12eda14cbcSMatt Macy# See the License for the specific language governing permissions
13eda14cbcSMatt Macy# and limitations under the License.
14eda14cbcSMatt Macy#
15eda14cbcSMatt Macy# When distributing Covered Code, include this CDDL HEADER in each
16eda14cbcSMatt Macy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17eda14cbcSMatt Macy# If applicable, add the following below this CDDL HEADER, with the
18eda14cbcSMatt Macy# fields enclosed by brackets "[]" replaced with your own identifying
19eda14cbcSMatt Macy# information: Portions Copyright [yyyy] [name of copyright owner]
20eda14cbcSMatt Macy#
21eda14cbcSMatt Macy# CDDL HEADER END
22eda14cbcSMatt Macy#
23eda14cbcSMatt Macy
24*681ce946SMartin Matuska#
25*681ce946SMartin Matuska# Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
26*681ce946SMartin Matuska#
27*681ce946SMartin Matuska
28eda14cbcSMatt MacyBASE_DIR=$(dirname "$0")
29eda14cbcSMatt MacySCRIPT_COMMON=common.sh
30eda14cbcSMatt Macyif [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then
31eda14cbcSMatt Macy. "${BASE_DIR}/${SCRIPT_COMMON}"
32eda14cbcSMatt Macyelse
33eda14cbcSMatt Macyecho "Missing helper script ${SCRIPT_COMMON}" && exit 1
34eda14cbcSMatt Macyfi
35eda14cbcSMatt Macy
36eda14cbcSMatt MacyPROG=zfs-tests.sh
37eda14cbcSMatt MacyVERBOSE="no"
38eda14cbcSMatt MacyQUIET=""
39eda14cbcSMatt MacyCLEANUP="yes"
40eda14cbcSMatt MacyCLEANUPALL="no"
41eda14cbcSMatt MacyLOOPBACK="yes"
42eda14cbcSMatt MacySTACK_TRACER="no"
43eda14cbcSMatt MacyFILESIZE="4G"
44eda14cbcSMatt MacyDEFAULT_RUNFILES="common.run,$(uname | tr '[:upper:]' '[:lower:]').run"
45eda14cbcSMatt MacyRUNFILES=${RUNFILES:-$DEFAULT_RUNFILES}
46eda14cbcSMatt MacyFILEDIR=${FILEDIR:-/var/tmp}
47eda14cbcSMatt MacyDISKS=${DISKS:-""}
48eda14cbcSMatt MacySINGLETEST=""
49eda14cbcSMatt MacySINGLETESTUSER="root"
50eda14cbcSMatt MacyTAGS=""
51eda14cbcSMatt MacyITERATIONS=1
52eda14cbcSMatt MacyZFS_DBGMSG="$STF_SUITE/callbacks/zfs_dbgmsg.ksh"
53eda14cbcSMatt MacyZFS_DMESG="$STF_SUITE/callbacks/zfs_dmesg.ksh"
54eda14cbcSMatt MacyUNAME=$(uname -s)
55*681ce946SMartin MatuskaRERUN=""
56eda14cbcSMatt Macy
57eda14cbcSMatt Macy# Override some defaults if on FreeBSD
58eda14cbcSMatt Macyif [ "$UNAME" = "FreeBSD" ] ; then
59eda14cbcSMatt Macy	TESTFAIL_CALLBACKS=${TESTFAIL_CALLBACKS:-"$ZFS_DMESG"}
60eda14cbcSMatt Macy	LOSETUP=/sbin/mdconfig
61eda14cbcSMatt Macy	DMSETUP=/sbin/gpart
62eda14cbcSMatt Macyelse
63eda14cbcSMatt Macy	ZFS_MMP="$STF_SUITE/callbacks/zfs_mmp.ksh"
64eda14cbcSMatt Macy	TESTFAIL_CALLBACKS=${TESTFAIL_CALLBACKS:-"$ZFS_DBGMSG:$ZFS_DMESG:$ZFS_MMP"}
65eda14cbcSMatt Macy	LOSETUP=${LOSETUP:-/sbin/losetup}
66eda14cbcSMatt Macy	DMSETUP=${DMSETUP:-/sbin/dmsetup}
67eda14cbcSMatt Macyfi
68eda14cbcSMatt Macy
69eda14cbcSMatt Macy#
70eda14cbcSMatt Macy# Log an informational message when additional verbosity is enabled.
71eda14cbcSMatt Macy#
72eda14cbcSMatt Macymsg() {
73eda14cbcSMatt Macy	if [ "$VERBOSE" = "yes" ]; then
74eda14cbcSMatt Macy		echo "$@"
75eda14cbcSMatt Macy	fi
76eda14cbcSMatt Macy}
77eda14cbcSMatt Macy
78eda14cbcSMatt Macy#
79eda14cbcSMatt Macy# Log a failure message, cleanup, and return an error.
80eda14cbcSMatt Macy#
81eda14cbcSMatt Macyfail() {
82eda14cbcSMatt Macy	echo "$PROG: $1" >&2
83eda14cbcSMatt Macy	cleanup
84eda14cbcSMatt Macy	exit 1
85eda14cbcSMatt Macy}
86eda14cbcSMatt Macy
87eda14cbcSMatt Macycleanup_freebsd_loopback() {
88eda14cbcSMatt Macy	for TEST_LOOPBACK in ${LOOPBACKS}; do
89eda14cbcSMatt Macy		if [ -c "/dev/${TEST_LOOPBACK}" ]; then
90eda14cbcSMatt Macy			sudo "${LOSETUP}" -d -u "${TEST_LOOPBACK}" ||
91eda14cbcSMatt Macy			    echo "Failed to destroy: ${TEST_LOOPBACK}"
92eda14cbcSMatt Macy		fi
93eda14cbcSMatt Macy	done
94eda14cbcSMatt Macy}
95eda14cbcSMatt Macy
96eda14cbcSMatt Macycleanup_linux_loopback() {
97eda14cbcSMatt Macy	for TEST_LOOPBACK in ${LOOPBACKS}; do
98dae17134SMartin Matuska		LOOP_DEV="${TEST_LOOPBACK##*/}"
99eda14cbcSMatt Macy		DM_DEV=$(sudo "${DMSETUP}" ls 2>/dev/null | \
100eda14cbcSMatt Macy		    grep "${LOOP_DEV}" | cut -f1)
101eda14cbcSMatt Macy
102eda14cbcSMatt Macy		if [ -n "$DM_DEV" ]; then
103eda14cbcSMatt Macy			sudo "${DMSETUP}" remove "${DM_DEV}" ||
104eda14cbcSMatt Macy			    echo "Failed to remove: ${DM_DEV}"
105eda14cbcSMatt Macy		fi
106eda14cbcSMatt Macy
107eda14cbcSMatt Macy		if [ -n "${TEST_LOOPBACK}" ]; then
108eda14cbcSMatt Macy			sudo "${LOSETUP}" -d "${TEST_LOOPBACK}" ||
109eda14cbcSMatt Macy			    echo "Failed to remove: ${TEST_LOOPBACK}"
110eda14cbcSMatt Macy		fi
111eda14cbcSMatt Macy	done
112eda14cbcSMatt Macy}
113eda14cbcSMatt Macy
114eda14cbcSMatt Macy#
115eda14cbcSMatt Macy# Attempt to remove loopback devices and files which where created earlier
116eda14cbcSMatt Macy# by this script to run the test framework.  The '-k' option may be passed
117eda14cbcSMatt Macy# to the script to suppress cleanup for debugging purposes.
118eda14cbcSMatt Macy#
119eda14cbcSMatt Macycleanup() {
120eda14cbcSMatt Macy	if [ "$CLEANUP" = "no" ]; then
121eda14cbcSMatt Macy		return 0
122eda14cbcSMatt Macy	fi
123eda14cbcSMatt Macy
124eda14cbcSMatt Macy
125eda14cbcSMatt Macy	if [ "$LOOPBACK" = "yes" ]; then
126eda14cbcSMatt Macy		if [ "$UNAME" = "FreeBSD" ] ; then
127eda14cbcSMatt Macy			cleanup_freebsd_loopback
128eda14cbcSMatt Macy		else
129eda14cbcSMatt Macy			cleanup_linux_loopback
130eda14cbcSMatt Macy		fi
131eda14cbcSMatt Macy	fi
132eda14cbcSMatt Macy
133eda14cbcSMatt Macy	for TEST_FILE in ${FILES}; do
134eda14cbcSMatt Macy		rm -f "${TEST_FILE}" >/dev/null 2>&1
135eda14cbcSMatt Macy	done
136eda14cbcSMatt Macy
137eda14cbcSMatt Macy	if [ "$STF_PATH_REMOVE" = "yes" ] && [ -d "$STF_PATH" ]; then
138eda14cbcSMatt Macy		rm -Rf "$STF_PATH"
139eda14cbcSMatt Macy	fi
140eda14cbcSMatt Macy}
141eda14cbcSMatt Macytrap cleanup EXIT
142eda14cbcSMatt Macy
143eda14cbcSMatt Macy#
144eda14cbcSMatt Macy# Attempt to remove all testpools (testpool.XXX), unopened dm devices,
145eda14cbcSMatt Macy# loopback devices, and files.  This is a useful way to cleanup a previous
146eda14cbcSMatt Macy# test run failure which has left the system in an unknown state.  This can
147eda14cbcSMatt Macy# be dangerous and should only be used in a dedicated test environment.
148eda14cbcSMatt Macy#
149eda14cbcSMatt Macycleanup_all() {
150eda14cbcSMatt Macy	TEST_POOLS=$(sudo "$ZPOOL" list -H -o name | grep testpool)
151eda14cbcSMatt Macy	if [ "$UNAME" = "FreeBSD" ] ; then
152eda14cbcSMatt Macy		TEST_LOOPBACKS=$(sudo "${LOSETUP}" -l)
153eda14cbcSMatt Macy	else
154eda14cbcSMatt Macy		TEST_LOOPBACKS=$(sudo "${LOSETUP}" -a|grep file-vdev|cut -f1 -d:)
155eda14cbcSMatt Macy	fi
156eda14cbcSMatt Macy	TEST_FILES=$(ls /var/tmp/file-vdev* 2>/dev/null)
157eda14cbcSMatt Macy
158eda14cbcSMatt Macy	msg
159eda14cbcSMatt Macy	msg "--- Cleanup ---"
160eda14cbcSMatt Macy	msg "Removing pool(s):     $(echo "${TEST_POOLS}" | tr '\n' ' ')"
161eda14cbcSMatt Macy	for TEST_POOL in $TEST_POOLS; do
162eda14cbcSMatt Macy		sudo "$ZPOOL" destroy "${TEST_POOL}"
163eda14cbcSMatt Macy	done
164eda14cbcSMatt Macy
165eda14cbcSMatt Macy	if [ "$UNAME" != "FreeBSD" ] ; then
166eda14cbcSMatt Macy		msg "Removing dm(s):       $(sudo "${DMSETUP}" ls |
167eda14cbcSMatt Macy		    grep loop | tr '\n' ' ')"
168eda14cbcSMatt Macy		sudo "${DMSETUP}" remove_all
169eda14cbcSMatt Macy	fi
170eda14cbcSMatt Macy
171eda14cbcSMatt Macy	msg "Removing loopback(s): $(echo "${TEST_LOOPBACKS}" | tr '\n' ' ')"
172eda14cbcSMatt Macy	for TEST_LOOPBACK in $TEST_LOOPBACKS; do
173eda14cbcSMatt Macy		if [ "$UNAME" = "FreeBSD" ] ; then
174eda14cbcSMatt Macy			sudo "${LOSETUP}" -d -u "${TEST_LOOPBACK}"
175eda14cbcSMatt Macy		else
176eda14cbcSMatt Macy			sudo "${LOSETUP}" -d "${TEST_LOOPBACK}"
177eda14cbcSMatt Macy		fi
178eda14cbcSMatt Macy	done
179eda14cbcSMatt Macy
180eda14cbcSMatt Macy	msg "Removing files(s):    $(echo "${TEST_FILES}" | tr '\n' ' ')"
181eda14cbcSMatt Macy	for TEST_FILE in $TEST_FILES; do
182eda14cbcSMatt Macy		sudo rm -f "${TEST_FILE}"
183eda14cbcSMatt Macy	done
184eda14cbcSMatt Macy}
185eda14cbcSMatt Macy
186eda14cbcSMatt Macy#
187eda14cbcSMatt Macy# Takes a name as the only arguments and looks for the following variations
188eda14cbcSMatt Macy# on that name.  If one is found it is returned.
189eda14cbcSMatt Macy#
190eda14cbcSMatt Macy# $RUNFILE_DIR/<name>
191eda14cbcSMatt Macy# $RUNFILE_DIR/<name>.run
192eda14cbcSMatt Macy# <name>
193eda14cbcSMatt Macy# <name>.run
194eda14cbcSMatt Macy#
195eda14cbcSMatt Macyfind_runfile() {
196eda14cbcSMatt Macy	NAME=$1
197eda14cbcSMatt Macy	RESULT=""
198eda14cbcSMatt Macy
199eda14cbcSMatt Macy	if [ -f "$RUNFILE_DIR/$NAME" ]; then
200eda14cbcSMatt Macy		RESULT="$RUNFILE_DIR/$NAME"
201eda14cbcSMatt Macy	elif [ -f "$RUNFILE_DIR/$NAME.run" ]; then
202eda14cbcSMatt Macy		RESULT="$RUNFILE_DIR/$NAME.run"
203eda14cbcSMatt Macy	elif [ -f "$NAME" ]; then
204eda14cbcSMatt Macy		RESULT="$NAME"
205eda14cbcSMatt Macy	elif [ -f "$NAME.run" ]; then
206eda14cbcSMatt Macy		RESULT="$NAME.run"
207eda14cbcSMatt Macy	fi
208eda14cbcSMatt Macy
209eda14cbcSMatt Macy	echo "$RESULT"
210eda14cbcSMatt Macy}
211eda14cbcSMatt Macy
212eda14cbcSMatt Macy#
213eda14cbcSMatt Macy# Symlink file if it appears under any of the given paths.
214eda14cbcSMatt Macy#
215eda14cbcSMatt Macycreate_links() {
216eda14cbcSMatt Macy	dir_list="$1"
217eda14cbcSMatt Macy	file_list="$2"
218eda14cbcSMatt Macy
219eda14cbcSMatt Macy	[ -n "$STF_PATH" ] || fail "STF_PATH wasn't correctly set"
220eda14cbcSMatt Macy
221eda14cbcSMatt Macy	for i in $file_list; do
222eda14cbcSMatt Macy		for j in $dir_list; do
223eda14cbcSMatt Macy			[ ! -e "$STF_PATH/$i" ] || continue
224eda14cbcSMatt Macy
225eda14cbcSMatt Macy			if [ ! -d "$j/$i" ] && [ -e "$j/$i" ]; then
226eda14cbcSMatt Macy				ln -sf "$j/$i" "$STF_PATH/$i" || \
227eda14cbcSMatt Macy				    fail "Couldn't link $i"
228eda14cbcSMatt Macy				break
229eda14cbcSMatt Macy			fi
230eda14cbcSMatt Macy		done
231eda14cbcSMatt Macy
232eda14cbcSMatt Macy		[ ! -e "$STF_PATH/$i" ] && \
233eda14cbcSMatt Macy		    STF_MISSING_BIN="$STF_MISSING_BIN $i"
234eda14cbcSMatt Macy	done
235eda14cbcSMatt Macy	STF_MISSING_BIN=${STF_MISSING_BIN# }
236eda14cbcSMatt Macy}
237eda14cbcSMatt Macy
238eda14cbcSMatt Macy#
239eda14cbcSMatt Macy# Constrain the path to limit the available binaries to a known set.
240eda14cbcSMatt Macy# When running in-tree a top level ./bin/ directory is created for
241eda14cbcSMatt Macy# convenience, otherwise a temporary directory is used.
242eda14cbcSMatt Macy#
243eda14cbcSMatt Macyconstrain_path() {
244eda14cbcSMatt Macy	. "$STF_SUITE/include/commands.cfg"
245eda14cbcSMatt Macy
246eda14cbcSMatt Macy	# On FreeBSD, base system zfs utils are in /sbin and OpenZFS utils
247eda14cbcSMatt Macy	# install to /usr/local/sbin. To avoid testing the wrong utils we
248eda14cbcSMatt Macy	# need /usr/local to come before / in the path search order.
249eda14cbcSMatt Macy	SYSTEM_DIRS="/usr/local/bin /usr/local/sbin"
2507877fdebSMatt Macy	SYSTEM_DIRS="$SYSTEM_DIRS /usr/bin /usr/sbin /bin /sbin $LIBEXEC_DIR"
251eda14cbcSMatt Macy
252eda14cbcSMatt Macy	if [ "$INTREE" = "yes" ]; then
253eda14cbcSMatt Macy		# Constrained path set to ./zfs/bin/
254eda14cbcSMatt Macy		STF_PATH="$BIN_DIR"
255eda14cbcSMatt Macy		STF_PATH_REMOVE="no"
256eda14cbcSMatt Macy		STF_MISSING_BIN=""
257eda14cbcSMatt Macy		if [ ! -d "$STF_PATH" ]; then
258eda14cbcSMatt Macy			mkdir "$STF_PATH"
259eda14cbcSMatt Macy			chmod 755 "$STF_PATH" || fail "Couldn't chmod $STF_PATH"
260eda14cbcSMatt Macy		fi
261eda14cbcSMatt Macy
262eda14cbcSMatt Macy		# Special case links for standard zfs utilities
263eda14cbcSMatt Macy		DIRS="$(find "$CMD_DIR" -type d \( ! -name .deps -a \
264eda14cbcSMatt Macy		    ! -name .libs \) -print | tr '\n' ' ')"
265eda14cbcSMatt Macy		create_links "$DIRS" "$ZFS_FILES"
266eda14cbcSMatt Macy
267eda14cbcSMatt Macy		# Special case links for zfs test suite utilities
268eda14cbcSMatt Macy		DIRS="$(find "$STF_SUITE" -type d \( ! -name .deps -a \
269eda14cbcSMatt Macy		    ! -name .libs \) -print | tr '\n' ' ')"
270eda14cbcSMatt Macy		create_links "$DIRS" "$ZFSTEST_FILES"
271eda14cbcSMatt Macy	else
272eda14cbcSMatt Macy		# Constrained path set to /var/tmp/constrained_path.*
2737877fdebSMatt Macy		SYSTEMDIR=${SYSTEMDIR:-/var/tmp/constrained_path.XXXXXX}
274eda14cbcSMatt Macy		STF_PATH=$(mktemp -d "$SYSTEMDIR")
275eda14cbcSMatt Macy		STF_PATH_REMOVE="yes"
276eda14cbcSMatt Macy		STF_MISSING_BIN=""
277eda14cbcSMatt Macy
278eda14cbcSMatt Macy		chmod 755 "$STF_PATH" || fail "Couldn't chmod $STF_PATH"
279eda14cbcSMatt Macy
280eda14cbcSMatt Macy		# Special case links for standard zfs utilities
281eda14cbcSMatt Macy		create_links "$SYSTEM_DIRS" "$ZFS_FILES"
282eda14cbcSMatt Macy
283eda14cbcSMatt Macy		# Special case links for zfs test suite utilities
284eda14cbcSMatt Macy		create_links "$STF_SUITE/bin" "$ZFSTEST_FILES"
285eda14cbcSMatt Macy	fi
286eda14cbcSMatt Macy
287eda14cbcSMatt Macy	# Standard system utilities
288eda14cbcSMatt Macy	SYSTEM_FILES="$SYSTEM_FILES_COMMON"
289eda14cbcSMatt Macy	if [ "$UNAME" = "FreeBSD" ] ; then
290eda14cbcSMatt Macy		SYSTEM_FILES="$SYSTEM_FILES $SYSTEM_FILES_FREEBSD"
291eda14cbcSMatt Macy	else
292eda14cbcSMatt Macy		SYSTEM_FILES="$SYSTEM_FILES $SYSTEM_FILES_LINUX"
293eda14cbcSMatt Macy	fi
294eda14cbcSMatt Macy	create_links "$SYSTEM_DIRS" "$SYSTEM_FILES"
295eda14cbcSMatt Macy
296eda14cbcSMatt Macy	# Exceptions
297eda14cbcSMatt Macy	ln -fs "$STF_PATH/awk" "$STF_PATH/nawk"
298eda14cbcSMatt Macy	if [ "$UNAME" = "Linux" ] ; then
299eda14cbcSMatt Macy		ln -fs /sbin/fsck.ext4 "$STF_PATH/fsck"
300eda14cbcSMatt Macy		ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs"
301eda14cbcSMatt Macy		ln -fs "$STF_PATH/gzip" "$STF_PATH/compress"
302eda14cbcSMatt Macy		ln -fs "$STF_PATH/gunzip" "$STF_PATH/uncompress"
303eda14cbcSMatt Macy		ln -fs "$STF_PATH/exportfs" "$STF_PATH/share"
304eda14cbcSMatt Macy		ln -fs "$STF_PATH/exportfs" "$STF_PATH/unshare"
305eda14cbcSMatt Macy	elif [ "$UNAME" = "FreeBSD" ] ; then
306eda14cbcSMatt Macy		ln -fs /usr/local/bin/ksh93 "$STF_PATH/ksh"
307eda14cbcSMatt Macy	fi
308eda14cbcSMatt Macy}
309eda14cbcSMatt Macy
310eda14cbcSMatt Macy#
311eda14cbcSMatt Macy# Output a useful usage message.
312eda14cbcSMatt Macy#
313eda14cbcSMatt Macyusage() {
314eda14cbcSMatt Macycat << EOF
315eda14cbcSMatt MacyUSAGE:
3162c48331dSMatt Macy$0 [-hvqxkfS] [-s SIZE] [-r RUNFILES] [-t PATH] [-u USER]
317eda14cbcSMatt Macy
318eda14cbcSMatt MacyDESCRIPTION:
319eda14cbcSMatt Macy	ZFS Test Suite launch script
320eda14cbcSMatt Macy
321eda14cbcSMatt MacyOPTIONS:
322eda14cbcSMatt Macy	-h          Show this message
323eda14cbcSMatt Macy	-v          Verbose zfs-tests.sh output
324eda14cbcSMatt Macy	-q          Quiet test-runner output
325eda14cbcSMatt Macy	-x          Remove all testpools, dm, lo, and files (unsafe)
326eda14cbcSMatt Macy	-k          Disable cleanup after test failure
327eda14cbcSMatt Macy	-f          Use files only, disables block device tests
328eda14cbcSMatt Macy	-S          Enable stack tracer (negative performance impact)
329eda14cbcSMatt Macy	-c          Only create and populate constrained path
330*681ce946SMartin Matuska	-R          Automatically rerun failing tests
331eda14cbcSMatt Macy	-n NFSFILE  Use the nfsfile to determine the NFS configuration
332eda14cbcSMatt Macy	-I NUM      Number of iterations
333eda14cbcSMatt Macy	-d DIR      Use DIR for files and loopback devices
334eda14cbcSMatt Macy	-s SIZE     Use vdevs of SIZE (default: 4G)
335eda14cbcSMatt Macy	-r RUNFILES Run tests in RUNFILES (default: ${DEFAULT_RUNFILES})
336eda14cbcSMatt Macy	-t PATH     Run single test at PATH relative to test suite
337eda14cbcSMatt Macy	-T TAGS     Comma separated list of tags (default: 'functional')
338eda14cbcSMatt Macy	-u USER     Run single test as USER (default: root)
339eda14cbcSMatt Macy
340eda14cbcSMatt MacyEXAMPLES:
341eda14cbcSMatt Macy# Run the default (linux) suite of tests and output the configuration used.
342eda14cbcSMatt Macy$0 -v
343eda14cbcSMatt Macy
344eda14cbcSMatt Macy# Run a smaller suite of tests designed to run more quickly.
345eda14cbcSMatt Macy$0 -r linux-fast
346eda14cbcSMatt Macy
347eda14cbcSMatt Macy# Run a single test
348eda14cbcSMatt Macy$0 -t tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh
349eda14cbcSMatt Macy
350eda14cbcSMatt Macy# Cleanup a previous run of the test suite prior to testing, run the
351eda14cbcSMatt Macy# default (linux) suite of tests and perform no cleanup on exit.
352eda14cbcSMatt Macy$0 -x
353eda14cbcSMatt Macy
354eda14cbcSMatt MacyEOF
355eda14cbcSMatt Macy}
356eda14cbcSMatt Macy
357*681ce946SMartin Matuskawhile getopts 'hvqxkfScRn:d:s:r:?t:T:u:I:' OPTION; do
358eda14cbcSMatt Macy	case $OPTION in
359eda14cbcSMatt Macy	h)
360eda14cbcSMatt Macy		usage
361eda14cbcSMatt Macy		exit 1
362eda14cbcSMatt Macy		;;
363eda14cbcSMatt Macy	v)
364eda14cbcSMatt Macy		VERBOSE="yes"
365eda14cbcSMatt Macy		;;
366eda14cbcSMatt Macy	q)
367eda14cbcSMatt Macy		QUIET="yes"
368eda14cbcSMatt Macy		;;
369eda14cbcSMatt Macy	x)
370eda14cbcSMatt Macy		CLEANUPALL="yes"
371eda14cbcSMatt Macy		;;
372eda14cbcSMatt Macy	k)
373eda14cbcSMatt Macy		CLEANUP="no"
374eda14cbcSMatt Macy		;;
375eda14cbcSMatt Macy	f)
376eda14cbcSMatt Macy		LOOPBACK="no"
377eda14cbcSMatt Macy		;;
378eda14cbcSMatt Macy	S)
379eda14cbcSMatt Macy		STACK_TRACER="yes"
380eda14cbcSMatt Macy		;;
381eda14cbcSMatt Macy	c)
382eda14cbcSMatt Macy		constrain_path
383eda14cbcSMatt Macy		exit
384eda14cbcSMatt Macy		;;
385*681ce946SMartin Matuska	R)
386*681ce946SMartin Matuska		RERUN="yes"
387*681ce946SMartin Matuska		;;
388eda14cbcSMatt Macy	n)
389eda14cbcSMatt Macy		nfsfile=$OPTARG
390eda14cbcSMatt Macy		[ -f "$nfsfile" ] || fail "Cannot read file: $nfsfile"
391eda14cbcSMatt Macy		export NFS=1
392eda14cbcSMatt Macy		. "$nfsfile"
393eda14cbcSMatt Macy		;;
394eda14cbcSMatt Macy	d)
395eda14cbcSMatt Macy		FILEDIR="$OPTARG"
396eda14cbcSMatt Macy		;;
397eda14cbcSMatt Macy	I)
398eda14cbcSMatt Macy		ITERATIONS="$OPTARG"
399eda14cbcSMatt Macy		if [ "$ITERATIONS" -le 0 ]; then
400eda14cbcSMatt Macy			fail "Iterations must be greater than 0."
401eda14cbcSMatt Macy		fi
402eda14cbcSMatt Macy		;;
403eda14cbcSMatt Macy	s)
404eda14cbcSMatt Macy		FILESIZE="$OPTARG"
405eda14cbcSMatt Macy		;;
406eda14cbcSMatt Macy	r)
407eda14cbcSMatt Macy		RUNFILES="$OPTARG"
408eda14cbcSMatt Macy		;;
409eda14cbcSMatt Macy	t)
410eda14cbcSMatt Macy		if [ -n "$SINGLETEST" ]; then
411eda14cbcSMatt Macy			fail "-t can only be provided once."
412eda14cbcSMatt Macy		fi
413eda14cbcSMatt Macy		SINGLETEST="$OPTARG"
414eda14cbcSMatt Macy		;;
415eda14cbcSMatt Macy	T)
416eda14cbcSMatt Macy		TAGS="$OPTARG"
417eda14cbcSMatt Macy		;;
418eda14cbcSMatt Macy	u)
419eda14cbcSMatt Macy		SINGLETESTUSER="$OPTARG"
420eda14cbcSMatt Macy		;;
421eda14cbcSMatt Macy	?)
422eda14cbcSMatt Macy		usage
423eda14cbcSMatt Macy		exit
424eda14cbcSMatt Macy		;;
425eda14cbcSMatt Macy	esac
426eda14cbcSMatt Macydone
427eda14cbcSMatt Macy
428eda14cbcSMatt Macyshift $((OPTIND-1))
429eda14cbcSMatt Macy
430eda14cbcSMatt MacyFILES=${FILES:-"$FILEDIR/file-vdev0 $FILEDIR/file-vdev1 $FILEDIR/file-vdev2"}
431eda14cbcSMatt MacyLOOPBACKS=${LOOPBACKS:-""}
432eda14cbcSMatt Macy
433eda14cbcSMatt Macyif [ -n "$SINGLETEST" ]; then
434eda14cbcSMatt Macy	if [ -n "$TAGS" ]; then
435eda14cbcSMatt Macy		fail "-t and -T are mutually exclusive."
436eda14cbcSMatt Macy	fi
437eda14cbcSMatt Macy	RUNFILE_DIR="/var/tmp"
438eda14cbcSMatt Macy	RUNFILES="zfs-tests.$$.run"
439eda14cbcSMatt Macy	SINGLEQUIET="False"
440eda14cbcSMatt Macy
441eda14cbcSMatt Macy	if [ -n "$QUIET" ]; then
442eda14cbcSMatt Macy		SINGLEQUIET="True"
443eda14cbcSMatt Macy	fi
444eda14cbcSMatt Macy
445eda14cbcSMatt Macy	cat >$RUNFILE_DIR/$RUNFILES << EOF
446eda14cbcSMatt Macy[DEFAULT]
447eda14cbcSMatt Macypre =
448eda14cbcSMatt Macyquiet = $SINGLEQUIET
449eda14cbcSMatt Macypre_user = root
450eda14cbcSMatt Macyuser = $SINGLETESTUSER
451eda14cbcSMatt Macytimeout = 600
452eda14cbcSMatt Macypost_user = root
453eda14cbcSMatt Macypost =
454eda14cbcSMatt Macyoutputdir = /var/tmp/test_results
455eda14cbcSMatt MacyEOF
456eda14cbcSMatt Macy	SINGLETESTDIR=$(dirname "$SINGLETEST")
457eda14cbcSMatt Macy	SINGLETESTFILE=$(basename "$SINGLETEST")
458eda14cbcSMatt Macy	SETUPSCRIPT=
459eda14cbcSMatt Macy	CLEANUPSCRIPT=
460eda14cbcSMatt Macy
461eda14cbcSMatt Macy	if [ -f "$STF_SUITE/$SINGLETESTDIR/setup.ksh" ]; then
462eda14cbcSMatt Macy		SETUPSCRIPT="setup"
463eda14cbcSMatt Macy	fi
464eda14cbcSMatt Macy
465eda14cbcSMatt Macy	if [ -f "$STF_SUITE/$SINGLETESTDIR/cleanup.ksh" ]; then
466eda14cbcSMatt Macy		CLEANUPSCRIPT="cleanup"
467eda14cbcSMatt Macy	fi
468eda14cbcSMatt Macy
469eda14cbcSMatt Macy	cat >>$RUNFILE_DIR/$RUNFILES << EOF
470eda14cbcSMatt Macy
471eda14cbcSMatt Macy[$SINGLETESTDIR]
472eda14cbcSMatt Macytests = ['$SINGLETESTFILE']
473eda14cbcSMatt Macypre = $SETUPSCRIPT
474eda14cbcSMatt Macypost = $CLEANUPSCRIPT
475eda14cbcSMatt Macytags = ['functional']
476eda14cbcSMatt MacyEOF
477eda14cbcSMatt Macyfi
478eda14cbcSMatt Macy
479eda14cbcSMatt Macy#
480eda14cbcSMatt Macy# Use default tag if none was specified
481eda14cbcSMatt Macy#
482eda14cbcSMatt MacyTAGS=${TAGS:='functional'}
483eda14cbcSMatt Macy
484eda14cbcSMatt Macy#
485eda14cbcSMatt Macy# Attempt to locate the runfiles describing the test workload.
486eda14cbcSMatt Macy#
487eda14cbcSMatt MacyR=""
488eda14cbcSMatt MacyIFS=,
489eda14cbcSMatt Macyfor RUNFILE in $RUNFILES; do
490eda14cbcSMatt Macy	if [ -n "$RUNFILE" ]; then
491eda14cbcSMatt Macy		SAVED_RUNFILE="$RUNFILE"
492eda14cbcSMatt Macy		RUNFILE=$(find_runfile "$RUNFILE")
493eda14cbcSMatt Macy		[ -z "$RUNFILE" ] && fail "Cannot find runfile: $SAVED_RUNFILE"
494eda14cbcSMatt Macy		R="$R,$RUNFILE"
495eda14cbcSMatt Macy	fi
496eda14cbcSMatt Macy
497eda14cbcSMatt Macy	if [ ! -r "$RUNFILE" ]; then
498eda14cbcSMatt Macy		fail "Cannot read runfile: $RUNFILE"
499eda14cbcSMatt Macy	fi
500eda14cbcSMatt Macydone
501eda14cbcSMatt Macyunset IFS
502eda14cbcSMatt MacyRUNFILES=${R#,}
503eda14cbcSMatt Macy
504eda14cbcSMatt Macy#
505eda14cbcSMatt Macy# This script should not be run as root.  Instead the test user, which may
506eda14cbcSMatt Macy# be a normal user account, needs to be configured such that it can
507eda14cbcSMatt Macy# run commands via sudo passwordlessly.
508eda14cbcSMatt Macy#
509eda14cbcSMatt Macyif [ "$(id -u)" = "0" ]; then
510eda14cbcSMatt Macy	fail "This script must not be run as root."
511eda14cbcSMatt Macyfi
512eda14cbcSMatt Macy
513eda14cbcSMatt Macyif [ "$(sudo whoami)" != "root" ]; then
514eda14cbcSMatt Macy	fail "Passwordless sudo access required."
515eda14cbcSMatt Macyfi
516eda14cbcSMatt Macy
517eda14cbcSMatt Macy#
518eda14cbcSMatt Macy# Constrain the available binaries to a known set.
519eda14cbcSMatt Macy#
520eda14cbcSMatt Macyconstrain_path
521eda14cbcSMatt Macy
522eda14cbcSMatt Macy#
523eda14cbcSMatt Macy# Check if ksh exists
524eda14cbcSMatt Macy#
525eda14cbcSMatt Macyif [ "$UNAME" = "FreeBSD" ]; then
526eda14cbcSMatt Macy	sudo ln -fs /usr/local/bin/ksh93 /bin/ksh
527eda14cbcSMatt Macyfi
528eda14cbcSMatt Macy[ -e "$STF_PATH/ksh" ] || fail "This test suite requires ksh."
529eda14cbcSMatt Macy[ -e "$STF_SUITE/include/default.cfg" ] || fail \
530eda14cbcSMatt Macy    "Missing $STF_SUITE/include/default.cfg file."
531eda14cbcSMatt Macy
532eda14cbcSMatt Macy#
533eda14cbcSMatt Macy# Verify the ZFS module stack is loaded.
534eda14cbcSMatt Macy#
535eda14cbcSMatt Macyif [ "$STACK_TRACER" = "yes" ]; then
536eda14cbcSMatt Macy	sudo "${ZFS_SH}" -S >/dev/null 2>&1
537eda14cbcSMatt Macyelse
538eda14cbcSMatt Macy	sudo "${ZFS_SH}" >/dev/null 2>&1
539eda14cbcSMatt Macyfi
540eda14cbcSMatt Macy
541eda14cbcSMatt Macy#
542eda14cbcSMatt Macy# Attempt to cleanup all previous state for a new test run.
543eda14cbcSMatt Macy#
544eda14cbcSMatt Macyif [ "$CLEANUPALL" = "yes" ]; then
545eda14cbcSMatt Macy	cleanup_all
546eda14cbcSMatt Macyfi
547eda14cbcSMatt Macy
548eda14cbcSMatt Macy#
549eda14cbcSMatt Macy# By default preserve any existing pools
550eda14cbcSMatt Macy# NOTE: Since 'zpool list' outputs a newline-delimited list convert $KEEP from
551eda14cbcSMatt Macy# space-delimited to newline-delimited.
552eda14cbcSMatt Macy#
553eda14cbcSMatt Macyif [ -z "${KEEP}" ]; then
554eda14cbcSMatt Macy	KEEP="$(sudo "$ZPOOL" list -H -o name)"
555eda14cbcSMatt Macy	if [ -z "${KEEP}" ]; then
556eda14cbcSMatt Macy		KEEP="rpool"
557eda14cbcSMatt Macy	fi
558eda14cbcSMatt Macyelse
559eda14cbcSMatt Macy	KEEP="$(echo "$KEEP" | tr '[:blank:]' '\n')"
560eda14cbcSMatt Macyfi
561eda14cbcSMatt Macy
562eda14cbcSMatt Macy#
563eda14cbcSMatt Macy# NOTE: The following environment variables are undocumented
564eda14cbcSMatt Macy# and should be used for testing purposes only:
565eda14cbcSMatt Macy#
566eda14cbcSMatt Macy# __ZFS_POOL_EXCLUDE - don't iterate over the pools it lists
567eda14cbcSMatt Macy# __ZFS_POOL_RESTRICT - iterate only over the pools it lists
568eda14cbcSMatt Macy#
569eda14cbcSMatt Macy# See libzfs/libzfs_config.c for more information.
570eda14cbcSMatt Macy#
571eda14cbcSMatt Macyif [ "$UNAME" = "FreeBSD" ] ; then
572eda14cbcSMatt Macy	__ZFS_POOL_EXCLUDE="$(echo "$KEEP" | tr -s '\n' ' ')"
573eda14cbcSMatt Macyelse
574eda14cbcSMatt Macy	__ZFS_POOL_EXCLUDE="$(echo "$KEEP" | sed ':a;N;s/\n/ /g;ba')"
575eda14cbcSMatt Macyfi
576eda14cbcSMatt Macy
577eda14cbcSMatt Macy. "$STF_SUITE/include/default.cfg"
578eda14cbcSMatt Macy
579eda14cbcSMatt Macy#
580eda14cbcSMatt Macy# No DISKS have been provided so a basic file or loopback based devices
581eda14cbcSMatt Macy# must be created for the test suite to use.
582eda14cbcSMatt Macy#
583eda14cbcSMatt Macyif [ -z "${DISKS}" ]; then
584eda14cbcSMatt Macy	#
5851f88aa09SMartin Matuska	# If this is a performance run, prevent accidental use of
5861f88aa09SMartin Matuska	# loopback devices.
5871f88aa09SMartin Matuska	#
5881f88aa09SMartin Matuska	[ "$TAGS" = "perf" ] && fail "Running perf tests without disks."
5891f88aa09SMartin Matuska
5901f88aa09SMartin Matuska	#
591eda14cbcSMatt Macy	# Create sparse files for the test suite.  These may be used
592eda14cbcSMatt Macy	# directory or have loopback devices layered on them.
593eda14cbcSMatt Macy	#
594eda14cbcSMatt Macy	for TEST_FILE in ${FILES}; do
595eda14cbcSMatt Macy		[ -f "$TEST_FILE" ] && fail "Failed file exists: ${TEST_FILE}"
596eda14cbcSMatt Macy		truncate -s "${FILESIZE}" "${TEST_FILE}" ||
597eda14cbcSMatt Macy		    fail "Failed creating: ${TEST_FILE} ($?)"
598eda14cbcSMatt Macy	done
599eda14cbcSMatt Macy
600eda14cbcSMatt Macy	#
601eda14cbcSMatt Macy	# If requested setup loopback devices backed by the sparse files.
602eda14cbcSMatt Macy	#
603eda14cbcSMatt Macy	if [ "$LOOPBACK" = "yes" ]; then
604eda14cbcSMatt Macy		test -x "$LOSETUP" || fail "$LOSETUP utility must be installed"
605eda14cbcSMatt Macy
606eda14cbcSMatt Macy		for TEST_FILE in ${FILES}; do
607eda14cbcSMatt Macy			if [ "$UNAME" = "FreeBSD" ] ; then
608eda14cbcSMatt Macy				MDDEVICE=$(sudo "${LOSETUP}" -a -t vnode -f "${TEST_FILE}")
609eda14cbcSMatt Macy				if [ -z "$MDDEVICE" ] ; then
610eda14cbcSMatt Macy					fail "Failed: ${TEST_FILE} -> loopback"
611eda14cbcSMatt Macy				fi
612eda14cbcSMatt Macy				DISKS="$DISKS $MDDEVICE"
613eda14cbcSMatt Macy				LOOPBACKS="$LOOPBACKS $MDDEVICE"
614eda14cbcSMatt Macy			else
615eda14cbcSMatt Macy				TEST_LOOPBACK=$(sudo "${LOSETUP}" -f)
616eda14cbcSMatt Macy				sudo "${LOSETUP}" "${TEST_LOOPBACK}" "${TEST_FILE}" ||
617eda14cbcSMatt Macy				    fail "Failed: ${TEST_FILE} -> ${TEST_LOOPBACK}"
618dae17134SMartin Matuska				BASELOOPBACK="${TEST_LOOPBACK##*/}"
619eda14cbcSMatt Macy				DISKS="$DISKS $BASELOOPBACK"
620eda14cbcSMatt Macy				LOOPBACKS="$LOOPBACKS $TEST_LOOPBACK"
621eda14cbcSMatt Macy			fi
622eda14cbcSMatt Macy		done
623eda14cbcSMatt Macy		DISKS=${DISKS# }
624eda14cbcSMatt Macy		LOOPBACKS=${LOOPBACKS# }
625eda14cbcSMatt Macy	else
626eda14cbcSMatt Macy		DISKS="$FILES"
627eda14cbcSMatt Macy	fi
628eda14cbcSMatt Macyfi
629eda14cbcSMatt Macy
6301f88aa09SMartin Matuska#
6311f88aa09SMartin Matuska# It may be desirable to test with fewer disks than the default when running
6321f88aa09SMartin Matuska# the performance tests, but the functional tests require at least three.
6331f88aa09SMartin Matuska#
634eda14cbcSMatt MacyNUM_DISKS=$(echo "${DISKS}" | awk '{print NF}')
6351f88aa09SMartin Matuskaif [ "$TAGS" != "perf" ]; then
636eda14cbcSMatt Macy	[ "$NUM_DISKS" -lt 3 ] && fail "Not enough disks ($NUM_DISKS/3 minimum)"
6371f88aa09SMartin Matuskafi
638eda14cbcSMatt Macy
639eda14cbcSMatt Macy#
640eda14cbcSMatt Macy# Disable SELinux until the ZFS Test Suite has been updated accordingly.
641eda14cbcSMatt Macy#
642eda14cbcSMatt Macyif [ -x "$STF_PATH/setenforce" ]; then
643eda14cbcSMatt Macy	sudo setenforce permissive >/dev/null 2>&1
644eda14cbcSMatt Macyfi
645eda14cbcSMatt Macy
646eda14cbcSMatt Macy#
647eda14cbcSMatt Macy# Enable internal ZFS debug log and clear it.
648eda14cbcSMatt Macy#
649eda14cbcSMatt Macyif [ -e /sys/module/zfs/parameters/zfs_dbgmsg_enable ]; then
650eda14cbcSMatt Macy	sudo /bin/sh -c "echo 1 >/sys/module/zfs/parameters/zfs_dbgmsg_enable"
651eda14cbcSMatt Macy	sudo /bin/sh -c "echo 0 >/proc/spl/kstat/zfs/dbgmsg"
652eda14cbcSMatt Macyfi
653eda14cbcSMatt Macy
6541f88aa09SMartin Matuskamsg
6551f88aa09SMartin Matuskamsg "--- Configuration ---"
6561f88aa09SMartin Matuskamsg "Runfiles:        $RUNFILES"
6571f88aa09SMartin Matuskamsg "STF_TOOLS:       $STF_TOOLS"
6581f88aa09SMartin Matuskamsg "STF_SUITE:       $STF_SUITE"
6591f88aa09SMartin Matuskamsg "STF_PATH:        $STF_PATH"
660eda14cbcSMatt Macymsg "FILEDIR:         $FILEDIR"
661eda14cbcSMatt Macymsg "FILES:           $FILES"
662eda14cbcSMatt Macymsg "LOOPBACKS:       $LOOPBACKS"
663eda14cbcSMatt Macymsg "DISKS:           $DISKS"
664eda14cbcSMatt Macymsg "NUM_DISKS:       $NUM_DISKS"
665eda14cbcSMatt Macymsg "FILESIZE:        $FILESIZE"
666eda14cbcSMatt Macymsg "ITERATIONS:      $ITERATIONS"
667eda14cbcSMatt Macymsg "TAGS:            $TAGS"
668eda14cbcSMatt Macymsg "STACK_TRACER:    $STACK_TRACER"
669eda14cbcSMatt Macymsg "Keep pool(s):    $KEEP"
670eda14cbcSMatt Macymsg "Missing util(s): $STF_MISSING_BIN"
671eda14cbcSMatt Macymsg ""
672eda14cbcSMatt Macy
673eda14cbcSMatt Macyexport STF_TOOLS
674eda14cbcSMatt Macyexport STF_SUITE
675eda14cbcSMatt Macyexport STF_PATH
676eda14cbcSMatt Macyexport DISKS
677eda14cbcSMatt Macyexport FILEDIR
678eda14cbcSMatt Macyexport KEEP
679eda14cbcSMatt Macyexport __ZFS_POOL_EXCLUDE
680eda14cbcSMatt Macyexport TESTFAIL_CALLBACKS
681eda14cbcSMatt Macyexport PATH=$STF_PATH
682eda14cbcSMatt Macy
683eda14cbcSMatt Macyif [ "$UNAME" = "FreeBSD" ] ; then
684eda14cbcSMatt Macy	mkdir -p "$FILEDIR" || true
6857877fdebSMatt Macy	RESULTS_FILE=$(mktemp -u "${FILEDIR}/zts-results.XXXXXX")
6867877fdebSMatt Macy	REPORT_FILE=$(mktemp -u "${FILEDIR}/zts-report.XXXXXX")
687eda14cbcSMatt Macyelse
6887877fdebSMatt Macy	RESULTS_FILE=$(mktemp -u -t zts-results.XXXXXX -p "$FILEDIR")
6897877fdebSMatt Macy	REPORT_FILE=$(mktemp -u -t zts-report.XXXXXX -p "$FILEDIR")
690eda14cbcSMatt Macyfi
691eda14cbcSMatt Macy
692eda14cbcSMatt Macy#
693eda14cbcSMatt Macy# Run all the tests as specified.
694eda14cbcSMatt Macy#
695eda14cbcSMatt Macymsg "${TEST_RUNNER} ${QUIET:+-q}" \
696eda14cbcSMatt Macy    "-c \"${RUNFILES}\"" \
697eda14cbcSMatt Macy    "-T \"${TAGS}\"" \
698eda14cbcSMatt Macy    "-i \"${STF_SUITE}\"" \
699eda14cbcSMatt Macy    "-I \"${ITERATIONS}\""
700eda14cbcSMatt Macy${TEST_RUNNER} ${QUIET:+-q} \
701eda14cbcSMatt Macy    -c "${RUNFILES}" \
702eda14cbcSMatt Macy    -T "${TAGS}" \
703eda14cbcSMatt Macy    -i "${STF_SUITE}" \
704eda14cbcSMatt Macy    -I "${ITERATIONS}" \
705eda14cbcSMatt Macy    2>&1 | tee "$RESULTS_FILE"
706eda14cbcSMatt Macy#
707eda14cbcSMatt Macy# Analyze the results.
708eda14cbcSMatt Macy#
709*681ce946SMartin Matuska${ZTS_REPORT} ${RERUN:+--no-maybes} "$RESULTS_FILE" >"$REPORT_FILE"
710eda14cbcSMatt MacyRESULT=$?
711*681ce946SMartin Matuska
712*681ce946SMartin Matuskaif [ "$RESULT" -eq "2" ] && [ -n "$RERUN" ]; then
713*681ce946SMartin Matuska	MAYBES="$($ZTS_REPORT --list-maybes)"
714*681ce946SMartin Matuska	TEMP_RESULTS_FILE=$(mktemp -u -t zts-results-tmp.XXXXX -p "$FILEDIR")
715*681ce946SMartin Matuska	TEST_LIST=$(mktemp -u -t test-list.XXXXX -p "$FILEDIR")
716*681ce946SMartin Matuska	grep "^Test:.*\[FAIL\]" "$RESULTS_FILE" >"$TEMP_RESULTS_FILE"
717*681ce946SMartin Matuska	for test_name in $MAYBES; do
718*681ce946SMartin Matuska		grep "$test_name " "$TEMP_RESULTS_FILE" >>"$TEST_LIST"
719*681ce946SMartin Matuska	done
720*681ce946SMartin Matuska	${TEST_RUNNER} ${QUIET:+-q} \
721*681ce946SMartin Matuska	    -c "${RUNFILES}" \
722*681ce946SMartin Matuska	    -T "${TAGS}" \
723*681ce946SMartin Matuska	    -i "${STF_SUITE}" \
724*681ce946SMartin Matuska	    -I "${ITERATIONS}" \
725*681ce946SMartin Matuska	    -l "${TEST_LIST}" \
726*681ce946SMartin Matuska	    2>&1 | tee "$RESULTS_FILE"
727*681ce946SMartin Matuska	#
728*681ce946SMartin Matuska	# Analyze the results.
729*681ce946SMartin Matuska	#
730*681ce946SMartin Matuska	${ZTS_REPORT} --no-maybes "$RESULTS_FILE" >"$REPORT_FILE"
731*681ce946SMartin Matuska	RESULT=$?
732*681ce946SMartin Matuskafi
733*681ce946SMartin Matuska
734*681ce946SMartin Matuska
735eda14cbcSMatt Macycat "$REPORT_FILE"
736eda14cbcSMatt Macy
737eda14cbcSMatt MacyRESULTS_DIR=$(awk '/^Log directory/ { print $3 }' "$RESULTS_FILE")
738eda14cbcSMatt Macyif [ -d "$RESULTS_DIR" ]; then
739eda14cbcSMatt Macy	cat "$RESULTS_FILE" "$REPORT_FILE" >"$RESULTS_DIR/results"
740eda14cbcSMatt Macyfi
741eda14cbcSMatt Macy
742eda14cbcSMatt Macyrm -f "$RESULTS_FILE" "$REPORT_FILE"
743eda14cbcSMatt Macy
744eda14cbcSMatt Macyif [ -n "$SINGLETEST" ]; then
745eda14cbcSMatt Macy	rm -f "$RUNFILES" >/dev/null 2>&1
746eda14cbcSMatt Macyfi
747eda14cbcSMatt Macy
748eda14cbcSMatt Macyexit ${RESULT}
749