From 36836607c9e79c9d18de5affcc05ce723ad16a7b Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Tue, 16 Dec 2025 10:29:25 -0800 Subject: [PATCH] check: put temporary files in TMPDIR, not /tmp Nowadays, systemd will auto-remove files from /tmp after 10 days. If you want to run a testcase for more than that duration (e.g. SOAK_DURATION=14d) then the test will fail after the .out file is deleted: xfs/286 _check_xfs_filesystem: filesystem on /dev/sda4 is inconsistent (r) (see /var/tmp/fstests/xfs/286.full for details) sed: can't read /tmp/2098.out: No such file or directory - output mismatch (see /var/tmp/fstests/xfs/286.out.bad) mv: cannot stat '/tmp/2098.out': No such file or directory diff: /var/tmp/fstests/xfs/286.out.bad: No such file or directory This happens because systemd-tmpfiles garbage collects any file in /tmp that becomes older than 10 days: $ cat /usr/lib/tmpfiles.d/tmp.conf # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # See tmpfiles.d(5) for details. # Clear tmp directories separately, to make them easier to override q /tmp 1777 root root 10d q /var/tmp 1777 root root 30d This is now the default in Debian 13 (D12 never deleted anything) which is why I didn't notice this until I upgraded a couple of weeks ago. Most people aren't going to be running a single testcase for more than 10 days so I'll go with the least invasive solution that I can think of. Allow system administrators or fstests runners to set TMPDIR to a directory that won't get purged, and make fstests follow that. Fix up generic/002 so that it doesn't use $tmp for paths on the test filesystem. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Zorro Lang --- check | 2 +- common/preamble | 2 +- tests/generic/002 | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/check b/check index c897afbb..cd7a7934 100755 --- a/check +++ b/check @@ -4,7 +4,7 @@ # # Control script for QA # -tmp=/tmp/$$ +tmp="${TMPDIR:-/tmp}/$$" status=0 needwrap=true needsum=true diff --git a/common/preamble b/common/preamble index 51d03396..1c1eb348 100644 --- a/common/preamble +++ b/common/preamble @@ -47,7 +47,7 @@ _begin_fstest() echo "QA output created by $seq" here=`pwd` - tmp=/tmp/$$ + tmp="${TMPDIR:-/tmp}/$$" status=1 # failure is the default! _register_cleanup _cleanup diff --git a/tests/generic/002 b/tests/generic/002 index b202492b..6df57a7a 100755 --- a/tests/generic/002 +++ b/tests/generic/002 @@ -20,31 +20,31 @@ _require_hardlinks echo "Silence is goodness ..." # ensure target directory exists -mkdir `dirname $TEST_DIR/$tmp` 2>/dev/null +mkdir `dirname $TEST_DIR/tmp` 2>/dev/null -touch $TEST_DIR/$tmp.1 +touch $TEST_DIR/tmp.1 for l in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 do - ln $TEST_DIR/$tmp.1 $TEST_DIR/$tmp.$l - x=`$here/src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'` + ln $TEST_DIR/tmp.1 $TEST_DIR/tmp.$l + x=`$here/src/lstat64 $TEST_DIR/tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'` if [ "$l" -ne $x ] then echo "Arrgh, created link #$l and lstat64 looks like ..." - $here/src/lstat64 $TEST_DIR/$tmp.1 + $here/src/lstat64 $TEST_DIR/tmp.1 status=1 fi done for l in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 do - x=`$here/src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'` + x=`$here/src/lstat64 $TEST_DIR/tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'` if [ "$l" -ne $x ] then echo "Arrgh, about to remove link #$l and lstat64 looks like ..." - $here/src/lstat64 $TEST_DIR/$tmp.1 + $here/src/lstat64 $TEST_DIR/tmp.1 status=1 fi - rm -f $TEST_DIR/$tmp.$l + rm -f $TEST_DIR/tmp.$l done # success, all done -- 2.47.3