Package: libdr-tarantool-perl
Version: 0.42-1
Severity: important
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch trusty

t/010-xs.t is unreliable (at least on i386) and randomly segfaults on
the Ubuntu build daemons.  On investigation, this is because the last
block of tests construct packets containing random data after the
header, but this includes things like length fields, causing the parser
to sometimes jump off into space.  It would be sufficient for the
purposes of this test to construct packets with generally-valid formats
and only fill random data into fields that are actually allowed to
contain arbitrary data.  Would something like this patch be acceptable?

  * Fix packet parsing tests to construct valid packets.

diff -Nru libdr-tarantool-perl-0.42/debian/patches/fix-pkt-parse-tests.patch 
libdr-tarantool-perl-0.42/debian/patches/fix-pkt-parse-tests.patch
--- libdr-tarantool-perl-0.42/debian/patches/fix-pkt-parse-tests.patch  
1970-01-01 01:00:00.000000000 +0100
+++ libdr-tarantool-perl-0.42/debian/patches/fix-pkt-parse-tests.patch  
2013-10-24 09:35:13.000000000 +0100
@@ -0,0 +1,90 @@
+Description: Fix packet parsing tests to construct valid packets
+Author: Colin Watson <cjwat...@ubuntu.com>
+Forwarded: no
+Last-Update: 2013-10-24
+
+Index: b/t/010-xs.t
+===================================================================
+--- a/t/010-xs.t
++++ b/t/010-xs.t
+@@ -202,38 +202,71 @@
+ 
+ SKIP: {
+ #     skip 'Devel tests $ENV{DEVEL_TEST}=0', 120 unless $ENV{DEVEL_TEST};
++
++# Pack an integer into an <int32_varint>, per the Tarantool binary protocol.
++sub pack_varint {
++    my $num = shift;
++    my $out = pack 'C', ($num & 0x7f);
++    $num >>= 7;
++    while ($num) {
++        $out .= pack 'C', (($num & 0x7f) | 0x80);
++        $num >>= 7;
++    }
++    return scalar reverse $out;
++}
++
++# Pack arbitrary data into a trivial <fq_tuple>, per the Tarantool binary
++# protocol.
++sub pack_fq_tuple {
++    my $body = shift;
++    my $len = length $body;
++    # <fq_tuple> ::= <size><tuple>
++    # <tuple> ::= <cardinality><field>+
++    # <field> ::= <int32_varint><data>
++    my $len_varint = pack_varint($len);
++    return pack 'LLa*a*',
++        4 * length($len_varint) + $len,
++        1,
++        $len_varint,
++        $body
++    ;
++}
++
+ for (1 .. 30) {
+     my $body = join '', map { chr int rand 256 } 1 .. (300 + int rand 300);
+     my $pkt =
+-        pack 'LLLLa*',
++        pack 'LLLLLa*',
+             TNT_SELECT,
+-            length $body,
++            8 + length $body,
+             int rand 500,
+             0,
+-            $body
++            1,
++            pack_fq_tuple($body)
+         ;
+     $res = DR::Tarantool::_pkt_parse_response( $pkt );
+     diag explain $res unless
+     is $res->{status}, 'buffer', "Broken package $_";
+     $pkt =
+-        pack 'LLLLa*',
++        pack 'LLLLLa*',
+             TNT_SELECT,
+-            10 + length $body,
++            8 + 10 + length $body,
+             int rand 500,
+             0,
+-            $body
++            1,
++            pack_fq_tuple($body)
+         ;
+     $res = DR::Tarantool::_pkt_parse_response( $pkt );
+     diag explain $res unless
+     is $res->{status}, 'buffer', "Broken package $_, too long body";
+     
+     $pkt =
+-        pack 'LLLLa*',
++        pack 'LLLLLa*',
+             TNT_SELECT,
+-            -10 + length $body,
++            8 - 10 + length $body,
+             int rand 500,
+             0,
+-            $body
++            1,
++            pack_fq_tuple($body)
+         ;
+     $res = DR::Tarantool::_pkt_parse_response( $pkt );
+     diag explain $res unless
diff -Nru libdr-tarantool-perl-0.42/debian/patches/series 
libdr-tarantool-perl-0.42/debian/patches/series
--- libdr-tarantool-perl-0.42/debian/patches/series     1970-01-01 
01:00:00.000000000 +0100
+++ libdr-tarantool-perl-0.42/debian/patches/series     2013-10-24 
00:22:26.000000000 +0100
@@ -0,0 +1 @@
+fix-pkt-parse-tests.patch

Thanks,

-- 
Colin Watson                                       [cjwat...@ubuntu.com]


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to