Add/fix copyright notices and adjust to latest GNU FDL.
[platform/upstream/coreutils.git] / tests / tail-2 / fflush
1 #!/bin/sh
2 # This test would fail on solaris5.7 with tail from pre-1.22k textutils.
3 # The problem was that using the solaris5.7 setvbuf function to turn off
4 # buffering doesn't flush stdout.
5
6 # Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
7
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 # 02110-1301, USA.
22
23
24 # FIXME: actually, I couldn't find a way to write the test (without resorting
25 # to use of expect) so that it would provoke the failure on solaris5.7.
26 # To exercise the bug, cat's stdout seems to have to be directed
27 # to a terminal.
28
29 if test "$VERBOSE" = yes; then
30   set -x
31   tail --version
32 fi
33
34 tmp=tail-flush.$$
35 pwd=`pwd`
36 trap "cd $pwd; rm -rf $tmp" 0 1 2 3 15
37
38 test_failure=0
39 mkdir $tmp || test_failure=1
40 cd $tmp || test_failure=1
41
42 if test $test_failure = 1; then
43   echo 'failure in testing framework'
44   exit 1
45 fi
46
47 echo fubar > in
48 tail -f in | cat > out &
49 pid=$!
50 sleep 1
51 kill $pid
52
53 fail=0
54 test "`cat out`" = fubar || fail=1
55
56 exit $fail