@matheusbsbs / matheus-bagliano / commits / a3a6f4c4cd
Fork 0

t9300: avoid short reads from dd

dd is a thin wrapper around read(2). As open group Issue 7 explains: It shall read the input one block at a time, using the specified input block size; it shall then process the block of data actually returned, which could be smaller than the requested block size. Any short read --- for example from a pipe whose capacity cannot fill a block --- results in that block being truncated. As a result, the first cat-blob test (9300.114) fails on Mac OS X, where the pipe capacity is around 8 KiB. Fix the test by using a block size of 1. Each read will block until the next byte of input is available. It would be even nicer to use head -c which expresses the intention more clearly. Alas, IRIX "head" does not support the -c option. Reported-by: Brian Gernhardt <brian@gernhardtsoftware.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Dec 13, 2010 at 00:31 UTC a3a6f4c4cdc42a4d432bc51915d3e1d092d8ca9a
1 file changed +3 -3
t/t9300-fast-import.sh
+3 -3
@@ -1794,7 +1794,7 @@ test_expect_success PIPE 'R: copy using cat-file' '
1794
1795 read blob_id type size <&3 &&
1796 echo "$blob_id $type $size" >response &&
1797 - dd of=blob bs=$size count=1 <&3 &&
1797 + dd of=blob bs=1 count=$size <&3 &&
1798 read newline <&3 &&
1799
1800 cat <<EOF &&
@@ -1845,7 +1845,7 @@ test_expect_success PIPE 'R: print blob mid-commit' '
1845 EOF
1846
1847 read blob_id type size <&3 &&
1848 - dd of=actual bs=$size count=1 <&3 &&
1848 + dd of=actual bs=1 count=$size <&3 &&
1849 read newline <&3 &&
1850
1851 echo
@@ -1880,7 +1880,7 @@ test_expect_success PIPE 'R: print staged blob within commit' '
1880 echo "cat-blob $to_get" &&
1881
1882 read blob_id type size <&3 &&
1883 - dd of=actual bs=$size count=1 <&3 &&
1883 + dd of=actual bs=1 count=$size <&3 &&
1884 read newline <&3 &&
1885
1886 echo deleteall