summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDustin Sallings <dustin@spy.net>2012-01-25 22:13:11 -0800
committerDustin Sallings <dustin@spy.net>2012-01-25 22:13:11 -0800
commit85db132d127a42ccc2bcdef447813fa8895307ae (patch)
tree07ab1e23cebb8d0c82b2fb74f036a088cfb96d5b
parent97354c326c931ca535e681e8fe3fcd53ff1b4927 (diff)
downloadmemcached-85db132d127a42ccc2bcdef447813fa8895307ae.tar.gz
tests: loop on short binary packet reads
Awesome bug goes like this: let "c1" be the commit of the "good state" and "c2" be the commit immediately after (in a bad state). "t1" is the state of the tree in "c1" and "t2" is the state of the tree in "c2" In their natural states, we have this: c1 -> t1 -> success c1 -> t2 -> fail However, if you take c1 -> t1 -> patch to t2 -> success c2 -> t2 -> patch to t1 -> fail So t1 *and* t2 both succeed if the committed tree is c1, but both fail of the committed tree is c2. The difference? c1 has a tag that points to it so the version number is "1.2.10" whereas the version number for the unreleased c2 is "1.4.10-1-gee486ab" -- a bit longer, breaks stuff in tests that try to print stats.
-rwxr-xr-xt/binary.t10
1 files changed, 7 insertions, 3 deletions
diff --git a/t/binary.t b/t/binary.t
index adc30c0..504ddef 100755
--- a/t/binary.t
+++ b/t/binary.t
@@ -573,11 +573,15 @@ sub _handle_single_response {
my $self = shift;
my $myopaque = shift;
- $self->{socket}->recv(my $response, ::MIN_RECV_BYTES);
- Test::More::is(length($response), ::MIN_RECV_BYTES, "Expected read length");
+ my $hdr = "";
+ while(::MIN_RECV_BYTES - length($hdr) > 0) {
+ $self->{socket}->recv(my $response, ::MIN_RECV_BYTES - length($hdr));
+ $hdr .= $response;
+ }
+ Test::More::is(length($hdr), ::MIN_RECV_BYTES, "Expected read length");
my ($magic, $cmd, $keylen, $extralen, $datatype, $status, $remaining,
- $opaque, $ident_hi, $ident_lo) = unpack(::RES_PKT_FMT, $response);
+ $opaque, $ident_hi, $ident_lo) = unpack(::RES_PKT_FMT, $hdr);
Test::More::is($magic, ::RES_MAGIC, "Got proper response magic");
my $cas = ($ident_hi * 2 ** 32) + $ident_lo;