Skip to content

Commit 3c9d4fd

Browse files
committed
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 uutils/coreutils#9590
1 parent 3c405ae commit 3c9d4fd

File tree

2 files changed

+12
-45
lines changed

2 files changed

+12
-45
lines changed

tests/local.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ all_root_tests = \
142142
tests/rm/read-only.sh \
143143
tests/rm/empty-immutable-skip.sh \
144144
tests/split/l-chunk-root.sh \
145+
tests/tac/tac-continue.sh \
145146
tests/tail/append-only.sh \
146147
tests/tail/end-of-device.sh \
147148
tests/touch/now-owned-by-other.sh
@@ -459,7 +460,6 @@ all_tests = \
459460
tests/cksum/sum-sysv.sh \
460461
tests/misc/sync.sh \
461462
tests/tac/tac.pl \
462-
tests/tac/tac-continue.sh \
463463
tests/tac/tac-locale.sh \
464464
tests/tac/tac-2-nonseekable.sh \
465465
tests/tail/tail.pl \

tests/tac/tac-continue.sh

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,57 +20,24 @@
2020

2121
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
2222
print_ver_ tac
23+
require_root_
2324

24-
# See if the envvar is defined.
25-
if test x = "x$FULL_PARTITION_TMPDIR"; then
26-
skip_ "FULL_PARTITION_TMPDIR not defined"
27-
fi
25+
cwd=$(pwd)
26+
cleanup_() { cd /; umount "$cwd/full_tmp"; }
2827

29-
if ! test -d "$FULL_PARTITION_TMPDIR"; then
30-
echo "$0: $FULL_PARTITION_TMPDIR:" \
31-
"\$FULL_PARTITION_TMPDIR does not specify a directory" 1>&2
32-
Exit 1
33-
fi
28+
mkdir full_tmp || framework_failure_
3429

35-
fp_tmp="$FULL_PARTITION_TMPDIR/tac-cont-$$"
36-
cleanup_()
37-
{
38-
# Terminate any background process
39-
# and remove tmp dir
40-
rm -f "$fp_tmp"
41-
kill $pid 2>/dev/null && wait $pid
42-
}
30+
mount -t tmpfs --options size=1M tmpfs $cwd/full_tmp ||
31+
skip_ 'Unable to mount small tmpfs'
4332

4433
# Make sure we can create an empty file there (i.e., no shortage of inodes).
45-
if ! touch $fp_tmp; then
46-
echo "$0: $fp_tmp: cannot create empty file" 1>&2
47-
Exit 1
48-
fi
34+
touch "$cwd/full_tmp/tac-empty" || framework_failure_
4935

50-
# Make sure that we fail when trying to create a file large enough
51-
# to consume a non-inode block.
52-
if seq 1000 > $fp_tmp 2>/dev/null; then
53-
echo "$0: $FULL_PARTITION_TMPDIR: not a full partition" 1>&2
54-
Exit 1
55-
fi
56-
57-
seq 5 > in
58-
59-
60-
# Give tac a fifo command line argument.
61-
# This makes it try to create a temporary file in $TMPDIR.
62-
mkfifo_or_skip_ fifo
63-
seq 1000 > fifo & pid=$!
64-
TMPDIR=$FULL_PARTITION_TMPDIR tac fifo in >out 2>err && fail=1
65-
66-
cat <<\EOF > exp || framework_failure_
67-
5
68-
4
69-
3
70-
2
71-
1
72-
EOF
36+
seq 5 > five && seq 5 -1 1 > exp || framework_failure_
7337

38+
# Make sure we diagnose the failure but continue to subsequent files
39+
yes | TMPDIR=$cwd/full_tmp timeout 10 tac - five >out 2>err && fail=1
40+
{ test $? = 124 || ! grep 'space' err >/dev/null; } && fail=1
7441
compare exp out || fail=1
7542

7643
Exit $fail

0 commit comments

Comments
 (0)