1#!/bin/sh 2# Test for assertion failure in "test". 3 4# Copyright (C) 1999-2023 Free Software Foundation, Inc. 5 6# This program is free software: you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation, either version 3 of the License, or 9# (at your option) any later version. 10 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see <https://www.gnu.org/licenses/>. 18 19 20# This test fails with tail from textutils-2.0. 21# It would get something like this: 22# tail: tail.c:718: recheck: Assertion 'valid_file_spec (f)' failed. 23# Aborted 24# due to a race condition in which a dev/inode pair is reused. 25 26. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 27print_ver_ tail 28 29check_tail_output() 30{ 31 local delay="$1" 32 grep "$tail_re" out || 33 { sleep $delay; return 1; } 34} 35 36# Terminate any background tail process 37cleanup_() { kill $pid 2>/dev/null && wait $pid; } 38 39# Speedup the non inotify case 40fastpoll='-s.1 --max-unchanged-stats=1' 41 42for mode in '' '---disable-inotify'; do 43 rm -f a foo out 44 touch a foo || framework_failure_ 45 46 tail $mode --follow=name $fastpoll a foo > out 2>&1 & pid=$! 47 48 # Wait up to 12.7s for tail to start. 49 echo x > a || framework_failure_ 50 tail_re='^x$' retry_delay_ check_tail_output .1 7 || 51 { cat out; fail=1; break; } 52 53 # Wait 12.7s for this diagnostic: 54 # tail: foo: No such file or directory 55 rm foo || framework_failure_ 56 tail_re='No such file' retry_delay_ check_tail_output .1 7 || 57 { cat out; fail=1; break; } 58 59 # Wait up to 12.7s for tail to notice new foo file 60 ok='ok ok ok' 61 echo "$ok" > foo || framework_failure_ 62 tail_re="^$ok$" retry_delay_ check_tail_output .1 7 || 63 { echo "$0: foo: unexpected delay?"; cat out; fail=1; break; } 64 65 cleanup_ 66done 67 68Exit $fail 69