c036e2619160b757b07d8a66d4f29ae47749804e
[platform/upstream/coreutils.git] / tests / tail-2 / assert-2
1 #!/bin/sh
2 # This variant of `assert' would get a UMR reliably in 2.0.9.
3 # Due to a race condition in the test, the `assert' script would get
4 # the UMR on Solaris only some of the time, and not at all on Linux/GNU.
5
6 if test "$VERBOSE" = yes; then
7   set -x
8   tail --version
9 fi
10
11 tmp=tail-as2.$$
12 pwd=`pwd`
13 trap "cd $pwd; rm -rf $tmp" 0 1 2 3 15
14
15 test_failure=0
16 mkdir $tmp || test_failure=1
17 cd $tmp || test_failure=1
18
19 if test $test_failure = 1; then
20   echo 'failure in testing framework'
21   exit 1
22 fi
23
24 ok='ok ok ok'
25
26 touch a
27 tail --follow=name a foo > err 2>&1 &
28 tail_pid=$!
29 # Arrange for the tail process to die after 12 seconds.
30 (sleep 12; kill $tail_pid) &
31 echo $ok > f
32 echo sleeping for 7 seconds...
33 sleep 7
34 mv f foo
35
36 # echo waiting....
37 wait
38
39 case "`cat err`" in
40   *$ok) fail=0;;
41   *) fail=1;;
42 esac
43
44 test $fail = 1 && cat err
45
46 exit $fail