From: Pádraig Brady
Date: Sun, 7 Dec 2025 13:24:00 +0000 (+0000) Subject: tests: tac-continue.sh: modernise and always execute as root X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c9d4fdd83ca1e13d001ef160301c10eb5de50c6;p=thirdparty%2Fcoreutils.git tests: tac-continue.sh: modernise and always execute as root * tests/tac/tac-continue.sh: This test was very awkard to setup, and thus always skipped. Instead move to a root only test that creates an almost full partition itself. * tests/local.mk: Move test to root only. Suggested at https://github.com/uutils/coreutils/pull/9590 --- diff --git a/tests/local.mk b/tests/local.mk index 8d8ef2767c..955de4e22a 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -142,6 +142,7 @@ all_root_tests = \ tests/rm/read-only.sh \ tests/rm/empty-immutable-skip.sh \ tests/split/l-chunk-root.sh \ + tests/tac/tac-continue.sh \ tests/tail/append-only.sh \ tests/tail/end-of-device.sh \ tests/touch/now-owned-by-other.sh @@ -459,7 +460,6 @@ all_tests = \ tests/cksum/sum-sysv.sh \ tests/misc/sync.sh \ tests/tac/tac.pl \ - tests/tac/tac-continue.sh \ tests/tac/tac-locale.sh \ tests/tac/tac-2-nonseekable.sh \ tests/tail/tail.pl \ diff --git a/tests/tac/tac-continue.sh b/tests/tac/tac-continue.sh index b4c92c1fd2..a5daaa06f4 100755 --- a/tests/tac/tac-continue.sh +++ b/tests/tac/tac-continue.sh @@ -20,57 +20,24 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ tac +require_root_ -# See if the envvar is defined. -if test x = "x$FULL_PARTITION_TMPDIR"; then - skip_ "FULL_PARTITION_TMPDIR not defined" -fi +cwd=$(pwd) +cleanup_() { cd /; umount "$cwd/full_tmp"; } -if ! test -d "$FULL_PARTITION_TMPDIR"; then - echo "$0: $FULL_PARTITION_TMPDIR:" \ - "\$FULL_PARTITION_TMPDIR does not specify a directory" 1>&2 - Exit 1 -fi +mkdir full_tmp || framework_failure_ -fp_tmp="$FULL_PARTITION_TMPDIR/tac-cont-$$" -cleanup_() -{ - # Terminate any background process - # and remove tmp dir - rm -f "$fp_tmp" - kill $pid 2>/dev/null && wait $pid -} +mount -t tmpfs --options size=1M tmpfs $cwd/full_tmp || + skip_ 'Unable to mount small tmpfs' # Make sure we can create an empty file there (i.e., no shortage of inodes). -if ! touch $fp_tmp; then - echo "$0: $fp_tmp: cannot create empty file" 1>&2 - Exit 1 -fi +touch "$cwd/full_tmp/tac-empty" || framework_failure_ -# Make sure that we fail when trying to create a file large enough -# to consume a non-inode block. -if seq 1000 > $fp_tmp 2>/dev/null; then - echo "$0: $FULL_PARTITION_TMPDIR: not a full partition" 1>&2 - Exit 1 -fi - -seq 5 > in - - -# Give tac a fifo command line argument. -# This makes it try to create a temporary file in $TMPDIR. -mkfifo_or_skip_ fifo -seq 1000 > fifo & pid=$! -TMPDIR=$FULL_PARTITION_TMPDIR tac fifo in >out 2>err && fail=1 - -cat <<\EOF > exp || framework_failure_ -5 -4 -3 -2 -1 -EOF +seq 5 > five && seq 5 -1 1 > exp || framework_failure_ +# Make sure we diagnose the failure but continue to subsequent files +yes | TMPDIR=$cwd/full_tmp timeout 10 tac - five >out 2>err && fail=1 +{ test $? = 124 || ! grep 'space' err >/dev/null; } && fail=1 compare exp out || fail=1 Exit $fail