diff --git a/scripts/zfs-tests.sh b/scripts/zfs-tests.sh index ae62f8f2a..4a874119e 100755 --- a/scripts/zfs-tests.sh +++ b/scripts/zfs-tests.sh @@ -718,6 +718,12 @@ 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" @@ -725,6 +731,7 @@ 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" diff --git a/tests/test-runner/bin/test-runner.py.in b/tests/test-runner/bin/test-runner.py.in index 2538f99ca..abe27d17d 100755 --- a/tests/test-runner/bin/test-runner.py.in +++ b/tests/test-runner/bin/test-runner.py.in @@ -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):