Skip to content

Commit

Permalink
ZTS: make uses of mktemp consistent
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Tino Reichardt <[email protected]>
Reviewed-by: Igor Kozhukhov <[email protected]>
  • Loading branch information
robn authored and tonyhutter committed Feb 27, 2025
1 parent 6003190 commit 72c0fde
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 16 deletions.
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)
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 @@ -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

0 comments on commit 72c0fde

Please sign in to comment.