]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
check: put temporary files in TMPDIR, not /tmp
authorDarrick J. Wong <djwong@kernel.org>
Tue, 16 Dec 2025 18:29:25 +0000 (10:29 -0800)
committerZorro Lang <zlang@kernel.org>
Wed, 31 Dec 2025 22:19:31 +0000 (06:19 +0800)
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 <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
check
common/preamble
tests/generic/002

diff --git a/check b/check
index c897afbb4196121d9260b420195ea1a9191df533..cd7a79347eac2896c9cab6bcf23b06da940c98e1 100755 (executable)
--- a/check
+++ b/check
@@ -4,7 +4,7 @@
 #
 # Control script for QA
 #
-tmp=/tmp/$$
+tmp="${TMPDIR:-/tmp}/$$"
 status=0
 needwrap=true
 needsum=true
index 51d03396c9686438b3b325768bd8c2acb24a0605..1c1eb348a881149ac4a98b9e6dcf171f4f160679 100644 (file)
@@ -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
index b202492b49a73cba2feb02d5c6ed273b66fdfccb..6df57a7a1353c72cff7b5c61e17eef72261bfb6a 100755 (executable)
@@ -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