]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: fix races wrt output files of background processes
authorBernhard Voelker <mail@bernhard-voelker.de>
Sun, 10 Jan 2016 00:44:04 +0000 (01:44 +0100)
committerBernhard Voelker <mail@bernhard-voelker.de>
Sun, 10 Jan 2016 00:51:27 +0000 (01:51 +0100)
At least the false positive in tail-2/follow-stdin.sh could be seen
on a 4-core i5 system with -j8.  Fix similar cases. too.

* tests/tail-2/follow-stdin.sh: Empty the 'out' file in each iteration.
Otherwise, under heavy system load, 'check_tail_output' would see the
expected output from the previous round before tail would have the
chance to come up in the background.
While at it, move the creation of the 'exp' file out of the loop.
* tests/dd/stats.sh: Empty the output file of the background process
here, too.
* tests/misc/cat-buf.sh: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/tail-2/wait.sh: Likewise.

tests/dd/stats.sh
tests/misc/cat-buf.sh
tests/misc/stdbuf.sh
tests/tail-2/follow-stdin.sh
tests/tail-2/wait.sh

index e8bb5fa27a8e8ad70e13a2d5da13fbff478eb9b4..182d5e7e73894da0d785d50205eb49f13010308f 100755 (executable)
@@ -38,6 +38,8 @@ cleanup_()
 }
 
 for open in '' '1'; do
+  > err || framework_failure_
+
   # Run dd with the fullblock iflag to avoid short reads
   # which can be triggered by reception of signals
   dd iflag=fullblock if=/dev/zero of=fifo count=50 bs=5000000 2>err & pid=$!
index f12bb5bc11b94683597ffdd99ce3a20636b9250e..a6960b566b7ddc3e135d7216e875f0d46f1c185b 100755 (executable)
@@ -35,6 +35,7 @@ cat_buf_1()
 {
   local delay="$1"
 
+  > out || framework_failure_
   dd count=1 if=fifo > out & pid=$!
   (echo 1; sleep $delay; echo 2) | cat -v > fifo
   wait $pid
index a5331deff8438be80dd19032f5f029a22ea007b4..7b9aed5036975dc8049f5077da97ce714d433efd 100755 (executable)
@@ -66,6 +66,7 @@ stdbuf_linebuffer()
   local delay="$1"
 
   printf '1\n' > exp
+  > out || framework_failure_
   dd count=1 if=fifo > out 2> err & pid=$!
   (printf '1\n'; sleep $delay; printf '2\n') | stdbuf -oL uniq > fifo
   wait $pid
@@ -80,6 +81,7 @@ stdbuf_unbuffer()
 
   # Ensure un buffering stdout takes effect
   printf '1\n' > exp
+  > out || framework_failure_
   dd count=1 if=fifo > out 2> err & pid=$!
   (printf '1\n'; sleep $delay; printf '2\n') | stdbuf -o0 uniq > fifo
   wait $pid
index 120cc3bbbce30f25ae0f1d44a31d0eb792302a14..a2f180428e4bb6b95e24e8a9e990cdf9294e17eb 100755 (executable)
@@ -33,9 +33,10 @@ cleanup_() { kill $pid 2>/dev/null && wait $pid; }
 fastpoll='-s.1 --max-unchanged-stats=1'
 
 echo line > in || framework_failure_
+echo line > exp || framework_failure_
 
 for mode in '' '---disable-inotify'; do
-  echo line > exp || framework_failure_
+  > out || framework_failure_
 
   tail $mode -f $fastpoll < in > out 2> err & pid=$!
 
index bcb04858a83b8f32afda61b6eef9a72f3784a572..008f9f55e99941011cf075aec2c336a21a559b16 100755 (executable)
@@ -72,7 +72,7 @@ if test "$HAVE_INOTIFY"; then
   {
     local delay="$1"
 
-    touch k || framework_failure_
+    > k && > tail.out && > tail.err || framework_failure_
     tail $fastpoll -F $mode k >tail.out 2>tail.err & pid=$!
     sleep $delay
     mv k l