1eda14cbcSMatt Macy#!/bin/sh 2e92ffd9bSMartin Matuska# shellcheck disable=SC2154 3eda14cbcSMatt Macy# 4eda14cbcSMatt Macy# CDDL HEADER START 5eda14cbcSMatt Macy# 6eda14cbcSMatt Macy# The contents of this file are subject to the terms of the 7eda14cbcSMatt Macy# Common Development and Distribution License, Version 1.0 only 8eda14cbcSMatt Macy# (the "License"). You may not use this file except in compliance 9eda14cbcSMatt Macy# with the License. 10eda14cbcSMatt Macy# 11eda14cbcSMatt Macy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 12271171e0SMartin Matuska# or https://opensource.org/licenses/CDDL-1.0. 13eda14cbcSMatt Macy# See the License for the specific language governing permissions 14eda14cbcSMatt Macy# and limitations under the License. 15eda14cbcSMatt Macy# 16eda14cbcSMatt Macy# When distributing Covered Code, include this CDDL HEADER in each 17eda14cbcSMatt Macy# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 18eda14cbcSMatt Macy# If applicable, add the following below this CDDL HEADER, with the 19eda14cbcSMatt Macy# fields enclosed by brackets "[]" replaced with your own identifying 20eda14cbcSMatt Macy# information: Portions Copyright [yyyy] [name of copyright owner] 21eda14cbcSMatt Macy# 22eda14cbcSMatt Macy# CDDL HEADER END 23eda14cbcSMatt Macy# 24eda14cbcSMatt Macy 25681ce946SMartin Matuska# 26681ce946SMartin Matuska# Copyright 2020 OmniOS Community Edition (OmniOSce) Association. 27681ce946SMartin Matuska# 28681ce946SMartin Matuska 29716fd348SMartin MatuskaSCRIPT_COMMON=${SCRIPT_COMMON:-${0%/*}/common.sh} 30716fd348SMartin Matuska. "${SCRIPT_COMMON}" || exit 31eda14cbcSMatt Macy 32eda14cbcSMatt MacyPROG=zfs-tests.sh 33eda14cbcSMatt MacyVERBOSE="no" 34eda14cbcSMatt MacyQUIET="" 35*0d4ad640SMartin MatuskaDEBUG="" 36eda14cbcSMatt MacyCLEANUP="yes" 37eda14cbcSMatt MacyCLEANUPALL="no" 38da5137abSMartin MatuskaKMSG="" 39eda14cbcSMatt MacyLOOPBACK="yes" 40eda14cbcSMatt MacySTACK_TRACER="no" 41eda14cbcSMatt MacyFILESIZE="4G" 42eda14cbcSMatt MacyDEFAULT_RUNFILES="common.run,$(uname | tr '[:upper:]' '[:lower:]').run" 43eda14cbcSMatt MacyRUNFILES=${RUNFILES:-$DEFAULT_RUNFILES} 44eda14cbcSMatt MacyFILEDIR=${FILEDIR:-/var/tmp} 45eda14cbcSMatt MacyDISKS=${DISKS:-""} 46eda14cbcSMatt MacySINGLETEST="" 47eda14cbcSMatt MacySINGLETESTUSER="root" 48eda14cbcSMatt MacyTAGS="" 49eda14cbcSMatt MacyITERATIONS=1 50eda14cbcSMatt MacyZFS_DBGMSG="$STF_SUITE/callbacks/zfs_dbgmsg.ksh" 51eda14cbcSMatt MacyZFS_DMESG="$STF_SUITE/callbacks/zfs_dmesg.ksh" 52716fd348SMartin MatuskaUNAME=$(uname) 53681ce946SMartin MatuskaRERUN="" 54c03c5b1cSMartin MatuskaKMEMLEAK="" 55eda14cbcSMatt Macy 56eda14cbcSMatt Macy# Override some defaults if on FreeBSD 57eda14cbcSMatt Macyif [ "$UNAME" = "FreeBSD" ] ; then 58eda14cbcSMatt Macy TESTFAIL_CALLBACKS=${TESTFAIL_CALLBACKS:-"$ZFS_DMESG"} 59eda14cbcSMatt Macy LOSETUP=/sbin/mdconfig 60eda14cbcSMatt Macy DMSETUP=/sbin/gpart 61eda14cbcSMatt Macyelse 62eda14cbcSMatt Macy ZFS_MMP="$STF_SUITE/callbacks/zfs_mmp.ksh" 63eda14cbcSMatt Macy TESTFAIL_CALLBACKS=${TESTFAIL_CALLBACKS:-"$ZFS_DBGMSG:$ZFS_DMESG:$ZFS_MMP"} 64eda14cbcSMatt Macy LOSETUP=${LOSETUP:-/sbin/losetup} 65eda14cbcSMatt Macy DMSETUP=${DMSETUP:-/sbin/dmsetup} 66eda14cbcSMatt Macyfi 67eda14cbcSMatt Macy 68eda14cbcSMatt Macy# 69eda14cbcSMatt Macy# Log an informational message when additional verbosity is enabled. 70eda14cbcSMatt Macy# 71eda14cbcSMatt Macymsg() { 72eda14cbcSMatt Macy if [ "$VERBOSE" = "yes" ]; then 73eda14cbcSMatt Macy echo "$@" 74eda14cbcSMatt Macy fi 75eda14cbcSMatt Macy} 76eda14cbcSMatt Macy 77eda14cbcSMatt Macy# 78eda14cbcSMatt Macy# Log a failure message, cleanup, and return an error. 79eda14cbcSMatt Macy# 80eda14cbcSMatt Macyfail() { 81eda14cbcSMatt Macy echo "$PROG: $1" >&2 82eda14cbcSMatt Macy cleanup 83eda14cbcSMatt Macy exit 1 84eda14cbcSMatt Macy} 85eda14cbcSMatt Macy 86eda14cbcSMatt Macycleanup_freebsd_loopback() { 87eda14cbcSMatt Macy for TEST_LOOPBACK in ${LOOPBACKS}; do 88eda14cbcSMatt Macy if [ -c "/dev/${TEST_LOOPBACK}" ]; then 89eda14cbcSMatt Macy sudo "${LOSETUP}" -d -u "${TEST_LOOPBACK}" || 90eda14cbcSMatt Macy echo "Failed to destroy: ${TEST_LOOPBACK}" 91eda14cbcSMatt Macy fi 92eda14cbcSMatt Macy done 93eda14cbcSMatt Macy} 94eda14cbcSMatt Macy 95eda14cbcSMatt Macycleanup_linux_loopback() { 96eda14cbcSMatt Macy for TEST_LOOPBACK in ${LOOPBACKS}; do 97dae17134SMartin Matuska LOOP_DEV="${TEST_LOOPBACK##*/}" 98eda14cbcSMatt Macy DM_DEV=$(sudo "${DMSETUP}" ls 2>/dev/null | \ 99716fd348SMartin Matuska awk -v l="${LOOP_DEV}" '$0 ~ l {print $1}') 100eda14cbcSMatt Macy 101eda14cbcSMatt Macy if [ -n "$DM_DEV" ]; then 102eda14cbcSMatt Macy sudo "${DMSETUP}" remove "${DM_DEV}" || 103eda14cbcSMatt Macy echo "Failed to remove: ${DM_DEV}" 104eda14cbcSMatt Macy fi 105eda14cbcSMatt Macy 106eda14cbcSMatt Macy if [ -n "${TEST_LOOPBACK}" ]; then 107eda14cbcSMatt Macy sudo "${LOSETUP}" -d "${TEST_LOOPBACK}" || 108eda14cbcSMatt Macy echo "Failed to remove: ${TEST_LOOPBACK}" 109eda14cbcSMatt Macy fi 110eda14cbcSMatt Macy done 111eda14cbcSMatt Macy} 112eda14cbcSMatt Macy 113eda14cbcSMatt Macy# 114eda14cbcSMatt Macy# Attempt to remove loopback devices and files which where created earlier 115eda14cbcSMatt Macy# by this script to run the test framework. The '-k' option may be passed 116eda14cbcSMatt Macy# to the script to suppress cleanup for debugging purposes. 117eda14cbcSMatt Macy# 118eda14cbcSMatt Macycleanup() { 119eda14cbcSMatt Macy if [ "$CLEANUP" = "no" ]; then 120eda14cbcSMatt Macy return 0 121eda14cbcSMatt Macy fi 122eda14cbcSMatt Macy 123eda14cbcSMatt Macy 124eda14cbcSMatt Macy if [ "$LOOPBACK" = "yes" ]; then 125eda14cbcSMatt Macy if [ "$UNAME" = "FreeBSD" ] ; then 126eda14cbcSMatt Macy cleanup_freebsd_loopback 127eda14cbcSMatt Macy else 128eda14cbcSMatt Macy cleanup_linux_loopback 129eda14cbcSMatt Macy fi 130eda14cbcSMatt Macy fi 131eda14cbcSMatt Macy 132716fd348SMartin Matuska # shellcheck disable=SC2086 133716fd348SMartin Matuska rm -f ${FILES} >/dev/null 2>&1 134eda14cbcSMatt Macy 135eda14cbcSMatt Macy if [ "$STF_PATH_REMOVE" = "yes" ] && [ -d "$STF_PATH" ]; then 136eda14cbcSMatt Macy rm -Rf "$STF_PATH" 137eda14cbcSMatt Macy fi 138eda14cbcSMatt Macy} 139eda14cbcSMatt Macytrap cleanup EXIT 140eda14cbcSMatt Macy 141eda14cbcSMatt Macy# 142eda14cbcSMatt Macy# Attempt to remove all testpools (testpool.XXX), unopened dm devices, 143eda14cbcSMatt Macy# loopback devices, and files. This is a useful way to cleanup a previous 144eda14cbcSMatt Macy# test run failure which has left the system in an unknown state. This can 145eda14cbcSMatt Macy# be dangerous and should only be used in a dedicated test environment. 146eda14cbcSMatt Macy# 147eda14cbcSMatt Macycleanup_all() { 148716fd348SMartin Matuska TEST_POOLS=$(ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -Ho name | grep testpool) 149eda14cbcSMatt Macy if [ "$UNAME" = "FreeBSD" ] ; then 150eda14cbcSMatt Macy TEST_LOOPBACKS=$(sudo "${LOSETUP}" -l) 151eda14cbcSMatt Macy else 152716fd348SMartin Matuska TEST_LOOPBACKS=$("${LOSETUP}" -a | awk -F: '/file-vdev/ {print $1}') 153eda14cbcSMatt Macy fi 154716fd348SMartin Matuska TEST_FILES=$(ls "${FILEDIR}"/file-vdev* /var/tmp/file-vdev* 2>/dev/null) 155eda14cbcSMatt Macy 156eda14cbcSMatt Macy msg 157eda14cbcSMatt Macy msg "--- Cleanup ---" 158716fd348SMartin Matuska # shellcheck disable=2116,2086 159716fd348SMartin Matuska msg "Removing pool(s): $(echo ${TEST_POOLS})" 160eda14cbcSMatt Macy for TEST_POOL in $TEST_POOLS; do 161c03c5b1cSMartin Matuska sudo env ASAN_OPTIONS=detect_leaks=false "$ZPOOL" destroy "${TEST_POOL}" 162eda14cbcSMatt Macy done 163eda14cbcSMatt Macy 164eda14cbcSMatt Macy if [ "$UNAME" != "FreeBSD" ] ; then 165716fd348SMartin Matuska msg "Removing all dm(s): $(sudo "${DMSETUP}" ls | 166eda14cbcSMatt Macy grep loop | tr '\n' ' ')" 167eda14cbcSMatt Macy sudo "${DMSETUP}" remove_all 168eda14cbcSMatt Macy fi 169eda14cbcSMatt Macy 170716fd348SMartin Matuska # shellcheck disable=2116,2086 171716fd348SMartin Matuska msg "Removing loopback(s): $(echo ${TEST_LOOPBACKS})" 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 180716fd348SMartin Matuska # shellcheck disable=2116,2086 181716fd348SMartin Matuska msg "Removing files(s): $(echo ${TEST_FILES})" 182716fd348SMartin Matuska # shellcheck disable=2086 183716fd348SMartin Matuska sudo rm -f ${TEST_FILES} 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 198eda14cbcSMatt Macy if [ -f "$RUNFILE_DIR/$NAME" ]; then 199716fd348SMartin Matuska echo "$RUNFILE_DIR/$NAME" 200eda14cbcSMatt Macy elif [ -f "$RUNFILE_DIR/$NAME.run" ]; then 201716fd348SMartin Matuska echo "$RUNFILE_DIR/$NAME.run" 202eda14cbcSMatt Macy elif [ -f "$NAME" ]; then 203716fd348SMartin Matuska echo "$NAME" 204eda14cbcSMatt Macy elif [ -f "$NAME.run" ]; then 205716fd348SMartin Matuska echo "$NAME.run" 206716fd348SMartin Matuska else 207716fd348SMartin Matuska return 1 208eda14cbcSMatt Macy fi 209eda14cbcSMatt Macy} 210eda14cbcSMatt Macy 211eda14cbcSMatt Macy# 212eda14cbcSMatt Macy# Symlink file if it appears under any of the given paths. 213eda14cbcSMatt Macy# 214eda14cbcSMatt Macycreate_links() { 215eda14cbcSMatt Macy dir_list="$1" 216eda14cbcSMatt Macy file_list="$2" 217eda14cbcSMatt Macy 218eda14cbcSMatt Macy [ -n "$STF_PATH" ] || fail "STF_PATH wasn't correctly set" 219eda14cbcSMatt Macy 220eda14cbcSMatt Macy for i in $file_list; do 221eda14cbcSMatt Macy for j in $dir_list; do 222eda14cbcSMatt Macy [ ! -e "$STF_PATH/$i" ] || continue 223eda14cbcSMatt Macy 224eda14cbcSMatt Macy if [ ! -d "$j/$i" ] && [ -e "$j/$i" ]; then 225eda14cbcSMatt Macy ln -sf "$j/$i" "$STF_PATH/$i" || \ 226eda14cbcSMatt Macy fail "Couldn't link $i" 227eda14cbcSMatt Macy break 228eda14cbcSMatt Macy fi 229eda14cbcSMatt Macy done 230eda14cbcSMatt Macy 231eda14cbcSMatt Macy [ ! -e "$STF_PATH/$i" ] && \ 232eda14cbcSMatt Macy STF_MISSING_BIN="$STF_MISSING_BIN $i" 233eda14cbcSMatt Macy done 234eda14cbcSMatt Macy STF_MISSING_BIN=${STF_MISSING_BIN# } 235eda14cbcSMatt Macy} 236eda14cbcSMatt Macy 237eda14cbcSMatt Macy# 238eda14cbcSMatt Macy# Constrain the path to limit the available binaries to a known set. 239eda14cbcSMatt Macy# When running in-tree a top level ./bin/ directory is created for 240eda14cbcSMatt Macy# convenience, otherwise a temporary directory is used. 241eda14cbcSMatt Macy# 242eda14cbcSMatt Macyconstrain_path() { 243eda14cbcSMatt Macy . "$STF_SUITE/include/commands.cfg" 244eda14cbcSMatt Macy 245eda14cbcSMatt Macy # On FreeBSD, base system zfs utils are in /sbin and OpenZFS utils 246eda14cbcSMatt Macy # install to /usr/local/sbin. To avoid testing the wrong utils we 247eda14cbcSMatt Macy # need /usr/local to come before / in the path search order. 248eda14cbcSMatt Macy SYSTEM_DIRS="/usr/local/bin /usr/local/sbin" 2497877fdebSMatt Macy SYSTEM_DIRS="$SYSTEM_DIRS /usr/bin /usr/sbin /bin /sbin $LIBEXEC_DIR" 250eda14cbcSMatt Macy 251eda14cbcSMatt Macy if [ "$INTREE" = "yes" ]; then 252716fd348SMartin Matuska # Constrained path set to $(top_builddir)/tests/zfs-tests/bin 253eda14cbcSMatt Macy STF_PATH="$BIN_DIR" 254eda14cbcSMatt Macy STF_PATH_REMOVE="no" 255eda14cbcSMatt Macy STF_MISSING_BIN="" 256eda14cbcSMatt Macy if [ ! -d "$STF_PATH" ]; then 257eda14cbcSMatt Macy mkdir "$STF_PATH" 258eda14cbcSMatt Macy chmod 755 "$STF_PATH" || fail "Couldn't chmod $STF_PATH" 259eda14cbcSMatt Macy fi 260eda14cbcSMatt Macy 261eda14cbcSMatt Macy # Special case links for standard zfs utilities 262716fd348SMartin Matuska create_links "$CMD_DIR" "$ZFS_FILES" 263eda14cbcSMatt Macy 264eda14cbcSMatt Macy # Special case links for zfs test suite utilities 265716fd348SMartin Matuska create_links "$CMD_DIR/tests/zfs-tests/cmd" "$ZFSTEST_FILES" 266eda14cbcSMatt Macy else 267eda14cbcSMatt Macy # Constrained path set to /var/tmp/constrained_path.* 2687877fdebSMatt Macy SYSTEMDIR=${SYSTEMDIR:-/var/tmp/constrained_path.XXXXXX} 269eda14cbcSMatt Macy STF_PATH=$(mktemp -d "$SYSTEMDIR") 270eda14cbcSMatt Macy STF_PATH_REMOVE="yes" 271eda14cbcSMatt Macy STF_MISSING_BIN="" 272eda14cbcSMatt Macy 273eda14cbcSMatt Macy chmod 755 "$STF_PATH" || fail "Couldn't chmod $STF_PATH" 274eda14cbcSMatt Macy 275eda14cbcSMatt Macy # Special case links for standard zfs utilities 276eda14cbcSMatt Macy create_links "$SYSTEM_DIRS" "$ZFS_FILES" 277eda14cbcSMatt Macy 278eda14cbcSMatt Macy # Special case links for zfs test suite utilities 279eda14cbcSMatt Macy create_links "$STF_SUITE/bin" "$ZFSTEST_FILES" 280eda14cbcSMatt Macy fi 281eda14cbcSMatt Macy 282eda14cbcSMatt Macy # Standard system utilities 283eda14cbcSMatt Macy SYSTEM_FILES="$SYSTEM_FILES_COMMON" 284eda14cbcSMatt Macy if [ "$UNAME" = "FreeBSD" ] ; then 285eda14cbcSMatt Macy SYSTEM_FILES="$SYSTEM_FILES $SYSTEM_FILES_FREEBSD" 286eda14cbcSMatt Macy else 287eda14cbcSMatt Macy SYSTEM_FILES="$SYSTEM_FILES $SYSTEM_FILES_LINUX" 288eda14cbcSMatt Macy fi 289eda14cbcSMatt Macy create_links "$SYSTEM_DIRS" "$SYSTEM_FILES" 290eda14cbcSMatt Macy 291eda14cbcSMatt Macy # Exceptions 292eda14cbcSMatt Macy if [ "$UNAME" = "Linux" ] ; then 293eda14cbcSMatt Macy ln -fs /sbin/fsck.ext4 "$STF_PATH/fsck" 294eda14cbcSMatt Macy ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs" 295eda14cbcSMatt Macy ln -fs "$STF_PATH/gzip" "$STF_PATH/compress" 296eda14cbcSMatt Macy ln -fs "$STF_PATH/gunzip" "$STF_PATH/uncompress" 297eda14cbcSMatt Macy elif [ "$UNAME" = "FreeBSD" ] ; then 298eda14cbcSMatt Macy ln -fs /usr/local/bin/ksh93 "$STF_PATH/ksh" 299eda14cbcSMatt Macy fi 300eda14cbcSMatt Macy} 301eda14cbcSMatt Macy 302eda14cbcSMatt Macy# 303eda14cbcSMatt Macy# Output a useful usage message. 304eda14cbcSMatt Macy# 305eda14cbcSMatt Macyusage() { 306eda14cbcSMatt Macycat << EOF 307eda14cbcSMatt MacyUSAGE: 3082c48331dSMatt Macy$0 [-hvqxkfS] [-s SIZE] [-r RUNFILES] [-t PATH] [-u USER] 309eda14cbcSMatt Macy 310eda14cbcSMatt MacyDESCRIPTION: 311eda14cbcSMatt Macy ZFS Test Suite launch script 312eda14cbcSMatt Macy 313eda14cbcSMatt MacyOPTIONS: 314eda14cbcSMatt Macy -h Show this message 315eda14cbcSMatt Macy -v Verbose zfs-tests.sh output 316eda14cbcSMatt Macy -q Quiet test-runner output 317*0d4ad640SMartin Matuska -D Debug; show all test output immediately (noisy) 318eda14cbcSMatt Macy -x Remove all testpools, dm, lo, and files (unsafe) 319eda14cbcSMatt Macy -k Disable cleanup after test failure 320da5137abSMartin Matuska -K Log test names to /dev/kmsg 321eda14cbcSMatt Macy -f Use files only, disables block device tests 322eda14cbcSMatt Macy -S Enable stack tracer (negative performance impact) 323eda14cbcSMatt Macy -c Only create and populate constrained path 324681ce946SMartin Matuska -R Automatically rerun failing tests 325c03c5b1cSMartin Matuska -m Enable kmemleak reporting (Linux only) 326eda14cbcSMatt Macy -n NFSFILE Use the nfsfile to determine the NFS configuration 327eda14cbcSMatt Macy -I NUM Number of iterations 328716fd348SMartin Matuska -d DIR Use world-writable DIR for files and loopback devices 329eda14cbcSMatt Macy -s SIZE Use vdevs of SIZE (default: 4G) 330eda14cbcSMatt Macy -r RUNFILES Run tests in RUNFILES (default: ${DEFAULT_RUNFILES}) 3311719886fSMartin Matuska -t PATH|NAME Run single test at PATH relative to test suite, 3321719886fSMartin Matuska or search for test by NAME 333eda14cbcSMatt Macy -T TAGS Comma separated list of tags (default: 'functional') 334eda14cbcSMatt Macy -u USER Run single test as USER (default: root) 335eda14cbcSMatt Macy 336eda14cbcSMatt MacyEXAMPLES: 337716fd348SMartin Matuska# Run the default ($(echo "${DEFAULT_RUNFILES}" | sed 's/\.run//')) suite of tests and output the configuration used. 338eda14cbcSMatt Macy$0 -v 339eda14cbcSMatt Macy 340eda14cbcSMatt Macy# Run a smaller suite of tests designed to run more quickly. 341eda14cbcSMatt Macy$0 -r linux-fast 342eda14cbcSMatt Macy 343eda14cbcSMatt Macy# Run a single test 344eda14cbcSMatt Macy$0 -t tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh 345eda14cbcSMatt Macy 3461719886fSMartin Matuska# Run a single test by name 3471719886fSMartin Matuska$0 -t zfs_bookmark_cliargs 3481719886fSMartin Matuska 349eda14cbcSMatt Macy# Cleanup a previous run of the test suite prior to testing, run the 350716fd348SMartin Matuska# default ($(echo "${DEFAULT_RUNFILES}" | sed 's/\.run//')) suite of tests and perform no cleanup on exit. 351eda14cbcSMatt Macy$0 -x 352eda14cbcSMatt Macy 353eda14cbcSMatt MacyEOF 354eda14cbcSMatt Macy} 355eda14cbcSMatt Macy 356*0d4ad640SMartin Matuskawhile getopts 'hvqxkKfScRmn:d:Ds:r:?t:T:u:I:' OPTION; do 357eda14cbcSMatt Macy case $OPTION in 358eda14cbcSMatt Macy h) 359eda14cbcSMatt Macy usage 360eda14cbcSMatt Macy exit 1 361eda14cbcSMatt Macy ;; 362eda14cbcSMatt Macy v) 363eda14cbcSMatt Macy VERBOSE="yes" 364eda14cbcSMatt Macy ;; 365eda14cbcSMatt Macy q) 366eda14cbcSMatt Macy QUIET="yes" 367eda14cbcSMatt Macy ;; 368eda14cbcSMatt Macy x) 369eda14cbcSMatt Macy CLEANUPALL="yes" 370eda14cbcSMatt Macy ;; 371eda14cbcSMatt Macy k) 372eda14cbcSMatt Macy CLEANUP="no" 373eda14cbcSMatt Macy ;; 374da5137abSMartin Matuska K) 375da5137abSMartin Matuska KMSG="yes" 376da5137abSMartin Matuska ;; 377eda14cbcSMatt Macy f) 378eda14cbcSMatt Macy LOOPBACK="no" 379eda14cbcSMatt Macy ;; 380eda14cbcSMatt Macy S) 381eda14cbcSMatt Macy STACK_TRACER="yes" 382eda14cbcSMatt Macy ;; 383eda14cbcSMatt Macy c) 384eda14cbcSMatt Macy constrain_path 385eda14cbcSMatt Macy exit 386eda14cbcSMatt Macy ;; 387681ce946SMartin Matuska R) 388681ce946SMartin Matuska RERUN="yes" 389681ce946SMartin Matuska ;; 390c03c5b1cSMartin Matuska m) 391c03c5b1cSMartin Matuska KMEMLEAK="yes" 392c03c5b1cSMartin Matuska ;; 393eda14cbcSMatt Macy n) 394eda14cbcSMatt Macy nfsfile=$OPTARG 395eda14cbcSMatt Macy [ -f "$nfsfile" ] || fail "Cannot read file: $nfsfile" 396eda14cbcSMatt Macy export NFS=1 397eda14cbcSMatt Macy . "$nfsfile" 398eda14cbcSMatt Macy ;; 399eda14cbcSMatt Macy d) 400eda14cbcSMatt Macy FILEDIR="$OPTARG" 401eda14cbcSMatt Macy ;; 402*0d4ad640SMartin Matuska D) 403*0d4ad640SMartin Matuska DEBUG="yes" 404*0d4ad640SMartin Matuska ;; 405eda14cbcSMatt Macy I) 406eda14cbcSMatt Macy ITERATIONS="$OPTARG" 407eda14cbcSMatt Macy if [ "$ITERATIONS" -le 0 ]; then 408eda14cbcSMatt Macy fail "Iterations must be greater than 0." 409eda14cbcSMatt Macy fi 410eda14cbcSMatt Macy ;; 411eda14cbcSMatt Macy s) 412eda14cbcSMatt Macy FILESIZE="$OPTARG" 413eda14cbcSMatt Macy ;; 414eda14cbcSMatt Macy r) 415eda14cbcSMatt Macy RUNFILES="$OPTARG" 416eda14cbcSMatt Macy ;; 417eda14cbcSMatt Macy t) 418eda14cbcSMatt Macy if [ -n "$SINGLETEST" ]; then 419eda14cbcSMatt Macy fail "-t can only be provided once." 420eda14cbcSMatt Macy fi 421eda14cbcSMatt Macy SINGLETEST="$OPTARG" 422eda14cbcSMatt Macy ;; 423eda14cbcSMatt Macy T) 424eda14cbcSMatt Macy TAGS="$OPTARG" 425eda14cbcSMatt Macy ;; 426eda14cbcSMatt Macy u) 427eda14cbcSMatt Macy SINGLETESTUSER="$OPTARG" 428eda14cbcSMatt Macy ;; 429eda14cbcSMatt Macy ?) 430eda14cbcSMatt Macy usage 431eda14cbcSMatt Macy exit 432eda14cbcSMatt Macy ;; 433e92ffd9bSMartin Matuska *) 434e92ffd9bSMartin Matuska ;; 435eda14cbcSMatt Macy esac 436eda14cbcSMatt Macydone 437eda14cbcSMatt Macy 438eda14cbcSMatt Macyshift $((OPTIND-1)) 439eda14cbcSMatt Macy 440eda14cbcSMatt MacyFILES=${FILES:-"$FILEDIR/file-vdev0 $FILEDIR/file-vdev1 $FILEDIR/file-vdev2"} 441eda14cbcSMatt MacyLOOPBACKS=${LOOPBACKS:-""} 442eda14cbcSMatt Macy 443eda14cbcSMatt Macyif [ -n "$SINGLETEST" ]; then 444eda14cbcSMatt Macy if [ -n "$TAGS" ]; then 445eda14cbcSMatt Macy fail "-t and -T are mutually exclusive." 446eda14cbcSMatt Macy fi 447eda14cbcSMatt Macy RUNFILE_DIR="/var/tmp" 448eda14cbcSMatt Macy RUNFILES="zfs-tests.$$.run" 449716fd348SMartin Matuska [ -n "$QUIET" ] && SINGLEQUIET="True" || SINGLEQUIET="False" 450eda14cbcSMatt Macy 451e92ffd9bSMartin Matuska cat >"${RUNFILE_DIR}/${RUNFILES}" << EOF 452eda14cbcSMatt Macy[DEFAULT] 453eda14cbcSMatt Macypre = 454eda14cbcSMatt Macyquiet = $SINGLEQUIET 455eda14cbcSMatt Macypre_user = root 456eda14cbcSMatt Macyuser = $SINGLETESTUSER 457eda14cbcSMatt Macytimeout = 600 458eda14cbcSMatt Macypost_user = root 459eda14cbcSMatt Macypost = 460eda14cbcSMatt Macyoutputdir = /var/tmp/test_results 461eda14cbcSMatt MacyEOF 4621719886fSMartin Matuska if [ "$SINGLETEST" = "${SINGLETEST%/*}" ] ; then 4631719886fSMartin Matuska NEWSINGLETEST=$(find "$STF_SUITE" -name "$SINGLETEST*" -print -quit) 4641719886fSMartin Matuska if [ -z "$NEWSINGLETEST" ] ; then 4651719886fSMartin Matuska fail "couldn't find test matching '$SINGLETEST'" 4661719886fSMartin Matuska fi 4671719886fSMartin Matuska SINGLETEST=$NEWSINGLETEST 4681719886fSMartin Matuska fi 469eda14cbcSMatt Macy 4701719886fSMartin Matuska SINGLETESTDIR="${SINGLETEST%/*}" 471716fd348SMartin Matuska SETUPDIR="$SINGLETESTDIR" 472716fd348SMartin Matuska [ "${SETUPDIR#/}" = "$SETUPDIR" ] && SETUPDIR="$STF_SUITE/$SINGLETESTDIR" 473716fd348SMartin Matuska [ -x "$SETUPDIR/setup.ksh" ] && SETUPSCRIPT="setup" || SETUPSCRIPT= 474716fd348SMartin Matuska [ -x "$SETUPDIR/cleanup.ksh" ] && CLEANUPSCRIPT="cleanup" || CLEANUPSCRIPT= 475eda14cbcSMatt Macy 476716fd348SMartin Matuska SINGLETESTFILE="${SINGLETEST##*/}" 477e92ffd9bSMartin Matuska cat >>"${RUNFILE_DIR}/${RUNFILES}" << EOF 478eda14cbcSMatt Macy 479eda14cbcSMatt Macy[$SINGLETESTDIR] 480eda14cbcSMatt Macytests = ['$SINGLETESTFILE'] 481eda14cbcSMatt Macypre = $SETUPSCRIPT 482eda14cbcSMatt Macypost = $CLEANUPSCRIPT 483eda14cbcSMatt Macytags = ['functional'] 484eda14cbcSMatt MacyEOF 485eda14cbcSMatt Macyfi 486eda14cbcSMatt Macy 487eda14cbcSMatt Macy# 488eda14cbcSMatt Macy# Use default tag if none was specified 489eda14cbcSMatt Macy# 490eda14cbcSMatt MacyTAGS=${TAGS:='functional'} 491eda14cbcSMatt Macy 492eda14cbcSMatt Macy# 493eda14cbcSMatt Macy# Attempt to locate the runfiles describing the test workload. 494eda14cbcSMatt Macy# 495eda14cbcSMatt MacyR="" 496eda14cbcSMatt MacyIFS=, 497eda14cbcSMatt Macyfor RUNFILE in $RUNFILES; do 498eda14cbcSMatt Macy if [ -n "$RUNFILE" ]; then 499eda14cbcSMatt Macy SAVED_RUNFILE="$RUNFILE" 500716fd348SMartin Matuska RUNFILE=$(find_runfile "$RUNFILE") || 501716fd348SMartin Matuska fail "Cannot find runfile: $SAVED_RUNFILE" 502eda14cbcSMatt Macy R="$R,$RUNFILE" 503eda14cbcSMatt Macy fi 504eda14cbcSMatt Macy 505eda14cbcSMatt Macy if [ ! -r "$RUNFILE" ]; then 506eda14cbcSMatt Macy fail "Cannot read runfile: $RUNFILE" 507eda14cbcSMatt Macy fi 508eda14cbcSMatt Macydone 509eda14cbcSMatt Macyunset IFS 510eda14cbcSMatt MacyRUNFILES=${R#,} 511eda14cbcSMatt Macy 512eda14cbcSMatt Macy# 513eda14cbcSMatt Macy# This script should not be run as root. Instead the test user, which may 514eda14cbcSMatt Macy# be a normal user account, needs to be configured such that it can 515eda14cbcSMatt Macy# run commands via sudo passwordlessly. 516eda14cbcSMatt Macy# 517eda14cbcSMatt Macyif [ "$(id -u)" = "0" ]; then 518eda14cbcSMatt Macy fail "This script must not be run as root." 519eda14cbcSMatt Macyfi 520eda14cbcSMatt Macy 521716fd348SMartin Matuskaif [ "$(sudo id -un)" != "root" ]; then 522eda14cbcSMatt Macy fail "Passwordless sudo access required." 523eda14cbcSMatt Macyfi 524eda14cbcSMatt Macy 525eda14cbcSMatt Macy# 526eda14cbcSMatt Macy# Constrain the available binaries to a known set. 527eda14cbcSMatt Macy# 528eda14cbcSMatt Macyconstrain_path 529eda14cbcSMatt Macy 530eda14cbcSMatt Macy# 531eda14cbcSMatt Macy# Check if ksh exists 532eda14cbcSMatt Macy# 533eda14cbcSMatt Macyif [ "$UNAME" = "FreeBSD" ]; then 534eda14cbcSMatt Macy sudo ln -fs /usr/local/bin/ksh93 /bin/ksh 535eda14cbcSMatt Macyfi 536eda14cbcSMatt Macy[ -e "$STF_PATH/ksh" ] || fail "This test suite requires ksh." 537eda14cbcSMatt Macy[ -e "$STF_SUITE/include/default.cfg" ] || fail \ 538eda14cbcSMatt Macy "Missing $STF_SUITE/include/default.cfg file." 539eda14cbcSMatt Macy 540eda14cbcSMatt Macy# 541eda14cbcSMatt Macy# Verify the ZFS module stack is loaded. 542eda14cbcSMatt Macy# 543eda14cbcSMatt Macyif [ "$STACK_TRACER" = "yes" ]; then 544eda14cbcSMatt Macy sudo "${ZFS_SH}" -S >/dev/null 2>&1 545eda14cbcSMatt Macyelse 546eda14cbcSMatt Macy sudo "${ZFS_SH}" >/dev/null 2>&1 547eda14cbcSMatt Macyfi 548eda14cbcSMatt Macy 549eda14cbcSMatt Macy# 550eda14cbcSMatt Macy# Attempt to cleanup all previous state for a new test run. 551eda14cbcSMatt Macy# 552eda14cbcSMatt Macyif [ "$CLEANUPALL" = "yes" ]; then 553eda14cbcSMatt Macy cleanup_all 554eda14cbcSMatt Macyfi 555eda14cbcSMatt Macy 556eda14cbcSMatt Macy# 557eda14cbcSMatt Macy# By default preserve any existing pools 558eda14cbcSMatt Macy# 559eda14cbcSMatt Macyif [ -z "${KEEP}" ]; then 560716fd348SMartin Matuska KEEP="$(ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -Ho name | tr -s '[:space:]' ' ')" 561eda14cbcSMatt Macy if [ -z "${KEEP}" ]; then 562eda14cbcSMatt Macy KEEP="rpool" 563eda14cbcSMatt Macy fi 564eda14cbcSMatt Macyelse 565716fd348SMartin Matuska KEEP="$(echo "$KEEP" | tr -s '[:space:]' ' ')" 566eda14cbcSMatt Macyfi 567eda14cbcSMatt Macy 568eda14cbcSMatt Macy# 569eda14cbcSMatt Macy# NOTE: The following environment variables are undocumented 570eda14cbcSMatt Macy# and should be used for testing purposes only: 571eda14cbcSMatt Macy# 572eda14cbcSMatt Macy# __ZFS_POOL_EXCLUDE - don't iterate over the pools it lists 573eda14cbcSMatt Macy# __ZFS_POOL_RESTRICT - iterate only over the pools it lists 574eda14cbcSMatt Macy# 575eda14cbcSMatt Macy# See libzfs/libzfs_config.c for more information. 576eda14cbcSMatt Macy# 577716fd348SMartin Matuska__ZFS_POOL_EXCLUDE="$KEEP" 578eda14cbcSMatt Macy 579eda14cbcSMatt Macy. "$STF_SUITE/include/default.cfg" 580eda14cbcSMatt Macy 581eda14cbcSMatt Macy# 582eda14cbcSMatt Macy# No DISKS have been provided so a basic file or loopback based devices 583eda14cbcSMatt Macy# must be created for the test suite to use. 584eda14cbcSMatt Macy# 585eda14cbcSMatt Macyif [ -z "${DISKS}" ]; then 586eda14cbcSMatt Macy # 5871f88aa09SMartin Matuska # If this is a performance run, prevent accidental use of 5881f88aa09SMartin Matuska # loopback devices. 5891f88aa09SMartin Matuska # 5901f88aa09SMartin Matuska [ "$TAGS" = "perf" ] && fail "Running perf tests without disks." 5911f88aa09SMartin Matuska 5921f88aa09SMartin Matuska # 593eda14cbcSMatt Macy # Create sparse files for the test suite. These may be used 594eda14cbcSMatt Macy # directory or have loopback devices layered on them. 595eda14cbcSMatt Macy # 596eda14cbcSMatt Macy for TEST_FILE in ${FILES}; do 597eda14cbcSMatt Macy [ -f "$TEST_FILE" ] && fail "Failed file exists: ${TEST_FILE}" 598eda14cbcSMatt Macy truncate -s "${FILESIZE}" "${TEST_FILE}" || 599eda14cbcSMatt Macy fail "Failed creating: ${TEST_FILE} ($?)" 600eda14cbcSMatt Macy done 601eda14cbcSMatt Macy 602eda14cbcSMatt Macy # 603eda14cbcSMatt Macy # If requested setup loopback devices backed by the sparse files. 604eda14cbcSMatt Macy # 605eda14cbcSMatt Macy if [ "$LOOPBACK" = "yes" ]; then 606eda14cbcSMatt Macy test -x "$LOSETUP" || fail "$LOSETUP utility must be installed" 607eda14cbcSMatt Macy 608eda14cbcSMatt Macy for TEST_FILE in ${FILES}; do 609eda14cbcSMatt Macy if [ "$UNAME" = "FreeBSD" ] ; then 610eda14cbcSMatt Macy MDDEVICE=$(sudo "${LOSETUP}" -a -t vnode -f "${TEST_FILE}") 611eda14cbcSMatt Macy if [ -z "$MDDEVICE" ] ; then 612eda14cbcSMatt Macy fail "Failed: ${TEST_FILE} -> loopback" 613eda14cbcSMatt Macy fi 614eda14cbcSMatt Macy DISKS="$DISKS $MDDEVICE" 615eda14cbcSMatt Macy LOOPBACKS="$LOOPBACKS $MDDEVICE" 616eda14cbcSMatt Macy else 617716fd348SMartin Matuska TEST_LOOPBACK=$(sudo "${LOSETUP}" --show -f "${TEST_FILE}") || 618eda14cbcSMatt Macy fail "Failed: ${TEST_FILE} -> ${TEST_LOOPBACK}" 619dae17134SMartin Matuska BASELOOPBACK="${TEST_LOOPBACK##*/}" 620eda14cbcSMatt Macy DISKS="$DISKS $BASELOOPBACK" 621eda14cbcSMatt Macy LOOPBACKS="$LOOPBACKS $TEST_LOOPBACK" 622eda14cbcSMatt Macy fi 623eda14cbcSMatt Macy done 624eda14cbcSMatt Macy DISKS=${DISKS# } 625eda14cbcSMatt Macy LOOPBACKS=${LOOPBACKS# } 626eda14cbcSMatt Macy else 627eda14cbcSMatt Macy DISKS="$FILES" 628eda14cbcSMatt Macy fi 629eda14cbcSMatt Macyfi 630eda14cbcSMatt Macy 6311f88aa09SMartin Matuska# 6321f88aa09SMartin Matuska# It may be desirable to test with fewer disks than the default when running 6331f88aa09SMartin Matuska# the performance tests, but the functional tests require at least three. 6341f88aa09SMartin Matuska# 635eda14cbcSMatt MacyNUM_DISKS=$(echo "${DISKS}" | awk '{print NF}') 6361f88aa09SMartin Matuskaif [ "$TAGS" != "perf" ]; then 637eda14cbcSMatt Macy [ "$NUM_DISKS" -lt 3 ] && fail "Not enough disks ($NUM_DISKS/3 minimum)" 6381f88aa09SMartin Matuskafi 639eda14cbcSMatt Macy 640eda14cbcSMatt Macy# 641eda14cbcSMatt Macy# Disable SELinux until the ZFS Test Suite has been updated accordingly. 642eda14cbcSMatt Macy# 643716fd348SMartin Matuskaif command -v setenforce >/dev/null; then 644eda14cbcSMatt Macy sudo setenforce permissive >/dev/null 2>&1 645eda14cbcSMatt Macyfi 646eda14cbcSMatt Macy 647eda14cbcSMatt Macy# 648eda14cbcSMatt Macy# Enable internal ZFS debug log and clear it. 649eda14cbcSMatt Macy# 650eda14cbcSMatt Macyif [ -e /sys/module/zfs/parameters/zfs_dbgmsg_enable ]; then 651716fd348SMartin Matuska sudo sh -c "echo 1 >/sys/module/zfs/parameters/zfs_dbgmsg_enable" 652716fd348SMartin Matuska sudo sh -c "echo 0 >/proc/spl/kstat/zfs/dbgmsg" 653eda14cbcSMatt Macyfi 654eda14cbcSMatt Macy 6551f88aa09SMartin Matuskamsg 6561f88aa09SMartin Matuskamsg "--- Configuration ---" 6571f88aa09SMartin Matuskamsg "Runfiles: $RUNFILES" 6581f88aa09SMartin Matuskamsg "STF_TOOLS: $STF_TOOLS" 6591f88aa09SMartin Matuskamsg "STF_SUITE: $STF_SUITE" 6601f88aa09SMartin Matuskamsg "STF_PATH: $STF_PATH" 661eda14cbcSMatt Macymsg "FILEDIR: $FILEDIR" 662eda14cbcSMatt Macymsg "FILES: $FILES" 663eda14cbcSMatt Macymsg "LOOPBACKS: $LOOPBACKS" 664eda14cbcSMatt Macymsg "DISKS: $DISKS" 665eda14cbcSMatt Macymsg "NUM_DISKS: $NUM_DISKS" 666eda14cbcSMatt Macymsg "FILESIZE: $FILESIZE" 667eda14cbcSMatt Macymsg "ITERATIONS: $ITERATIONS" 668eda14cbcSMatt Macymsg "TAGS: $TAGS" 669eda14cbcSMatt Macymsg "STACK_TRACER: $STACK_TRACER" 670eda14cbcSMatt Macymsg "Keep pool(s): $KEEP" 671eda14cbcSMatt Macymsg "Missing util(s): $STF_MISSING_BIN" 672eda14cbcSMatt Macymsg "" 673eda14cbcSMatt Macy 674eda14cbcSMatt Macyexport STF_TOOLS 675eda14cbcSMatt Macyexport STF_SUITE 676eda14cbcSMatt Macyexport STF_PATH 677eda14cbcSMatt Macyexport DISKS 678eda14cbcSMatt Macyexport FILEDIR 679eda14cbcSMatt Macyexport KEEP 680eda14cbcSMatt Macyexport __ZFS_POOL_EXCLUDE 681eda14cbcSMatt Macyexport TESTFAIL_CALLBACKS 682eda14cbcSMatt Macy 683c03c5b1cSMartin Matuskamktemp_file() { 684eda14cbcSMatt Macy if [ "$UNAME" = "FreeBSD" ]; then 685c03c5b1cSMartin Matuska mktemp -u "${FILEDIR}/$1.XXXXXX" 686eda14cbcSMatt Macy else 687c03c5b1cSMartin Matuska mktemp -ut "$1.XXXXXX" -p "$FILEDIR" 688eda14cbcSMatt Macy fi 689c03c5b1cSMartin Matuska} 690c03c5b1cSMartin Matuskamkdir -p "$FILEDIR" || : 691c03c5b1cSMartin MatuskaRESULTS_FILE=$(mktemp_file zts-results) 692c03c5b1cSMartin MatuskaREPORT_FILE=$(mktemp_file zts-report) 693eda14cbcSMatt Macy 694eda14cbcSMatt Macy# 695eda14cbcSMatt Macy# Run all the tests as specified. 696eda14cbcSMatt Macy# 697c03c5b1cSMartin Matuskamsg "${TEST_RUNNER}" \ 698c03c5b1cSMartin Matuska "${QUIET:+-q}" \ 699*0d4ad640SMartin Matuska "${DEBUG:+-D}" \ 700c03c5b1cSMartin Matuska "${KMEMLEAK:+-m}" \ 701da5137abSMartin Matuska "${KMSG:+-K}" \ 702eda14cbcSMatt Macy "-c \"${RUNFILES}\"" \ 703eda14cbcSMatt Macy "-T \"${TAGS}\"" \ 704eda14cbcSMatt Macy "-i \"${STF_SUITE}\"" \ 705eda14cbcSMatt Macy "-I \"${ITERATIONS}\"" 706716fd348SMartin Matuska{ PATH=$STF_PATH \ 707716fd348SMartin Matuska ${TEST_RUNNER} \ 708c03c5b1cSMartin Matuska ${QUIET:+-q} \ 709*0d4ad640SMartin Matuska ${DEBUG:+-D} \ 710c03c5b1cSMartin Matuska ${KMEMLEAK:+-m} \ 711da5137abSMartin Matuska ${KMSG:+-K} \ 712eda14cbcSMatt Macy -c "${RUNFILES}" \ 713eda14cbcSMatt Macy -T "${TAGS}" \ 714eda14cbcSMatt Macy -i "${STF_SUITE}" \ 715eda14cbcSMatt Macy -I "${ITERATIONS}" \ 716c03c5b1cSMartin Matuska 2>&1; echo $? >"$REPORT_FILE"; } | tee "$RESULTS_FILE" 717c03c5b1cSMartin Matuskaread -r RUNRESULT <"$REPORT_FILE" 718c03c5b1cSMartin Matuska 719eda14cbcSMatt Macy# 720eda14cbcSMatt Macy# Analyze the results. 721eda14cbcSMatt Macy# 722681ce946SMartin Matuska${ZTS_REPORT} ${RERUN:+--no-maybes} "$RESULTS_FILE" >"$REPORT_FILE" 723eda14cbcSMatt MacyRESULT=$? 724681ce946SMartin Matuska 725681ce946SMartin Matuskaif [ "$RESULT" -eq "2" ] && [ -n "$RERUN" ]; then 726681ce946SMartin Matuska MAYBES="$($ZTS_REPORT --list-maybes)" 727c03c5b1cSMartin Matuska TEMP_RESULTS_FILE=$(mktemp_file zts-results-tmp) 728c03c5b1cSMartin Matuska TEST_LIST=$(mktemp_file test-list) 729681ce946SMartin Matuska grep "^Test:.*\[FAIL\]" "$RESULTS_FILE" >"$TEMP_RESULTS_FILE" 730681ce946SMartin Matuska for test_name in $MAYBES; do 731681ce946SMartin Matuska grep "$test_name " "$TEMP_RESULTS_FILE" >>"$TEST_LIST" 732681ce946SMartin Matuska done 733716fd348SMartin Matuska { PATH=$STF_PATH \ 734716fd348SMartin Matuska ${TEST_RUNNER} \ 735c03c5b1cSMartin Matuska ${QUIET:+-q} \ 736*0d4ad640SMartin Matuska ${DEBUG:+-D} \ 737c03c5b1cSMartin Matuska ${KMEMLEAK:+-m} \ 738681ce946SMartin Matuska -c "${RUNFILES}" \ 739681ce946SMartin Matuska -T "${TAGS}" \ 740681ce946SMartin Matuska -i "${STF_SUITE}" \ 741681ce946SMartin Matuska -I "${ITERATIONS}" \ 742681ce946SMartin Matuska -l "${TEST_LIST}" \ 743c03c5b1cSMartin Matuska 2>&1; echo $? >"$REPORT_FILE"; } | tee "$RESULTS_FILE" 744c03c5b1cSMartin Matuska read -r RUNRESULT <"$REPORT_FILE" 745681ce946SMartin Matuska # 746681ce946SMartin Matuska # Analyze the results. 747681ce946SMartin Matuska # 748681ce946SMartin Matuska ${ZTS_REPORT} --no-maybes "$RESULTS_FILE" >"$REPORT_FILE" 749681ce946SMartin Matuska RESULT=$? 750681ce946SMartin Matuskafi 751681ce946SMartin Matuska 752681ce946SMartin Matuska 753eda14cbcSMatt Macycat "$REPORT_FILE" 754eda14cbcSMatt Macy 755eda14cbcSMatt MacyRESULTS_DIR=$(awk '/^Log directory/ { print $3 }' "$RESULTS_FILE") 756eda14cbcSMatt Macyif [ -d "$RESULTS_DIR" ]; then 757eda14cbcSMatt Macy cat "$RESULTS_FILE" "$REPORT_FILE" >"$RESULTS_DIR/results" 758eda14cbcSMatt Macyfi 759eda14cbcSMatt Macy 760716fd348SMartin Matuskarm -f "$RESULTS_FILE" "$REPORT_FILE" "$TEST_LIST" "$TEMP_RESULTS_FILE" 761eda14cbcSMatt Macy 762eda14cbcSMatt Macyif [ -n "$SINGLETEST" ]; then 763eda14cbcSMatt Macy rm -f "$RUNFILES" >/dev/null 2>&1 764eda14cbcSMatt Macyfi 765eda14cbcSMatt Macy 766c03c5b1cSMartin Matuska[ "$RUNRESULT" -gt 3 ] && exit "$RUNRESULT" || exit "$RESULT" 767