Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Archive-Zip CPAN distribution.

Report information
The Basics
Id:
25925
Status:
resolved
Worked:
3 hours (180 minutes)
Users:
SHLOMIF: 3 hours (180 minutes)
Priority:
Low/Low
Queue:

People
Owner:
SHLOMIF [...] cpan.org
Requestors:
perl [...] evancarroll.com
Cc:
AdminCc:



Subject: Failed test
failed test please advise Archive::Zip fails to extract and create zip.
Subject: error.jpg
Subject: unzip.pl
#!/usr/bin/perl -l use strict; use warnings; use Archive::Zip qw( :ERROR_CODES ); use Digest::MD5; use Test::More tests => 5; use Carp; use constant ERROR_PRONE_FILE => 'error.jpg'; use constant ERROR_FILE => 'corrupterror.jpg'; use constant ERROR_ARCHIVE => 'out.zip'; my $zip = Archive::Zip->new(); my $md5 = Digest::MD5->new; my ( $before, $after ); ## ## OPEN GOOD FILE GET MD5 ## { open ( my $fh, '<', ERROR_PRONE_FILE ) or die 'Can not open file' ; $before = $md5->addfile( $fh )->md5_hex; close $fh; } ## ## Zip up and write out ## { $zip->addFile( ERROR_PRONE_FILE ); $zip->extractMember( ERROR_PRONE_FILE, ERROR_FILE ); open ( my $fh, '<', ERROR_FILE ) or die 'Can not open file' ; $after = $md5->addfile( $fh )->md5_hex; close $fh; unlink ERROR_FILE; cmp_ok( $after, 'eq', $before , 'Failed test, pre-zip, and post-pre-zip do not match' ); my $status = $zip->writeToFileNamed( ERROR_ARCHIVE ); cmp_ok( $status, '==', AZ_OK, 'Wrote zip out alright' ); } ## ## Read back ## { my $zip2; eval { $zip2 = Archive::Zip->new( ERROR_ARCHIVE ); }; ok( !$@, "This stupid bugger crashed again, error:\n$@" ); ok ( defined $zip2, 'Perl failed at spawning the object of doom' ); $zip2->extractMember( ERROR_FILE ); open ( my $fh, '<', ERROR_FILE ) or croak 'Can not open file' ; $after = $md5->addfile( $fh )->md5_hex; close $fh; unlink ERROR_FILE; unlink ERROR_ARCHIVE; cmp_ok( $after, 'eq', $before , 'Failed test, pre-zip, and post-zip do not match' ); } print "Success sums match up all th way through!! Congrats"; print "Verbose: [ $before eq $after ]"; 1;
use this test instead the other one had some typos in it, this test is successful the bug is in Archive::Zip not being $\ safe. This is a good round robin test though for creation and extraction of a zip using md5s for checking results.
#!/usr/bin/perl use strict; use warnings; use Archive::Zip qw( :ERROR_CODES ); use Digest::MD5; use Test::More tests => 5; use Carp; use constant ERROR_PRONE_FILE => 'error.jpg'; use constant ERROR_FILE => 'corrupterror.jpg'; use constant ERROR_ARCHIVE => 'out.zip'; my $zip = Archive::Zip->new(); my ( $before, $after ); ## ## OPEN GOOD FILE GET MD5 ## { my $md5 = Digest::MD5->new; open ( my $fh, '<', ERROR_PRONE_FILE ) or die 'Can not open file' ; binmode( $fh ); $before = $md5->addfile( $fh )->md5_hex; close $fh; } ## ## ZIP UP AND WRITE OUT ## { my $md5 = Digest::MD5->new; $zip->addFile( ERROR_PRONE_FILE ); $zip->extractMember( ERROR_PRONE_FILE, ERROR_FILE ); open ( my $fh, '<', ERROR_FILE ) or die 'Can not open file' ; binmode( $fh ); $after = $md5->addfile( $fh )->md5_hex; close $fh; unlink ERROR_FILE; cmp_ok( $after, 'eq', $before , 'Failed test, pre-zip, and post-pre-zip do not match' ); my $status = $zip->writeToFileNamed( ERROR_ARCHIVE ); cmp_ok( $status, '==', AZ_OK, 'Wrote zip out alright' ); } ## ## READ BACK ## { my $md5 = Digest::MD5->new; my $zip2; eval { $zip2 = Archive::Zip->new( ERROR_ARCHIVE ); }; ok( !$@, "This stupid bugger crashed again, error:\n$@" ); ok ( defined $zip2, 'Perl failed at spawning the object of doom' ); $zip2->extractMember( ERROR_PRONE_FILE, ERROR_FILE ); open ( my $fh, '<', ERROR_FILE ) or croak 'Can not open file' ; binmode( $fh ); $after = $md5->addfile( $fh )->md5_hex; close $fh; unlink ERROR_FILE; unlink ERROR_ARCHIVE; cmp_ok( $after, 'eq', $before , 'Failed test, pre-zip, and post-zip do not match' ); } print "Success sums match up all th way through!! Congrats"; print "Verbose: [ $before eq $after ]"; 1;
This is a last update of the round-robin test of creating a zip and testing the result of it, this could use /dev/urandom to create the content prior to the zip, but I'm not sure how well that would port to ActiveState.
#!/usr/bin/perl use strict; use warnings; use Archive::Zip qw( :ERROR_CODES ); use Digest::MD5; use Test::More tests => 5; use Carp; use constant ERROR_PRONE_FILE => 'error.jpg'; use constant ERROR_FILE => 'corrupterror.jpg'; use constant ERROR_ARCHIVE => 'out.zip'; my $zip = Archive::Zip->new(); my ( $before, $after ); ## ## OPEN GOOD FILE GET MD5 ## { my $md5 = Digest::MD5->new; open ( my $fh, '<', ERROR_PRONE_FILE ) or die 'Can not open file' ; binmode( $fh ); $before = $md5->addfile( $fh )->hexdigest; close $fh; } ## ## ZIP UP AND WRITE OUT ## { my $md5 = Digest::MD5->new; $zip->addFile( ERROR_PRONE_FILE ); $zip->extractMember( ERROR_PRONE_FILE, ERROR_FILE ); open ( my $fh, '<', ERROR_FILE ) or die 'Can not open file' ; binmode( $fh ); $after = $md5->addfile( $fh )->hexdigest; close $fh; unlink ERROR_FILE; cmp_ok( $after, 'eq', $before , 'Failed test, pre-zip, and post-pre-zip do not match' ); my $status = $zip->writeToFileNamed( ERROR_ARCHIVE ); cmp_ok( $status, '==', AZ_OK, 'Wrote zip out alright' ); } ## ## READ BACK ## { my $md5 = Digest::MD5->new; my $zip2; eval { $zip2 = Archive::Zip->new( ERROR_ARCHIVE ); }; ok( !$@, "This stupid bugger crashed again, error:\n$@" ); ok ( defined $zip2, 'Perl failed at spawning the object of doom' ); $zip2->extractMember( ERROR_PRONE_FILE, ERROR_FILE ); open ( my $fh, '<', ERROR_FILE ) or croak 'Can not open file' ; binmode( $fh ); $after = $md5->addfile( $fh )->hexdigest; close $fh; unlink ERROR_FILE; unlink ERROR_ARCHIVE; cmp_ok( $after, 'eq', $before , 'Failed test, pre-zip, and post-zip do not match' ); } print "Success sums match up all th way through!! Congrats"; print "Verbose: [ $before eq $after ]"; 1;
From: SHLOMIF@cpan.org
Hi ECARROL! On Fri Mar 30 11:57:27 2007, ECARROLL wrote:
Show quoted text
> This is a last update of the round-robin test of creating a zip and > testing the result of it, this could use /dev/urandom to create the > content prior to the zip, but I'm not sure how well that would port
to
Show quoted text
> ActiveState.
I'm sorry, but I get all-OKs with the script on the following configurations: 1. Mandriva Cooker with Archive-Zip 1.20. 2. Mandriva Cooker with Archive-Zip 1.18. 3. Mandriva Cooker with Archive-Zip trunk. 4. WinXP with ActivePerl and built-in Archive-Zip. 5. WinXP with ActivePerl and Archive-Zip 1.18. Can you still reproduce this problem? In any case, the test file needs some work if it is to be included in the distribution. I'd like to: 1. Get rid of the dependency on Digest::MD5. 2. Add Test::Count "# TEST" lines to the file. 3. Remove "Failed" strings from the beginning of tests. 4. Change the ERROR constants to something more neutral.
I talked with ECARROLL on IRC now, and as he told me, the problem is that the tests fail if one specifies the "-l" flag to perl. I checked and was able to reproduce the problem with Archive-Zip trunk.
Fixed in Subversion trunk: {{{{{{{{{{{{{{{{{ - Fixed http://rt.cpan.org/Public/Bug/Display.html?id=25925 : - Archive-Zip wrote faulty .zip files when $\ was set (such as when running using perl -l). - Incorporated a heavily modified version of ECARROLL's test file. - Thanks for ECARROLL for reporting it, and helping with the investigation. - The fix was to convert all $fh->print(@data) to $self->_print($fh, @data) where the _print() method localizes $\ to undef. }}}}}}}}}}}}}}}}} Thanks again! Regards, Shlomi Fish


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.