Skip to content

Commit

Permalink
Move platform independent tests to a shared runfile
Browse files Browse the repository at this point in the history
Tests that aren't limited to running on Linux can be moved to a common
runfile to be shared with other platforms.

The test runner and wrapper script are enhanced to allow specifying
multiple runfiles as a comma-separated list. The default runfiles are
now "common.run,PLATFORM.run" where PLATFORM is determined at run time.

Sections in runfiles that share a path with another runfile can append
a colon separator and an identifier to the path in the section
name, ie `[tests/functional/atime:Linux]`, to avoid overriding the tests
specified by other runfiles.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes openzfs#9391
  • Loading branch information
Ryan Moeller authored and behlendorf committed Oct 9, 2019
1 parent ca57777 commit 5e74ac5
Show file tree
Hide file tree
Showing 6 changed files with 1,036 additions and 949 deletions.
48 changes: 28 additions & 20 deletions scripts/zfs-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ CLEANUPALL="no"
LOOPBACK="yes"
STACK_TRACER="no"
FILESIZE="4G"
RUNFILE=${RUNFILE:-"linux.run"}
DEFAULT_RUNFILES="common.run,$(uname | tr '[:upper:]' '[:lower:]').run"
RUNFILES=${RUNFILES:-$DEFAULT_RUNFILES}
FILEDIR=${FILEDIR:-/var/tmp}
DISKS=${DISKS:-""}
SINGLETEST=()
Expand Down Expand Up @@ -259,7 +260,7 @@ constrain_path() {
usage() {
cat << EOF
USAGE:
$0 [hvqxkfS] [-s SIZE] [-r RUNFILE] [-t PATH] [-u USER]
$0 [hvqxkfS] [-s SIZE] [-r RUNFILES] [-t PATH] [-u USER]
DESCRIPTION:
ZFS Test Suite launch script
Expand All @@ -277,7 +278,7 @@ OPTIONS:
-I NUM Number of iterations
-d DIR Use DIR for files and loopback devices
-s SIZE Use vdevs of SIZE (default: 4G)
-r RUNFILE Run tests in RUNFILE (default: linux.run)
-r RUNFILES Run tests in RUNFILES (default: ${DEFAULT_RUNFILES})
-t PATH Run single test at PATH relative to test suite
-T TAGS Comma separated list of tags (default: 'functional')
-u USER Run single test as USER (default: root)
Expand Down Expand Up @@ -344,7 +345,7 @@ while getopts 'hvqxkfScn:d:s:r:?t:T:u:I:' OPTION; do
FILESIZE="$OPTARG"
;;
r)
RUNFILE="$OPTARG"
RUNFILES="$OPTARG"
;;
t)
if [ ${#SINGLETEST[@]} -ne 0 ]; then
Expand Down Expand Up @@ -375,14 +376,14 @@ if [ ${#SINGLETEST[@]} -ne 0 ]; then
fail "-t and -T are mutually exclusive."
fi
RUNFILE_DIR="/var/tmp"
RUNFILE="zfs-tests.$$.run"
RUNFILES="zfs-tests.$$.run"
SINGLEQUIET="False"

if [ -n "$QUIET" ]; then
SINGLEQUIET="True"
fi

cat >$RUNFILE_DIR/$RUNFILE << EOF
cat >$RUNFILE_DIR/$RUNFILES << EOF
[DEFAULT]
pre =
quiet = $SINGLEQUIET
Expand All @@ -408,7 +409,7 @@ EOF
CLEANUPSCRIPT="cleanup"
fi

cat >>$RUNFILE_DIR/$RUNFILE << EOF
cat >>$RUNFILE_DIR/$RUNFILES << EOF
[$SINGLETESTDIR]
tests = ['$SINGLETESTFILE']
Expand All @@ -425,17 +426,24 @@ fi
TAGS=${TAGS:='functional'}

#
# Attempt to locate the runfile describing the test workload.
# Attempt to locate the runfiles describing the test workload.
#
if [ -n "$RUNFILE" ]; then
SAVED_RUNFILE="$RUNFILE"
RUNFILE=$(find_runfile "$RUNFILE")
[ -z "$RUNFILE" ] && fail "Cannot find runfile: $SAVED_RUNFILE"
fi
R=""
IFS=,
for RUNFILE in $RUNFILES; do
if [ -n "$RUNFILE" ]; then
SAVED_RUNFILE="$RUNFILE"
RUNFILE=$(find_runfile "$RUNFILE")
[ -z "$RUNFILE" ] && fail "Cannot find runfile: $SAVED_RUNFILE"
R+="${R:+,}${RUNFILE}"
fi

if [ ! -r "$RUNFILE" ]; then
fail "Cannot read runfile: $RUNFILE"
fi
if [ ! -r "$RUNFILE" ]; then
fail "Cannot read runfile: $RUNFILE"
fi
done
unset IFS
RUNFILES=$R

#
# This script should not be run as root. Instead the test user, which may
Expand Down Expand Up @@ -507,7 +515,7 @@ __ZFS_POOL_EXCLUDE="$(echo "$KEEP" | sed ':a;N;s/\n/ /g;ba')"

msg
msg "--- Configuration ---"
msg "Runfile: $RUNFILE"
msg "Runfiles: $RUNFILES"
msg "STF_TOOLS: $STF_TOOLS"
msg "STF_SUITE: $STF_SUITE"
msg "STF_PATH: $STF_PATH"
Expand Down Expand Up @@ -603,12 +611,12 @@ REPORT_FILE=$(mktemp -u -t zts-report.XXXX -p "$FILEDIR")
# Run all the tests as specified.
#
msg "${TEST_RUNNER} ${QUIET:+-q}" \
"-c \"${RUNFILE}\"" \
"-c \"${RUNFILES}\"" \
"-T \"${TAGS}\"" \
"-i \"${STF_SUITE}\"" \
"-I \"${ITERATIONS}\""
${TEST_RUNNER} ${QUIET:+-q} \
-c "${RUNFILE}" \
-c "${RUNFILES}" \
-T "${TAGS}" \
-i "${STF_SUITE}" \
-I "${ITERATIONS}" \
Expand All @@ -630,7 +638,7 @@ fi
rm -f "$RESULTS_FILE" "$REPORT_FILE"

if [ ${#SINGLETEST[@]} -ne 0 ]; then
rm -f "$RUNFILE" &>/dev/null
rm -f "$RUNFILES" &>/dev/null
fi

exit ${RESULT}
4 changes: 2 additions & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The following zfs-tests.sh options are supported:

-s SIZE Use vdevs of SIZE (default: 4G)

-r RUNFILE Run tests in RUNFILE (default: linux.run)
-r RUNFILES Run tests in RUNFILES (default: common.run,linux.run)

-t PATH Run single test at PATH relative to test suite

Expand Down Expand Up @@ -149,4 +149,4 @@ with the `zfs-tests.sh` wrapper script will look something like this:

Running Time: 02:35:33
Percent passed: 95.6%
Log directory: /var/tmp/test_results/20180515T054509
Log directory: /var/tmp/test_results/20180515T054509
1 change: 1 addition & 0 deletions tests/runfiles/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pkgdatadir = $(datadir)/@PACKAGE@/runfiles
dist_pkgdata_DATA = \
common.run \
linux.run \
longevity.run \
perf-regression.run
Loading

0 comments on commit 5e74ac5

Please sign in to comment.