From e34894bf3f52f1600e5a334ddeec9c2a7e431853 Mon Sep 17 00:00:00 2001 From: Pádraig Brady
Date: Mon, 1 Dec 2008 01:08:02 +0000 Subject: tests: dd/reblock: Reduce chance of timing related failures * tests/dd/reblock: Change the IPC mechanism to the dd process under test, from pipes to fifos. Also change the delay between data writes to 0.2s for both tests. This should increase the chance that the dd process will read the data chunks separately. --- tests/dd/reblock | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'tests/dd') diff --git a/tests/dd/reblock b/tests/dd/reblock index ef9e03613..7631acc19 100755 --- a/tests/dd/reblock +++ b/tests/dd/reblock @@ -24,12 +24,14 @@ fi . $srcdir/lang-default . $srcdir/test-lib.sh +# 2 short reads -> 1 full write + 1 partial write cat <<\EOF > exp-reblock || framework_failure 0+2 records in 1+1 records out 4 bytes (4 B) copied EOF +# 2 short reads -> 2 partial writes cat <<\EOF > exp-no-reblock || framework_failure 0+2 records in 0+2 records out @@ -38,16 +40,24 @@ EOF fail=0 +# Use a fifo rather than a pipe in the tests below +# so that the producer (printf subshell) will wait +# until the consumer (dd) opens the fifo therefore +# increasing the chance that dd will read the data +# from each printf separately. +mkfifo dd.fifo || framework_failure + # ensure that dd reblocks when bs= is not specified -(echo x; sleep .1; echo y) | dd ibs=3 obs=3 > out 2> err || fail=1 +dd ibs=3 obs=3 if=dd.fifo > out 2> err& +(printf 'ab'; sleep .2; printf 'cd') > dd.fifo +wait #for dd to complete sed 's/,.*//' err > k && mv k err compare err exp-reblock || fail=1 # Demonstrate that bs=N supersedes even following ibs= and obs= settings. -# Choosing a delay of 0.1 would result in an occasional lost race where -# the consumer's first read would consume 3 bytes rather than the expected 2. -# Not wanting to sleep a full second, I'll raise that to 0.3. -(printf ab; sleep .3; printf cd) | dd bs=3 ibs=1 obs=1 > out 2> err || fail=1 +dd bs=3 ibs=1 obs=1 if=dd.fifo > out 2> err& +(printf 'ab'; sleep .2; printf 'cd') > dd.fifo +wait #for dd to complete sed 's/,.*//' err > k && mv k err compare err exp-no-reblock || fail=1 -- cgit v1.2.3-70-g09d2