summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2016-11-09 17:51:13 +0000
committerPádraig Brady <P@draigBrady.com>2016-11-09 21:38:33 +0000
commit659060233ff2cff324be5cf4cc40b782068d45fd (patch)
treee3769014e9f5723a91836eaca3835ca80cc89f07 /tests
parent7fc7206b03a7f54b23904373ad397f693a5fae2a (diff)
downloadcoreutils-659060233ff2cff324be5cf4cc40b782068d45fd.tar.xz
tail: ensure -f --retry 'missing' handles truncation
* src/tail.c (tail_forever): The BLOCKING optimization is only enabled for non regular files (which can't be truncated), so ensure we don't enable that unless we've a valid file descriptor. * tests/tail-2/retry.sh: Add a test case. * NEWS: Mention the bug fix.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/tail-2/retry.sh13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/tail-2/retry.sh b/tests/tail-2/retry.sh
index b764aa7f1..858909f65 100755
--- a/tests/tail-2/retry.sh
+++ b/tests/tail-2/retry.sh
@@ -83,17 +83,22 @@ timeout 10 \
tail $mode $fastpoll --follow=descriptor --retry missing >out 2>&1 & pid=$!
# Wait for "cannot open" error.
retry_delay_ wait4lines_ .1 6 2 || { cat out; fail=1; }
-echo "X" > missing || framework_failure_
+echo "X1" > missing || framework_failure_
# Wait for the expected output.
retry_delay_ wait4lines_ .1 6 4 || { cat out; fail=1; }
+# Ensure truncation is detected
+# tail-8.25 failed at this (as assumed non file and went into blocking mode)
+echo "X" > missing || framework_failure_
+retry_delay_ wait4lines_ .1 6 6 || { cat out; fail=1; }
cleanup_
-# Expect 4 lines in the output file.
-[ "$(countlines_)" = 4 ] || { fail=1; cat out; }
+[ "$(countlines_)" = 6 ] || { fail=1; cat out; }
grep -F 'retry only effective for the initial open' out \
|| { fail=1; cat out; }
grep -F 'cannot open' out || { fail=1; cat out; }
grep -F 'has appeared' out || { fail=1; cat out; }
-grep '^X$' out || { fail=1; cat out; }
+grep '^X1$' out || { fail=1; cat out; }
+grep -F 'file truncated' out || { fail=1; cat out; }
+grep '^X$' out || { fail=1; cat out; }
rm -f missing out || framework_failure_
# === Test: