Subject: | memBzip and memBunzip do not generate/read valid bzip2 files |
memBzip adds and memBunzip expects to find 5 bytes of some data at the
beginning of their buffers which is not valid bzip as far as I can tell.
Bzip2 files/streams should start with BZh; I don't know what the 5 bytes
added/expexcted by memBzip/memBunzip before that are there for, but they
seem to make them incompatible with standard formatted bzip2
streams/files and other bzip2 tools.
Patch to test suite attached that starts adding a bit of these tests,
and causes it to currently fail.
This is on Fedora 10 x86_64, perl v5.10.0, system bzip2 1.0.5
Subject: | Compress-Bzip2-mem.patch |
diff -up Compress-Bzip2-2.09/t/040-memory.t~ Compress-Bzip2-2.09/t/040-memory.t
--- Compress-Bzip2-2.09/t/040-memory.t~ 2005-04-21 19:57:48.000000000 +0300
+++ Compress-Bzip2-2.09/t/040-memory.t 2009-07-23 23:35:29.000000000 +0300
@@ -1,6 +1,6 @@
# -*- mode: perl -*-
-use Test::More tests => 10;
+use Test::More tests => 12;
#use Test::More qw(no_plan);
BEGIN {
@@ -18,6 +18,8 @@ and the Momewrathes outgrabe
my $compress = memBzip( $string );
my $uncompress = memBunzip( $compress );
+ok( $compress =~ /^BZh/, "compressed starts with bzip magic header" );
+
ok( $compress ne $string, "string was not inouted" );
ok( length($compress)-10 < length($string), "string compression - ".length($compress).' vs '.length($string) );
ok( $uncompress eq $string, "uncompressed is same as the original" );
@@ -36,3 +38,16 @@ $uncompress = decompress( $compress );
ok( $compress ne $string, "bzip1 string was not inouted" );
ok( length($compress)-10 < length($string), "bzip1 string compression - ".length($compress).' vs '.length($string) );
ok( $uncompress eq $string, "bzip1 decompress is same as the original" );
+
+do 't/lib.pl';
+
+my $sample0;
+my $INFILE = catfile( qw(bzlib-src sample0.bz2) );
+local $/ = undef;
+open( IN, "< $INFILE" ) or die "$INFILE: $!";
+binmode IN;
+$sample0 = <IN>;
+close( IN );
+
+$uncompress = memBunzip( "$sample0" ); # copy
+ok( $uncompress, "sample0 uncompressed" );