dd630c5a77b0736cfdc08a74911832738f197b8b
[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 # FIXME: actually, I couldn't find a way to write the test (without resorting
7 # to use of expect) so that it would provoke the failure on solaris5.7.
8 # To exercise the bug, cat's stdout seems to have to be directed
9 # to a terminal.
10
11 if test "$VERBOSE" = yes; then
12   set -x
13   tail --version
14 fi
15
16 tmp=tail-flush.$$
17 pwd=`pwd`
18 trap "cd $pwd; rm -rf $tmp" 0 1 2 3 15
19
20 test_failure=0
21 mkdir $tmp || test_failure=1
22 cd $tmp || test_failure=1
23
24 if test $test_failure = 1; then
25   echo 'failure in testing framework'
26   exit 1
27 fi
28
29 echo fubar > in
30 tail -f in | cat > out &
31 pid=$!
32 sleep 1
33 kill $pid
34
35 fail=0
36 test "`cat out`" = fubar || fail=1
37
38 exit $fail