Subject: Re: bug#8074: Fix sparse-pipe test on 2.6.26 kernel

From: Pádraig Brady <[email-masked]>
Date: Fri, 18 Feb 2011 10:54:36 +0000

On 18/02/11 08:48, Gilles Espinasse wrote:
> I compile the same code on different machines and
> that's made in a chroot a la LFS. With sparse-fiemap-test.patch, all tests
> are ok on three machines but randomly fail on the fourth (all x86 32-bits).
> The only difference at this stage between the different machines should be
> the running kernel (same glibc-2.11.3 is compiled before coreutils).
> This work on ubuntu 2.6.32-26-generic, 2.6.27.57 vanilia kernel, Centos-5.5
> 2.6.18-194.32.1.el5 but fail in debian v5 2.6.26-2-686
> 
> Tested as root with
> for i in {1..20}; do make -s check -C tests TESTS=cp/sparse-to-pipe
> 2>/dev/null;done | grep '1 test'
> show this result on the debian machine
> 1 of 1 test failed
> 1 of 1 test failed
> 1 test passed
> 1 test passed
> 1 of 1 test failed
> 1 of 1 test failed
> 1 of 1 test failed
> 1 of 1 test failed
> 1 test passed
> 1 test passed
> 1 of 1 test failed
> 1 test passed
> 1 test passed
> 1 of 1 test failed
> 1 of 1 test failed
> 1 of 1 test failed
> 1 test passed
> 1 test passed
> 1 of 1 test failed
> 1 of 1 test failed
> 
> FS is ext3
> failure is
> + require_sparse_support_
> + test 0 = 0
> + t=sparse.17085
> + dd bs=1 seek=128K of=sparse.17085
> ++ du -sk sparse.17085
> + set x 0 sparse.17085
> + kb_size=0
> + rm -f sparse.17085
> + test 0 -ge 128
> + mkfifo_or_skip_ pipe
> + test 1 = 1
> + mkfifo pipe
> + timeout 10 cat pipe
> + truncate -s1M sparse
> + cp sparse pipe
> + cmp sparse copy
> cmp: EOF on copy
> + fail=1
> + Exit 1
> 
> The fun is that if I try to strace the cmp, this change the cmp test to
> reliabily work
> 
> If I add a dd if=/dev/null of=pipe conv=notrunc,fdatasync, test reliabily
> work too.
> So I added that in attached patch.

Good testing!
Interesting to see that fdatasync flushes the pipe to disk.
However it might be more portable/robust to use `wait`
rather than that dd command?

cheers,
Pádraig.