ZTS: make uses of mktemp consistent

In all cases, rely on mktemp itself to make the best decision about
where to place the file or directory. In all cases, that decision will
be $TMPDIR, which we have set globally.

Sponsored-by: https://despairlabs.com/sponsor/
Signed-off-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
This commit is contained in:
Rob Norris 2025-02-15 14:41:19 +11:00 committed by Tony Hutter
parent a1786ca93c
commit 6f8ff94016
12 changed files with 16 additions and 16 deletions

View File

@ -130,7 +130,7 @@ function test_posix_mode # base
} }
# Sanity check on tmpfs first # Sanity check on tmpfs first
tmpdir=$(TMPDIR=$TEST_BASE_DIR mktemp -d) tmpdir=$(mktemp -d)
log_must mount -t tmpfs tmp $tmpdir log_must mount -t tmpfs tmp $tmpdir
log_must chmod 777 $tmpdir log_must chmod 777 $tmpdir

View File

@ -40,8 +40,8 @@
# dbufstat and the dbufs kstat output # dbufstat and the dbufs kstat output
# #
DBUFSTATS_FILE=$(mktemp $TEST_BASE_DIR/dbufstats.out.XXXXXX) DBUFSTATS_FILE=$(mktemp -t dbufstats.out.XXXXXX)
DBUFS_FILE=$(mktemp $TEST_BASE_DIR/dbufs.out.XXXXXX) DBUFS_FILE=$(mktemp -t dbufs.out.XXXXXX)
function cleanup function cleanup
{ {

View File

@ -42,7 +42,7 @@
# 8. Ensure that at least some dbufs moved to the mfu list in the ARC # 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 function cleanup
{ {

View File

@ -48,8 +48,8 @@ function cleanup
log_assert "Verify that 'zfs send' drills appropriate holes" log_assert "Verify that 'zfs send' drills appropriate holes"
log_onexit cleanup log_onexit cleanup
streamfile=$(mktemp $TESTDIR/file.XXXXXX) streamfile=$(mktemp)
vdev=$(mktemp $TEST_BASE_DIR/file.XXXXXX) vdev=$(mktemp)
function test_pool function test_pool

View File

@ -160,7 +160,7 @@ while (( i < ${#pools[*]} )); do
((i = i + 1)) ((i = i + 1))
done done
VDEV_FILE=$(mktemp $TEST_BASE_DIR/tmp.XXXXXX) VDEV_FILE=$(mktemp)
log_must mkfile -n 128M $VDEV_FILE log_must mkfile -n 128M $VDEV_FILE
log_must zpool create overflow $VDEV_FILE log_must zpool create overflow $VDEV_FILE

View File

@ -28,7 +28,7 @@ typeset ds_name="panic"
typeset sendfs="$POOL/$ds_name" typeset sendfs="$POOL/$ds_name"
typeset recvfs="$POOL2/$ds_name" typeset recvfs="$POOL2/$ds_name"
typeset clone="$POOL/${ds_name}_clone" typeset clone="$POOL/${ds_name}_clone"
typeset stream=$(mktemp $TEST_BASE_DIR/stream.XXXX) typeset stream=$(mktemp -t stream.XXXX)
function cleanup function cleanup
{ {

View File

@ -63,7 +63,7 @@ function cleanup
log_assert "Verify an archive of a file system is identical to " \ log_assert "Verify an archive of a file system is identical to " \
"an archive of its snapshot." "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 log_onexit cleanup
typeset -i COUNT=21 typeset -i COUNT=21

View File

@ -72,7 +72,7 @@ function cleanup
log_assert "Verify that an archive of a dataset is identical to " \ log_assert "Verify that an archive of a dataset is identical to " \
"an archive of the dataset's snapshot." "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 log_onexit cleanup
typeset -i COUNT=21 typeset -i COUNT=21

View File

@ -58,7 +58,7 @@ log_onexit user_ns_cleanup
log_must zfs create -o zoned=on "$TESTPOOL/userns" log_must zfs create -o zoned=on "$TESTPOOL/userns"
# 1. Try to pass a non-namespace file to zfs zone. # 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" log_mustnot zfs zone "$temp_file" "$TESTPOOL/userns"
# 2. Try to pass a non-namespace and non-existent file to zfs zone. # 2. Try to pass a non-namespace and non-existent file to zfs zone.

View File

@ -47,8 +47,8 @@ if ! is_linux ; then
log_unsupported "Only linux supports dd with oflag=dsync for FUA writes" log_unsupported "Only linux supports dd with oflag=dsync for FUA writes"
fi fi
typeset datafile1="$(mktemp zvol_misc_fua1.XXXXXX)" typeset datafile1="$(mktemp -t zvol_misc_fua1.XXXXXX)"
typeset datafile2="$(mktemp zvol_misc_fua2.XXXXXX)" typeset datafile2="$(mktemp -t zvol_misc_fua2.XXXXXX)"
typeset zvolpath=${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL typeset zvolpath=${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL
function cleanup function cleanup

View File

@ -65,8 +65,8 @@ if ! is_physical_device $DISKS; then
log_unsupported "This directory cannot be run on raw files." log_unsupported "This directory cannot be run on raw files."
fi fi
typeset datafile1="$(mktemp zvol_misc_flags1.XXXXXX)" typeset datafile1="$(mktemp -t zvol_misc_flags1.XXXXXX)"
typeset datafile2="$(mktemp zvol_misc_flags2.XXXXXX)" typeset datafile2="$(mktemp -t zvol_misc_flags2.XXXXXX)"
typeset zvolpath=${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL typeset zvolpath=${ZVOL_DEVDIR}/$TESTPOOL/$TESTVOL
function cleanup function cleanup

View File

@ -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 / \ typeset -f each_zvol_size=$(( floor($biggest_zvol_size_possible * 0.9 / \
$num_zvols ))) $num_zvols )))
typeset tmpdir="$(mktemp -d zvol_stress_fio_state.XXXXXX)" typeset tmpdir="$(mktemp -t -d zvol_stress_fio_state.XXXXXX)"
function create_zvols function create_zvols
{ {