Path: blob/main/sys/contrib/openzfs/scripts/zfs-tests.sh
48266 views
#!/usr/bin/env bash1# SPDX-License-Identifier: CDDL-1.02# shellcheck disable=SC21543# shellcheck disable=SC22924#5# CDDL HEADER START6#7# The contents of this file are subject to the terms of the8# Common Development and Distribution License, Version 1.0 only9# (the "License"). You may not use this file except in compliance10# with the License.11#12# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE13# or https://opensource.org/licenses/CDDL-1.0.14# See the License for the specific language governing permissions15# and limitations under the License.16#17# When distributing Covered Code, include this CDDL HEADER in each18# file and include the License file at usr/src/OPENSOLARIS.LICENSE.19# If applicable, add the following below this CDDL HEADER, with the20# fields enclosed by brackets "[]" replaced with your own identifying21# information: Portions Copyright [yyyy] [name of copyright owner]22#23# CDDL HEADER END24#2526#27# Copyright 2020 OmniOS Community Edition (OmniOSce) Association.28#2930SCRIPT_COMMON=${SCRIPT_COMMON:-${0%/*}/common.sh}31. "${SCRIPT_COMMON}" || exit3233PROG=zfs-tests.sh34VERBOSE="no"35QUIET=""36DEBUG=""37CLEANUP="yes"38CLEANUPALL="no"39KMSG=""40TIMEOUT_DEBUG=""41LOOPBACK="yes"42STACK_TRACER="no"43FILESIZE="4G"44DEFAULT_RUNFILES="common.run,$(uname | tr '[:upper:]' '[:lower:]').run"45RUNFILES=${RUNFILES:-$DEFAULT_RUNFILES}46FILEDIR=${FILEDIR:-/var/tmp}47DISKS=${DISKS:-""}48SINGLETEST=""49SINGLETESTUSER="root"50TAGS=""51ITERATIONS=152ZFS_DBGMSG="$STF_SUITE/callbacks/zfs_dbgmsg.ksh"53ZFS_DMESG="$STF_SUITE/callbacks/zfs_dmesg.ksh"54UNAME=$(uname)55RERUN=""56KMEMLEAK=""5758# Override some defaults if on FreeBSD59if [ "$UNAME" = "FreeBSD" ] ; then60TESTFAIL_CALLBACKS=${TESTFAIL_CALLBACKS:-"$ZFS_DMESG"}61LOSETUP=/sbin/mdconfig62DMSETUP=/sbin/gpart63else64ZFS_MMP="$STF_SUITE/callbacks/zfs_mmp.ksh"65TESTFAIL_CALLBACKS=${TESTFAIL_CALLBACKS:-"$ZFS_DBGMSG:$ZFS_DMESG:$ZFS_MMP"}66LOSETUP=${LOSETUP:-/sbin/losetup}67DMSETUP=${DMSETUP:-/sbin/dmsetup}68fi6970#71# Log an informational message when additional verbosity is enabled.72#73msg() {74if [ "$VERBOSE" = "yes" ]; then75echo "$@"76fi77}7879#80# Log a failure message, cleanup, and return an error.81#82fail() {83echo "$PROG: $1" >&284cleanup85exit 186}8788cleanup_freebsd_loopback() {89for TEST_LOOPBACK in ${LOOPBACKS}; do90if [ -c "/dev/${TEST_LOOPBACK}" ]; then91sudo "${LOSETUP}" -d -u "${TEST_LOOPBACK}" ||92echo "Failed to destroy: ${TEST_LOOPBACK}"93fi94done95}9697cleanup_linux_loopback() {98for TEST_LOOPBACK in ${LOOPBACKS}; do99LOOP_DEV="${TEST_LOOPBACK##*/}"100DM_DEV=$(sudo "${DMSETUP}" ls 2>/dev/null | \101awk -v l="${LOOP_DEV}" '$0 ~ l {print $1}')102103if [ -n "$DM_DEV" ]; then104sudo "${DMSETUP}" remove "${DM_DEV}" ||105echo "Failed to remove: ${DM_DEV}"106fi107108if [ -n "${TEST_LOOPBACK}" ]; then109sudo "${LOSETUP}" -d "${TEST_LOOPBACK}" ||110echo "Failed to remove: ${TEST_LOOPBACK}"111fi112done113}114115#116# Attempt to remove loopback devices and files which where created earlier117# by this script to run the test framework. The '-k' option may be passed118# to the script to suppress cleanup for debugging purposes.119#120cleanup() {121if [ "$CLEANUP" = "no" ]; then122return 0123fi124125126if [ "$LOOPBACK" = "yes" ]; then127if [ "$UNAME" = "FreeBSD" ] ; then128cleanup_freebsd_loopback129else130cleanup_linux_loopback131fi132fi133134# shellcheck disable=SC2086135rm -f ${FILES} >/dev/null 2>&1136137if [ "$STF_PATH_REMOVE" = "yes" ] && [ -d "$STF_PATH" ]; then138rm -Rf "$STF_PATH"139fi140}141trap cleanup EXIT142143#144# Attempt to remove all testpools (testpool.XXX), unopened dm devices,145# loopback devices, and files. This is a useful way to cleanup a previous146# test run failure which has left the system in an unknown state. This can147# be dangerous and should only be used in a dedicated test environment.148#149cleanup_all() {150TEST_POOLS=$(ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -Ho name | grep testpool)151if [ "$UNAME" = "FreeBSD" ] ; then152TEST_LOOPBACKS=$(sudo "${LOSETUP}" -l)153else154TEST_LOOPBACKS=$("${LOSETUP}" -a | awk -F: '/file-vdev/ {print $1}')155fi156TEST_FILES=$(ls "${FILEDIR}"/file-vdev* 2>/dev/null)157158msg159msg "--- Cleanup ---"160# shellcheck disable=2116,2086161msg "Removing pool(s): $(echo ${TEST_POOLS})"162for TEST_POOL in $TEST_POOLS; do163sudo env ASAN_OPTIONS=detect_leaks=false "$ZPOOL" destroy "${TEST_POOL}"164done165166if [ "$UNAME" != "FreeBSD" ] ; then167msg "Removing all dm(s): $(sudo "${DMSETUP}" ls |168grep loop | tr '\n' ' ')"169sudo "${DMSETUP}" remove_all170fi171172# shellcheck disable=2116,2086173msg "Removing loopback(s): $(echo ${TEST_LOOPBACKS})"174for TEST_LOOPBACK in $TEST_LOOPBACKS; do175if [ "$UNAME" = "FreeBSD" ] ; then176sudo "${LOSETUP}" -d -u "${TEST_LOOPBACK}"177else178sudo "${LOSETUP}" -d "${TEST_LOOPBACK}"179fi180done181182# shellcheck disable=2116,2086183msg "Removing files(s): $(echo ${TEST_FILES})"184# shellcheck disable=2086185sudo rm -f ${TEST_FILES}186}187188#189# Takes a name as the only arguments and looks for the following variations190# on that name. If one is found it is returned.191#192# $RUNFILE_DIR/<name>193# $RUNFILE_DIR/<name>.run194# <name>195# <name>.run196#197find_runfile() {198NAME=$1199200if [ -f "$RUNFILE_DIR/$NAME" ]; then201echo "$RUNFILE_DIR/$NAME"202elif [ -f "$RUNFILE_DIR/$NAME.run" ]; then203echo "$RUNFILE_DIR/$NAME.run"204elif [ -f "$NAME" ]; then205echo "$NAME"206elif [ -f "$NAME.run" ]; then207echo "$NAME.run"208else209return 1210fi211}212213# Given a TAGS with a format like "1/3" or "2/3" then divide up the test list214# into portions and print that portion. So "1/3" for "the first third of the215# test tags".216#217#218split_tags() {219# Get numerator and denominator220NUM=$(echo "$TAGS" | cut -d/ -f1)221DEN=$(echo "$TAGS" | cut -d/ -f2)222# At the point this is called, RUNFILES will contain a comma separated223# list of full paths to the runfiles, like:224#225# "/home/hutter/qemu/tests/runfiles/common.run,/home/hutter/qemu/tests/runfiles/linux.run"226#227# So to get tags for our selected tests we do:228#229# 1. Remove unneeded chars: [],\230# 2. Print out the last field of each tag line. This will be the tag231# for the test (like 'zpool_add').232# 3. Remove duplicates between the runfiles. If the same tag is defined233# in multiple runfiles, then when you do '-T <tag>' ZTS is smart234# enough to know to run the tag in each runfile. So '-T zpool_add'235# will run the zpool_add from common.run and linux.run.236# 4. Ignore the 'functional' tag since we only want individual tests237# 5. Print out the tests in our faction of all tests. This uses modulus238# so "1/3" will run tests 1,3,6,9 etc. That way the tests are239# interleaved so, say, "3/4" isn't running all the zpool_* tests that240# appear alphabetically at the end.241# 6. Remove trailing comma from list242#243# TAGS will then look like:244#245# "append,atime,bootfs,cachefile,checksum,cp_files,deadman,dos_attributes, ..."246247# Change the comma to a space for easy processing248_RUNFILES=${RUNFILES//","/" "}249# shellcheck disable=SC2002,SC2086250cat $_RUNFILES | tr -d "[],\'" | awk '/tags = /{print $NF}' | sort | \251uniq | grep -v functional | \252awk -v num="$NUM" -v den="$DEN" '{ if(NR % den == (num - 1)) {printf "%s,",$0}}' | \253sed -E 's/,$//'254}255256#257# Symlink file if it appears under any of the given paths.258#259create_links() {260dir_list="$1"261file_list="$2"262263[ -n "$STF_PATH" ] || fail "STF_PATH wasn't correctly set"264265for i in $file_list; do266for j in $dir_list; do267[ ! -e "$STF_PATH/$i" ] || continue268269if [ ! -d "$j/$i" ] && [ -e "$j/$i" ]; then270ln -sf "$j/$i" "$STF_PATH/$i" || \271fail "Couldn't link $i"272break273fi274done275276[ ! -e "$STF_PATH/$i" ] && \277STF_MISSING_BIN="$STF_MISSING_BIN $i"278done279STF_MISSING_BIN=${STF_MISSING_BIN# }280}281282#283# Constrain the path to limit the available binaries to a known set.284# When running in-tree a top level ./bin/ directory is created for285# convenience, otherwise a temporary directory is used.286#287constrain_path() {288. "$STF_SUITE/include/commands.cfg"289290# On FreeBSD, base system zfs utils are in /sbin and OpenZFS utils291# install to /usr/local/sbin. To avoid testing the wrong utils we292# need /usr/local to come before / in the path search order.293SYSTEM_DIRS="/usr/local/bin /usr/local/sbin"294SYSTEM_DIRS="$SYSTEM_DIRS /usr/bin /usr/sbin /bin /sbin $LIBEXEC_DIR"295296if [ "$INTREE" = "yes" ]; then297# Constrained path set to $(top_builddir)/tests/zfs-tests/bin298STF_PATH="$BIN_DIR"299STF_PATH_REMOVE="no"300STF_MISSING_BIN=""301if [ ! -d "$STF_PATH" ]; then302mkdir "$STF_PATH"303chmod 755 "$STF_PATH" || fail "Couldn't chmod $STF_PATH"304fi305306# Special case links for standard zfs utilities307create_links "$CMD_DIR" "$ZFS_FILES"308309# Special case links for zfs test suite utilities310create_links "$CMD_DIR/tests/zfs-tests/cmd" "$ZFSTEST_FILES"311else312# Constrained path set to $FILEDIR/constrained_path.*313SYSTEMDIR=${SYSTEMDIR:-$FILEDIR/constrained_path.XXXXXX}314STF_PATH=$(mktemp -d "$SYSTEMDIR")315STF_PATH_REMOVE="yes"316STF_MISSING_BIN=""317318chmod 755 "$STF_PATH" || fail "Couldn't chmod $STF_PATH"319320# Special case links for standard zfs utilities321create_links "$SYSTEM_DIRS" "$ZFS_FILES"322323# Special case links for zfs test suite utilities324create_links "$STF_SUITE/bin" "$ZFSTEST_FILES"325fi326327# Standard system utilities328SYSTEM_FILES="$SYSTEM_FILES_COMMON"329if [ "$UNAME" = "FreeBSD" ] ; then330SYSTEM_FILES="$SYSTEM_FILES $SYSTEM_FILES_FREEBSD"331else332SYSTEM_FILES="$SYSTEM_FILES $SYSTEM_FILES_LINUX"333fi334create_links "$SYSTEM_DIRS" "$SYSTEM_FILES"335336# Exceptions337if [ "$UNAME" = "Linux" ] ; then338ln -fs /sbin/fsck.ext4 "$STF_PATH/fsck"339ln -fs /sbin/mkfs.ext4 "$STF_PATH/newfs"340ln -fs "$STF_PATH/gzip" "$STF_PATH/compress"341ln -fs "$STF_PATH/gunzip" "$STF_PATH/uncompress"342elif [ "$UNAME" = "FreeBSD" ] ; then343ln -fs /usr/local/bin/ksh93 "$STF_PATH/ksh"344fi345}346347#348# Output a useful usage message.349#350usage() {351cat << EOF352USAGE:353$0 [-hvqxkfS] [-s SIZE] [-r RUNFILES] [-t PATH] [-u USER]354355DESCRIPTION:356ZFS Test Suite launch script357358OPTIONS:359-h Show this message360-v Verbose zfs-tests.sh output361-q Quiet test-runner output362-D Debug; show all test output immediately (noisy)363-x Remove all testpools, dm, lo, and files (unsafe)364-k Disable cleanup after test failure365-K Log test names to /dev/kmsg366-f Use files only, disables block device tests367-O Dump debugging info to /dev/kmsg on test timeout368-S Enable stack tracer (negative performance impact)369-c Only create and populate constrained path370-R Automatically rerun failing tests371-m Enable kmemleak reporting (Linux only)372-n NFSFILE Use the nfsfile to determine the NFS configuration373-I NUM Number of iterations374-d DIR Use world-writable DIR for files and loopback devices375-s SIZE Use vdevs of SIZE (default: 4G)376-r RUNFILES Run tests in RUNFILES (default: ${DEFAULT_RUNFILES})377-t PATH|NAME Run single test at PATH relative to test suite,378or search for test by NAME379-T TAGS Comma separated list of tags (default: 'functional')380Alternately, specify a fraction like "1/3" or "2/3" to381run the first third of tests or 2nd third of the tests. This382is useful for splitting up the test amongst different383runners.384-u USER Run single test as USER (default: root)385386EXAMPLES:387# Run the default ${DEFAULT_RUNFILES//\.run/} suite of tests and output the configuration used.388$0 -v389390# Run a smaller suite of tests designed to run more quickly.391$0 -r linux-fast392393# Run a single test394$0 -t tests/functional/cli_root/zfs_bookmark/zfs_bookmark_cliargs.ksh395396# Run a single test by name397$0 -t zfs_bookmark_cliargs398399# Cleanup a previous run of the test suite prior to testing, run the400# default ${DEFAULT_RUNFILES//\.run//} suite of tests and perform no cleanup on exit.401$0 -x402403EOF404}405406while getopts 'hvqxkKfScRmOn:d:Ds:r:?t:T:u:I:' OPTION; do407case $OPTION in408h)409usage410exit 1411;;412v)413VERBOSE="yes"414;;415q)416QUIET="yes"417;;418x)419CLEANUPALL="yes"420;;421k)422CLEANUP="no"423;;424K)425KMSG="yes"426;;427f)428LOOPBACK="no"429;;430S)431STACK_TRACER="yes"432;;433c)434constrain_path435exit436;;437R)438RERUN="yes"439;;440m)441KMEMLEAK="yes"442;;443n)444nfsfile=$OPTARG445[ -f "$nfsfile" ] || fail "Cannot read file: $nfsfile"446export NFS=1447. "$nfsfile"448;;449O)450TIMEOUT_DEBUG="yes"451;;452d)453FILEDIR="$OPTARG"454;;455D)456DEBUG="yes"457;;458I)459ITERATIONS="$OPTARG"460if [ "$ITERATIONS" -le 0 ]; then461fail "Iterations must be greater than 0."462fi463;;464s)465FILESIZE="$OPTARG"466;;467r)468RUNFILES="$OPTARG"469;;470t)471if [ -n "$SINGLETEST" ]; then472fail "-t can only be provided once."473fi474SINGLETEST="$OPTARG"475;;476T)477TAGS="$OPTARG"478;;479u)480SINGLETESTUSER="$OPTARG"481;;482?)483usage484exit485;;486*)487;;488esac489done490491shift $((OPTIND-1))492493FILES=${FILES:-"$FILEDIR/file-vdev0 $FILEDIR/file-vdev1 $FILEDIR/file-vdev2"}494LOOPBACKS=${LOOPBACKS:-""}495496if [ -n "$SINGLETEST" ]; then497if [ -n "$TAGS" ]; then498fail "-t and -T are mutually exclusive."499fi500RUNFILE_DIR="$FILEDIR"501RUNFILES="zfs-tests.$$.run"502[ -n "$QUIET" ] && SINGLEQUIET="True" || SINGLEQUIET="False"503504cat >"${RUNFILE_DIR}/${RUNFILES}" << EOF505[DEFAULT]506pre =507quiet = $SINGLEQUIET508pre_user = root509user = $SINGLETESTUSER510timeout = 600511post_user = root512post =513EOF514if [ "$SINGLETEST" = "${SINGLETEST%/*}" ] ; then515NEWSINGLETEST=$(find "$STF_SUITE" -name "$SINGLETEST*" -print -quit)516if [ -z "$NEWSINGLETEST" ] ; then517fail "couldn't find test matching '$SINGLETEST'"518fi519SINGLETEST=$NEWSINGLETEST520fi521522SINGLETESTDIR="${SINGLETEST%/*}"523SETUPDIR="$SINGLETESTDIR"524[ "${SETUPDIR#/}" = "$SETUPDIR" ] && SETUPDIR="$STF_SUITE/$SINGLETESTDIR"525[ -x "$SETUPDIR/setup.ksh" ] && SETUPSCRIPT="setup" || SETUPSCRIPT=526[ -x "$SETUPDIR/cleanup.ksh" ] && CLEANUPSCRIPT="cleanup" || CLEANUPSCRIPT=527528SINGLETESTFILE="${SINGLETEST##*/}"529cat >>"${RUNFILE_DIR}/${RUNFILES}" << EOF530531[$SINGLETESTDIR]532tests = ['$SINGLETESTFILE']533pre = $SETUPSCRIPT534post = $CLEANUPSCRIPT535tags = ['functional']536EOF537fi538539#540# Use default tag if none was specified541#542TAGS=${TAGS:='functional'}543544545546#547# Attempt to locate the runfiles describing the test workload.548#549R=""550IFS=,551for RUNFILE in $RUNFILES; do552if [ -n "$RUNFILE" ]; then553SAVED_RUNFILE="$RUNFILE"554RUNFILE=$(find_runfile "$RUNFILE") ||555fail "Cannot find runfile: $SAVED_RUNFILE"556R="$R,$RUNFILE"557fi558559if [ ! -r "$RUNFILE" ]; then560fail "Cannot read runfile: $RUNFILE"561fi562done563unset IFS564RUNFILES=${R#,}565566# The tag can be a fraction to indicate which portion of ZTS to run, Like567#568# "1/3": Run first one third of all tests in runfiles569# "2/3": Run second one third of all test in runfiles570# "6/10": Run 6th tenth of all tests in runfiles571#572# This is useful for splitting up the test across multiple runners.573#574# After this code block, TAGS will be transformed from something like575# "1/3" to a comma separate taglist, like:576#577# "append,atime,bootfs,cachefile,checksum,cp_files,deadman,dos_attributes, ..."578#579if echo "$TAGS" | grep -Eq '^[0-9]+/[0-9]+$' ; then580TAGS=$(split_tags)581fi582583#584# This script should not be run as root. Instead the test user, which may585# be a normal user account, needs to be configured such that it can586# run commands via sudo passwordlessly.587#588if [ "$(id -u)" = "0" ]; then589fail "This script must not be run as root."590fi591592if [ "$(sudo id -un)" != "root" ]; then593fail "Passwordless sudo access required."594fi595596#597# Constrain the available binaries to a known set.598#599constrain_path600601#602# Check if ksh exists603#604if [ "$UNAME" = "FreeBSD" ]; then605sudo ln -fs /usr/local/bin/ksh93 /bin/ksh606fi607[ -e "$STF_PATH/ksh" ] || fail "This test suite requires ksh."608[ -e "$STF_SUITE/include/default.cfg" ] || fail \609"Missing $STF_SUITE/include/default.cfg file."610611#612# Verify the ZFS module stack is loaded.613#614if [ "$STACK_TRACER" = "yes" ]; then615sudo "${ZFS_SH}" -S >/dev/null 2>&1616else617sudo "${ZFS_SH}" >/dev/null 2>&1618fi619620#621# Attempt to cleanup all previous state for a new test run.622#623if [ "$CLEANUPALL" = "yes" ]; then624cleanup_all625fi626627#628# By default preserve any existing pools629#630if [ -z "${KEEP}" ]; then631KEEP="$(ASAN_OPTIONS=detect_leaks=false "$ZPOOL" list -Ho name | tr -s '[:space:]' ' ')"632if [ -z "${KEEP}" ]; then633KEEP="rpool"634fi635else636KEEP="$(echo "$KEEP" | tr -s '[:space:]' ' ')"637fi638639#640# NOTE: The following environment variables are undocumented641# and should be used for testing purposes only:642#643# __ZFS_POOL_EXCLUDE - don't iterate over the pools it lists644# __ZFS_POOL_RESTRICT - iterate only over the pools it lists645#646# See libzfs/libzfs_config.c for more information.647#648__ZFS_POOL_EXCLUDE="$KEEP"649650. "$STF_SUITE/include/default.cfg"651652#653# No DISKS have been provided so a basic file or loopback based devices654# must be created for the test suite to use.655#656if [ -z "${DISKS}" ]; then657#658# If this is a performance run, prevent accidental use of659# loopback devices.660#661[ "$TAGS" = "perf" ] && fail "Running perf tests without disks."662663#664# Create sparse files for the test suite. These may be used665# directory or have loopback devices layered on them.666#667for TEST_FILE in ${FILES}; do668[ -f "$TEST_FILE" ] && fail "Failed file exists: ${TEST_FILE}"669truncate -s "${FILESIZE}" "${TEST_FILE}" ||670fail "Failed creating: ${TEST_FILE} ($?)"671done672673#674# If requested setup loopback devices backed by the sparse files.675#676if [ "$LOOPBACK" = "yes" ]; then677test -x "$LOSETUP" || fail "$LOSETUP utility must be installed"678679for TEST_FILE in ${FILES}; do680if [ "$UNAME" = "FreeBSD" ] ; then681MDDEVICE=$(sudo "${LOSETUP}" -a -t vnode -f "${TEST_FILE}")682if [ -z "$MDDEVICE" ] ; then683fail "Failed: ${TEST_FILE} -> loopback"684fi685DISKS="$DISKS $MDDEVICE"686LOOPBACKS="$LOOPBACKS $MDDEVICE"687else688TEST_LOOPBACK=$(sudo "${LOSETUP}" --show -f "${TEST_FILE}") ||689fail "Failed: ${TEST_FILE} -> ${TEST_LOOPBACK}"690BASELOOPBACK="${TEST_LOOPBACK##*/}"691DISKS="$DISKS $BASELOOPBACK"692LOOPBACKS="$LOOPBACKS $TEST_LOOPBACK"693fi694done695DISKS=${DISKS# }696LOOPBACKS=${LOOPBACKS# }697else698DISKS="$FILES"699fi700fi701702#703# It may be desirable to test with fewer disks than the default when running704# the performance tests, but the functional tests require at least three.705#706NUM_DISKS=$(echo "${DISKS}" | awk '{print NF}')707if [ "$TAGS" != "perf" ]; then708[ "$NUM_DISKS" -lt 3 ] && fail "Not enough disks ($NUM_DISKS/3 minimum)"709fi710711#712# Disable SELinux until the ZFS Test Suite has been updated accordingly.713#714if command -v setenforce >/dev/null; then715sudo setenforce permissive >/dev/null 2>&1716fi717718#719# Enable internal ZFS debug log and clear it.720#721if [ -e /sys/module/zfs/parameters/zfs_dbgmsg_enable ]; then722sudo sh -c "echo 1 >/sys/module/zfs/parameters/zfs_dbgmsg_enable"723sudo sh -c "echo 0 >/proc/spl/kstat/zfs/dbgmsg"724fi725726#727# Set TMPDIR. Some tests run mktemp, and we want those files contained to728# the work dir the same as any other.729#730export TMPDIR="$FILEDIR"731732msg733msg "--- Configuration ---"734msg "Runfiles: $RUNFILES"735msg "STF_TOOLS: $STF_TOOLS"736msg "STF_SUITE: $STF_SUITE"737msg "STF_PATH: $STF_PATH"738msg "FILEDIR: $FILEDIR"739msg "TMPDIR: $TMPDIR"740msg "FILES: $FILES"741msg "LOOPBACKS: $LOOPBACKS"742msg "DISKS: $DISKS"743msg "NUM_DISKS: $NUM_DISKS"744msg "FILESIZE: $FILESIZE"745msg "ITERATIONS: $ITERATIONS"746msg "TAGS: $TAGS"747msg "STACK_TRACER: $STACK_TRACER"748msg "Keep pool(s): $KEEP"749msg "Missing util(s): $STF_MISSING_BIN"750msg ""751752export STF_TOOLS753export STF_SUITE754export STF_PATH755export DISKS756export FILEDIR757export KEEP758export __ZFS_POOL_EXCLUDE759export TESTFAIL_CALLBACKS760761mktemp_file() {762if [ "$UNAME" = "FreeBSD" ]; then763mktemp -u "${FILEDIR}/$1.XXXXXX"764else765mktemp -ut "$1.XXXXXX" -p "$FILEDIR"766fi767}768mkdir -p "$FILEDIR" || :769RESULTS_FILE=$(mktemp_file zts-results)770REPORT_FILE=$(mktemp_file zts-report)771772#773# Run all the tests as specified.774#775msg "${TEST_RUNNER}" \776"${QUIET:+-q}" \777"${DEBUG:+-D}" \778"${KMEMLEAK:+-m}" \779"${KMSG:+-K}" \780"${TIMEOUT_DEBUG:+-O}" \781"-c \"${RUNFILES}\"" \782"-T \"${TAGS}\"" \783"-i \"${STF_SUITE}\"" \784"-I \"${ITERATIONS}\""785{ PATH=$STF_PATH \786${TEST_RUNNER} \787${QUIET:+-q} \788${DEBUG:+-D} \789${KMEMLEAK:+-m} \790${KMSG:+-K} \791${TIMEOUT_DEBUG:+-O} \792-c "${RUNFILES}" \793-T "${TAGS}" \794-i "${STF_SUITE}" \795-I "${ITERATIONS}" \7962>&1; echo $? >"$REPORT_FILE"; } | tee "$RESULTS_FILE"797read -r RUNRESULT <"$REPORT_FILE"798799if [[ "$RUNRESULT" -eq "255" ]] ; then800fail "$TEST_RUNNER failed, test aborted."801fi802803#804# Analyze the results.805#806${ZTS_REPORT} ${RERUN:+--no-maybes} "$RESULTS_FILE" >"$REPORT_FILE"807RESULT=$?808809if [ "$RESULT" -eq "2" ] && [ -n "$RERUN" ]; then810MAYBES="$($ZTS_REPORT --list-maybes)"811TEMP_RESULTS_FILE=$(mktemp_file zts-results-tmp)812TEST_LIST=$(mktemp_file test-list)813grep "^Test:.*\[FAIL\]" "$RESULTS_FILE" >"$TEMP_RESULTS_FILE"814for test_name in $MAYBES; do815grep "$test_name " "$TEMP_RESULTS_FILE" >>"$TEST_LIST"816done817{ PATH=$STF_PATH \818${TEST_RUNNER} \819${QUIET:+-q} \820${DEBUG:+-D} \821${KMEMLEAK:+-m} \822-c "${RUNFILES}" \823-T "${TAGS}" \824-i "${STF_SUITE}" \825-I "${ITERATIONS}" \826-l "${TEST_LIST}" \8272>&1; echo $? >"$REPORT_FILE"; } | tee "$RESULTS_FILE"828read -r RUNRESULT <"$REPORT_FILE"829#830# Analyze the results.831#832${ZTS_REPORT} --no-maybes "$RESULTS_FILE" >"$REPORT_FILE"833RESULT=$?834fi835836837cat "$REPORT_FILE"838839RESULTS_DIR=$(awk '/^Log directory/ { print $3 }' "$RESULTS_FILE")840if [ -d "$RESULTS_DIR" ]; then841cat "$RESULTS_FILE" "$REPORT_FILE" >"$RESULTS_DIR/results"842fi843844rm -f "$RESULTS_FILE" "$REPORT_FILE" "$TEST_LIST" "$TEMP_RESULTS_FILE"845846if [ -n "$SINGLETEST" ]; then847rm -f "$RUNFILES" >/dev/null 2>&1848fi849850[ "$RUNRESULT" -gt 3 ] && exit "$RUNRESULT" || exit "$RESULT"851852853