From: Marius Gavrilescu Date: Sat, 13 Jan 2018 19:52:56 +0000 (+0200) Subject: Add debugging output X-Git-Tag: 0.002_001~1 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=c4911b1f4d6c1e4b2a3c7f5a71a538b459bbe322;p=slob.git Add debugging output --- diff --git a/lib/Slob.pm b/lib/Slob.pm index 33516bd..9d78249 100644 --- a/lib/Slob.pm +++ b/lib/Slob.pm @@ -14,6 +14,9 @@ use Compress::Raw::Bzip2; use Compress::Raw::Lzma; use Compress::Raw::Zlib; +# MD5 only used for debugging output in tests +use Digest::MD5 qw/md5_hex/; + our %UNCOMPRESS = ( '' => sub { $_[0] }, 'lzma2' => sub { @@ -156,8 +159,14 @@ sub ftell { } sub uncompress { - my ($self, $data) = @_; - $UNCOMPRESS{$self->{header}{compression}}->($data) + my ($self, $data) = @_; + my $compression = $self->{header}{compression}; + if ($ENV{HARNESS_ACTIVE} && $compression eq 'lzma2') { + my $prefix = unpack 'H*', substr $data, 0, 10; + my $md5sum = md5_hex $data; + Test::More::diag "Uncompressing data starting '$prefix', md5sum $md5sum"; + } + $UNCOMPRESS{$compression}->($data) } sub read_header {