1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-04-19 10:15:48 +02:00

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.
This commit is contained in:
Pádraig Brady
2008-12-01 01:08:02 +00:00
parent b14e5c40b9
commit e34894bf3f

View File

@@ -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