Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZTS: allow alternate work and output dir #17059

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions scripts/zfs-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ cleanup_all() {
else
TEST_LOOPBACKS=$("${LOSETUP}" -a | awk -F: '/file-vdev/ {print $1}')
fi
TEST_FILES=$(ls "${FILEDIR}"/file-vdev* /var/tmp/file-vdev* 2>/dev/null)
TEST_FILES=$(ls "${FILEDIR}"/file-vdev* 2>/dev/null)

msg
msg "--- Cleanup ---"
Expand Down Expand Up @@ -308,8 +308,8 @@ constrain_path() {
# Special case links for zfs test suite utilities
create_links "$CMD_DIR/tests/zfs-tests/cmd" "$ZFSTEST_FILES"
else
# Constrained path set to /var/tmp/constrained_path.*
SYSTEMDIR=${SYSTEMDIR:-/var/tmp/constrained_path.XXXXXX}
# Constrained path set to $FILEDIR/constrained_path.*
SYSTEMDIR=${SYSTEMDIR:-$FILEDIR/constrained_path.XXXXXX}
STF_PATH=$(mktemp -d "$SYSTEMDIR")
STF_PATH_REMOVE="yes"
STF_MISSING_BIN=""
Expand Down Expand Up @@ -492,7 +492,7 @@ if [ -n "$SINGLETEST" ]; then
if [ -n "$TAGS" ]; then
fail "-t and -T are mutually exclusive."
fi
RUNFILE_DIR="/var/tmp"
RUNFILE_DIR="$FILEDIR"
RUNFILES="zfs-tests.$$.run"
[ -n "$QUIET" ] && SINGLEQUIET="True" || SINGLEQUIET="False"

Expand All @@ -505,7 +505,6 @@ user = $SINGLETESTUSER
timeout = 600
post_user = root
post =
outputdir = /var/tmp/test_results
EOF
if [ "$SINGLETEST" = "${SINGLETEST%/*}" ] ; then
NEWSINGLETEST=$(find "$STF_SUITE" -name "$SINGLETEST*" -print -quit)
Expand Down Expand Up @@ -719,13 +718,20 @@ if [ -e /sys/module/zfs/parameters/zfs_dbgmsg_enable ]; then
sudo sh -c "echo 0 >/proc/spl/kstat/zfs/dbgmsg"
fi

#
# Set TMPDIR. Some tests run mktemp, and we want those files contained to
# the work dir the same as any other.
#
export TMPDIR="$FILEDIR"

msg
msg "--- Configuration ---"
msg "Runfiles: $RUNFILES"
msg "STF_TOOLS: $STF_TOOLS"
msg "STF_SUITE: $STF_SUITE"
msg "STF_PATH: $STF_PATH"
msg "FILEDIR: $FILEDIR"
msg "TMPDIR: $TMPDIR"
msg "FILES: $FILES"
msg "LOOPBACKS: $LOOPBACKS"
msg "DISKS: $DISKS"
Expand Down
1 change: 0 additions & 1 deletion tests/runfiles/bclone.run
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ post_user = root
post = cleanup
failsafe_user = root
failsafe = callbacks/zfs_failsafe
outputdir = /var/tmp/test_results
tags = ['bclone']

[tests/functional/bclone]
Expand Down
1 change: 0 additions & 1 deletion tests/runfiles/common.run
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ post_user = root
post = cleanup
failsafe_user = root
failsafe = callbacks/zfs_failsafe
outputdir = /var/tmp/test_results
tags = ['functional']

[tests/functional/acl/off]
Expand Down
1 change: 0 additions & 1 deletion tests/runfiles/freebsd.run
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ post_user = root
post = cleanup
failsafe_user = root
failsafe = callbacks/zfs_failsafe
outputdir = /var/tmp/test_results
tags = ['functional']

[tests/functional/cli_root/zfs_jail:FreeBSD]
Expand Down
1 change: 0 additions & 1 deletion tests/runfiles/linux.run
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ post_user = root
post = cleanup
failsafe_user = root
failsafe = callbacks/zfs_failsafe
outputdir = /var/tmp/test_results
tags = ['functional']

[tests/functional/acl/posix:Linux]
Expand Down
1 change: 0 additions & 1 deletion tests/runfiles/longevity.run
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
quiet = False
user = root
timeout = 10800
outputdir = /var/tmp/test_results

[/opt/zfs-tests/tests/longevity]
tests = ['slop_space_test']
1 change: 0 additions & 1 deletion tests/runfiles/perf-regression.run
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ user = root
timeout = 0
post_user = root
post = cleanup
outputdir = /var/tmp/test_results
tags = ['perf']

[tests/perf/regression]
Expand Down
1 change: 0 additions & 1 deletion tests/runfiles/sanity.run
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ post_user = root
post = cleanup
failsafe_user = root
failsafe = callbacks/zfs_failsafe
outputdir = /var/tmp/test_results
tags = ['functional']

[tests/functional/acl/off]
Expand Down
1 change: 0 additions & 1 deletion tests/runfiles/sunos.run
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ post_user = root
post = cleanup
failsafe_user = root
failsafe = callbacks/zfs_failsafe
outputdir = /var/tmp/test_results
tags = ['functional']

[tests/functional/inuse:illumos]
Expand Down
27 changes: 24 additions & 3 deletions tests/test-runner/bin/test-runner.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,15 @@ User: %s
if os.path.isfile(cmd+'.sh') and os.access(cmd+'.sh', os.X_OK):
cmd += '.sh'

ret = '%s -E -u %s %s' % (SUDO, user, cmd)
# glibc (at least) will not pass TMPDIR through to setuid programs.
# if set, arrange for it to be reset before running the target cmd
tmpdir = os.getenv('TMPDIR')
if tmpdir:
tmpdirarg = 'env TMPDIR=%s' % tmpdir
else:
tmpdirarg = ''

ret = '%s -E -u %s %s %s' % (SUDO, user, tmpdirarg, cmd)
return ret.split(' ')

def collect_output(self, proc, debug=False):
Expand Down Expand Up @@ -746,8 +754,11 @@ class TestRun(object):

for opt in TestRun.props:
if config.has_option('DEFAULT', opt):
setattr(self, opt, config.get('DEFAULT', opt))
self.outputdir = os.path.join(self.outputdir, self.timestamp)
if opt == 'outputdir':
outputdir = config.get('DEFAULT', opt)
setattr(self, opt, os.path.join(outputdir, self.timestamp))
else:
setattr(self, opt, config.get('DEFAULT', opt))

testdir = options.testdir

Expand Down Expand Up @@ -775,6 +786,11 @@ class TestRun(object):
failsafe = config.get(sect, prop)
setattr(testgroup, prop,
os.path.join(testdir, failsafe))
elif prop == 'outputdir':
outputdir = config.get(sect, prop)
setattr(self, opt,
os.path.join(outputdir,
self.timestamp))
else:
setattr(testgroup, prop,
config.get(sect, prop))
Expand All @@ -793,6 +809,11 @@ class TestRun(object):
failsafe = config.get(sect, prop)
setattr(test, prop,
os.path.join(testdir, failsafe))
elif prop == 'outputdir':
outputdir = config.get(sect, prop)
setattr(self, opt,
os.path.join(outputdir,
self.timestamp))
else:
setattr(test, prop, config.get(sect, prop))

Expand Down
2 changes: 1 addition & 1 deletion tests/zfs-tests/include/default.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Linux)
DEV_RDSKDIR="/dev"
DEV_MPATHDIR="/dev/mapper"

ZEDLET_DIR="/var/tmp/zed"
ZEDLET_DIR="$TEST_BASE_DIR/zed"
ZED_LOG="$ZEDLET_DIR/zed.log"
ZED_DEBUG_LOG="$ZEDLET_DIR/zed.debug.log"
VDEVID_CONF="$ZEDLET_DIR/vdev_id.conf"
Expand Down
8 changes: 4 additions & 4 deletions tests/zfs-tests/include/libtest.shlib
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ function set_partition
log_fail "The slice, size or disk name is unspecified."
fi

typeset format_file=/var/tmp/format_in.$$
typeset format_file="$TEST_BASE_DIR"/format_in.$$

echo "partition" >$format_file
echo "$slicenum" >> $format_file
Expand Down Expand Up @@ -2404,7 +2404,7 @@ function add_user #<group_name> <user_name> <basedir>
{
typeset group=$1
typeset user=$2
typeset basedir=${3:-"/var/tmp"}
typeset basedir=${3:-"$TEST_BASE_DIR"}

if ((${#group} == 0 || ${#user} == 0)); then
log_fail "group name or user name are not defined."
Expand Down Expand Up @@ -2434,7 +2434,7 @@ function add_user #<group_name> <user_name> <basedir>
function del_user #<logname> <basedir>
{
typeset user=$1
typeset basedir=${2:-"/var/tmp"}
typeset basedir=${2:-"$TEST_BASE_DIR"}

if ((${#user} == 0)); then
log_fail "login name is necessary."
Expand Down Expand Up @@ -3184,7 +3184,7 @@ function zed_start
return
fi

# ZEDLET_DIR=/var/tmp/zed
# ZEDLET_DIR=$TEST_BASE_DIR/zed
if [[ ! -d $ZEDLET_DIR ]]; then
log_must mkdir $ZEDLET_DIR
fi
Expand Down
2 changes: 1 addition & 1 deletion tests/zfs-tests/tests/functional/acl/off/posixmode.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function test_posix_mode # base
}

# Sanity check on tmpfs first
tmpdir=$(TMPDIR=$TEST_BASE_DIR mktemp -d)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code makes it easier to clean up the temporary ZTS files after a failed run, since you'd know they'd be in a fixed location ($TEST_BASE_DIR aka /var/tmp). I would keep this as-is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous commit defaults TMPDIR to FILEDIR, which is TEST_BASE_DIR, making this specific line a no-op change for the default case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, my mistake, I missed where you added export TMPDIR="$FILEDIR"

tmpdir=$(mktemp -d)
log_must mount -t tmpfs tmp $tmpdir
log_must chmod 777 $tmpdir

Expand Down
4 changes: 2 additions & 2 deletions tests/zfs-tests/tests/functional/arc/dbufstats_001_pos.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
# dbufstat and the dbufs kstat output
#

DBUFSTATS_FILE=$(mktemp $TEST_BASE_DIR/dbufstats.out.XXXXXX)
DBUFS_FILE=$(mktemp $TEST_BASE_DIR/dbufs.out.XXXXXX)
DBUFSTATS_FILE=$(mktemp -t dbufstats.out.XXXXXX)
DBUFS_FILE=$(mktemp -t dbufs.out.XXXXXX)

function cleanup
{
Expand Down
2 changes: 1 addition & 1 deletion tests/zfs-tests/tests/functional/arc/dbufstats_002_pos.ksh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# 8. Ensure that at least some dbufs moved to the mfu list in the ARC
#

DBUFS_FILE=$(mktemp $TEST_BASE_DIR/dbufs.out.XXXXXX)
DBUFS_FILE=$(mktemp -t dbufs.out.XXXXXX)

function cleanup
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ function cleanup

log_assert "Verify that 'zfs send' drills appropriate holes"
log_onexit cleanup
streamfile=$(mktemp $TESTDIR/file.XXXXXX)
vdev=$(mktemp $TEST_BASE_DIR/file.XXXXXX)
streamfile=$(mktemp)
vdev=$(mktemp)


function test_pool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ while (( i < ${#pools[*]} )); do
((i = i + 1))
done

VDEV_FILE=$(mktemp $TEST_BASE_DIR/tmp.XXXXXX)
VDEV_FILE=$(mktemp)

log_must mkfile -n 128M $VDEV_FILE
log_must zpool create overflow $VDEV_FILE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
# home directory.
#
# STRATEGY:
# 1. Change HOME to /var/tmp
# 1. Change HOME to /var/tmp (TEST_BASE_DIR)
# 2. Make a simple script that echoes a key value pair
# in /var/tmp/.zpool.d
# in $HOME/.zpool.d
# 3. Make sure it can be run with -c
# 4. Remove the script we created

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
# home directory.
#
# STRATEGY:
# 1. Change HOME to /var/tmp
# 1. Change HOME to /var/tmp (TEST_BASE_DIR)
# 2. Make a simple script that echoes a key value pair
# in /var/tmp/.zpool.d
# in $HOME/.zpool.d
# 3. Make sure it can be run with -c
# 4. Remove the script we created

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typeset ds_name="panic"
typeset sendfs="$POOL/$ds_name"
typeset recvfs="$POOL2/$ds_name"
typeset clone="$POOL/${ds_name}_clone"
typeset stream=$(mktemp $TEST_BASE_DIR/stream.XXXX)
typeset stream=$(mktemp -t stream.XXXX)

function cleanup
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function cleanup
log_assert "Verify an archive of a file system is identical to " \
"an archive of its snapshot."

SNAPSHOT_TARDIR="$(mktemp -d /tmp/zfstests_snapshot_002.XXXXXX)"
SNAPSHOT_TARDIR="$(mktemp -t -d zfstests_snapshot_002.XXXXXX)"
log_onexit cleanup

typeset -i COUNT=21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function cleanup
log_assert "Verify that an archive of a dataset is identical to " \
"an archive of the dataset's snapshot."

SNAPSHOT_TARDIR="$(mktemp -d /tmp/zfstests_snapshot_006.XXXXXX)"
SNAPSHOT_TARDIR="$(mktemp -t -d zfstests_snapshot_006.XXXXXX)"
log_onexit cleanup

typeset -i COUNT=21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ log_onexit user_ns_cleanup
log_must zfs create -o zoned=on "$TESTPOOL/userns"

# 1. Try to pass a non-namespace file to zfs zone.
temp_file="$(TMPDIR=$TEST_BASE_DIR mktemp)"
temp_file="$(mktemp)"
log_mustnot zfs zone "$temp_file" "$TESTPOOL/userns"

# 2. Try to pass a non-namespace and non-existent file to zfs zone.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ if ! is_linux ; then
log_unsupported "Only linux supports dd with oflag=dsync for FUA writes"
fi

typeset datafile1="$(mktemp zvol_misc_fua1.XXXXXX)"
typeset datafile2="$(mktemp zvol_misc_fua2.XXXXXX)"
typeset datafile1="$(mktemp -t zvol_misc_fua1.XXXXXX)"
typeset datafile2="$(mktemp -t zvol_misc_fua2.XXXXXX)"
typeset zvolpath=${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL

function cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ if ! is_physical_device $DISKS; then
log_unsupported "This directory cannot be run on raw files."
fi

typeset datafile1="$(mktemp zvol_misc_flags1.XXXXXX)"
typeset datafile2="$(mktemp zvol_misc_flags2.XXXXXX)"
typeset datafile1="$(mktemp -t zvol_misc_flags1.XXXXXX)"
typeset datafile2="$(mktemp -t zvol_misc_flags2.XXXXXX)"
typeset zvolpath=${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL

function cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ biggest_zvol_size_possible=$(largest_volsize_from_pool $TESTPOOL)
typeset -f each_zvol_size=$(( floor($biggest_zvol_size_possible * 0.9 / \
$num_zvols )))

typeset tmpdir="$(mktemp -d zvol_stress_fio_state.XXXXXX)"
typeset tmpdir="$(mktemp -t -d zvol_stress_fio_state.XXXXXX)"

function create_zvols
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# 1. Create a pool
# 2. Create a zvol volume
# 3. Use zvol as swap space
# 4. Create a file under /var/tmp
# 4. Create a file under /var/tmp (TEST_BASE_DIR)
#

verify_runnable "global"
Expand All @@ -63,11 +63,11 @@ voldev=${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL
log_note "Add zvol volume as swap space"
log_must swap_setup $voldev

log_note "Create a file under /var/tmp"
log_note "Create a file under $TEST_BASE_DIR"
log_must file_write -o create -f $TEMPFILE \
-b $BLOCKSZ -c $NUM_WRITES -d $DATA

[[ ! -f $TEMPFILE ]] && log_fail "Unable to create file under /var/tmp"
[[ ! -f $TEMPFILE ]] && log_fail "Unable to create file under $TEST_BASE_DIR"

filesize=`ls -l $TEMPFILE | awk '{print $5}'`
tf_size=$(( BLOCKSZ * NUM_WRITES ))
Expand Down
Loading