git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Brian Gernhardt <brian@gernhardtsoftware.com>
Cc: "git@vger.kernel.org List" <git@vger.kernel.org>,
	David Barr <david.barr@cordelta.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH jn/fast-import-blob-access] t9300: avoid short reads from dd
Date: Mon, 13 Dec 2010 00:31:51 -0600	[thread overview]
Message-ID: <20101213063151.GB20812@burratino> (raw)
In-Reply-To: <2F4185D2-5846-45CB-BC92-6BC07AE5CEC8@gernhardtsoftware.com>

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>
---
 t/t9300-fast-import.sh |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 055ddc6..ed28d3c 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1794,7 +1794,7 @@ test_expect_success PIPE 'R: copy using cat-file' '
 
 	read blob_id type size <&3 &&
 	echo "$blob_id $type $size" >response &&
-	dd of=blob bs=$size count=1 <&3 &&
+	dd of=blob bs=1 count=$size <&3 &&
 	read newline <&3 &&
 
 	cat <<EOF &&
@@ -1845,7 +1845,7 @@ test_expect_success PIPE 'R: print blob mid-commit' '
 		EOF
 
 		read blob_id type size <&3 &&
-		dd of=actual bs=$size count=1 <&3 &&
+		dd of=actual bs=1 count=$size <&3 &&
 		read newline <&3 &&
 
 		echo
@@ -1880,7 +1880,7 @@ test_expect_success PIPE 'R: print staged blob within commit' '
 		echo "cat-blob $to_get" &&
 
 		read blob_id type size <&3 &&
-		dd of=actual bs=$size count=1 <&3 &&
+		dd of=actual bs=1 count=$size <&3 &&
 		read newline <&3 &&
 
 		echo deleteall
-- 
1.7.2.4

  reply	other threads:[~2010-12-13  6:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-12 20:49 SIGPIPE in t9300-fast-import Brian Gernhardt
2010-12-12 21:49 ` Jonathan Nieder
2010-12-12 22:04   ` Brian Gernhardt
2010-12-13  6:31     ` Jonathan Nieder [this message]
2010-12-13  7:21       ` [PATCH jn/fast-import-blob-access] t9300: avoid short reads from dd Junio C Hamano
2010-12-13  9:28         ` [PATCH jn/fast-import-blob-access] t9300: use perl "head -c" clone in place of "dd bs=1 count=16000" kluge Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101213063151.GB20812@burratino \
    --to=jrnieder@gmail.com \
    --cc=brian@gernhardtsoftware.com \
    --cc=david.barr@cordelta.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).