diff options
author | Pádraig Brady <P@draigBrady.com> | 2008-12-01 01:08:02 +0000 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2008-12-01 01:20:18 +0000 |
commit | e34894bf3f52f1600e5a334ddeec9c2a7e431853 (patch) | |
tree | 375ce7867cb3936ac5b821b78bbf011357683190 /tests/dd | |
parent | b14e5c40b9e7f6140a800a0b69eec693ea73fd09 (diff) | |
download | coreutils-e34894bf3f52f1600e5a334ddeec9c2a7e431853.tar.xz |
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.
Diffstat (limited to 'tests/dd')
-rwxr-xr-x | tests/dd/reblock | 20 |
1 files changed, 15 insertions, 5 deletions
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 |