diff options
author | 2021-03-01 23:14:32 +0000 | |
---|---|---|
committer | 2021-03-01 23:14:32 +0000 | |
commit | de8cc8edbc71bd3e3bc7fbffa27ba0e564c37d8b (patch) | |
tree | 5e91ea1711126841ef19ee1ee17705e29dc6baf0 /gnu/usr.bin/perl/cpan/IO-Compress/t | |
parent | Update the MSI addresses for the Armada 8040. This chunk will only be (diff) | |
download | wireguard-openbsd-de8cc8edbc71bd3e3bc7fbffa27ba0e564c37d8b.tar.xz wireguard-openbsd-de8cc8edbc71bd3e3bc7fbffa27ba0e564c37d8b.zip |
Import perl-5.32.1
OK sthen@
Diffstat (limited to 'gnu/usr.bin/perl/cpan/IO-Compress/t')
-rwxr-xr-x | gnu/usr.bin/perl/cpan/IO-Compress/t/006zip.t | 44 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/IO-Compress/t/011-streamzip.t | 118 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/IO-Compress/t/050interop-gzip.t | 4 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/IO-Compress/t/105oneshot-zip-only.t | 51 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/IO-Compress/t/107multi-zip-only.t | 102 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/IO-Compress/t/112utf8-zip.t | 220 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/IO-Compress/t/compress/multi.pl | 3 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/cpan/IO-Compress/t/cz-14gzopen.t | 2 | ||||
-rw-r--r-- | gnu/usr.bin/perl/cpan/IO-Compress/t/files/bad-efs.zip | bin | 0 -> 126 bytes | |||
-rw-r--r-- | gnu/usr.bin/perl/cpan/IO-Compress/t/files/encrypt-aes.zip | bin | 0 -> 9007 bytes | |||
-rw-r--r-- | gnu/usr.bin/perl/cpan/IO-Compress/t/files/encrypt-standard.zip | bin | 0 -> 207 bytes | |||
-rw-r--r-- | gnu/usr.bin/perl/cpan/IO-Compress/t/files/jar.zip | bin | 0 -> 434 bytes |
12 files changed, 538 insertions, 6 deletions
diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/006zip.t b/gnu/usr.bin/perl/cpan/IO-Compress/t/006zip.t index 33afa8e7236..cfc53d79ab2 100755 --- a/gnu/usr.bin/perl/cpan/IO-Compress/t/006zip.t +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/006zip.t @@ -19,7 +19,7 @@ BEGIN { $extra = 1 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - plan tests => 101 + $extra ; + plan tests => 108 + $extra ; use_ok('IO::Compress::Zip', qw(:all)) ; use_ok('IO::Uncompress::Unzip', qw(unzip $UnzipError)) ; @@ -360,3 +360,45 @@ for my $method (ZIP_CM_DEFLATE, ZIP_CM_STORE, ZIP_CM_BZIP2) is $u->getHeaderInfo()->{Name}, "0", "Name is '0'"; } + +{ + title "nexStream regression"; + # https://github.com/pmqs/IO-Compress/issues/3 + + my $lex = new LexFile my $file1; + + my $content1 = qq["organisation_path","collection_occasion_key","episode_key"\n] ; + + my $zip = new IO::Compress::Zip $file1, + Name => "one"; + isa_ok $zip, "IO::Compress::Zip"; + + print $zip $content1; + + $zip->newStream(Name=> "two"); + + my $content2 = <<EOM; +"key","value" +"version","2" +"type","PMHC" +EOM + print $zip $content2; + + ok $zip->close(), "closed"; + + + my $u = new IO::Uncompress::Unzip $file1, Append => 1, @_ + or die "Cannot open $file1: $UnzipError"; + + isa_ok $u, "IO::Uncompress::Unzip"; + + my $name = $u->getHeaderInfo()->{Name}; + + is $u->getHeaderInfo()->{Name}, "one", "Name is 'one'"; + + ok $u->nextStream(), "nextStream OK"; + + my $line = <$u>; + + is $line, qq["key","value"\n], "got line 1 from second member"; +}
\ No newline at end of file diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/011-streamzip.t b/gnu/usr.bin/perl/cpan/IO-Compress/t/011-streamzip.t new file mode 100644 index 00000000000..df3fbfb0fd8 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/011-streamzip.t @@ -0,0 +1,118 @@ +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = ("../lib", "lib/compress"); + } +} + +use lib qw(t t/compress); + +use strict; +use warnings; +use bytes; + +use Test::More ; +use CompTestUtils; +use IO::Uncompress::Unzip 'unzip' ; + +BEGIN +{ + plan(skip_all => "Needs Perl 5.005 or better - you have Perl $]" ) + if $] < 5.005 ; + + # use Test::NoWarnings, if available + my $extra = 0 ; + $extra = 1 + if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; + + plan tests => 8 + $extra ; +} + + +my $Inc = join " ", map qq["-I$_"] => @INC; +$Inc = '"-MExtUtils::testlib"' + if ! $ENV{PERL_CORE} && eval " require ExtUtils::testlib; " ; + +my $Perl = ($ENV{'FULLPERL'} or $^X or 'perl') ; +$Perl = qq["$Perl"] if $^O eq 'MSWin32' ; + +$Perl = "$Perl $Inc -w" ; +#$Perl .= " -Mblib " ; +my $binDir = $ENV{PERL_CORE} ? "../ext/IO-Compress/bin/" + : "./bin/"; + +my $hello1 = <<EOM ; +hello +this is +a test +message +x ttttt +xuuuuuu +the end +EOM + + + + +my $lex = new LexFile my $stderr ; + + +sub check +{ + my $command = shift ; + my $expected = shift ; + + my $lex = new LexFile my $stderr ; + + my $cmd = "$command 2>$stderr"; + my $stdout = `$cmd` ; + + my $aok = 1 ; + + $aok &= is $?, 0, " exit status is 0" ; + + $aok &= is readFile($stderr), '', " no stderr" ; + + $aok &= is $stdout, $expected, " expected content is ok" + if defined $expected ; + + if (! $aok) { + diag "Command line: $cmd"; + my ($file, $line) = (caller)[1,2]; + diag "Test called from $file, line $line"; + } + + 1 while unlink $stderr; +} + + +# streamzip +# ######## + +{ + title "streamzip" ; + + my ($infile, $outfile); + my $lex = new LexFile $infile, $outfile ; + + writeFile($infile, $hello1) ; + check "$Perl ${binDir}/streamzip <$infile >$outfile"; + + my $uncompressed ; + unzip $outfile => \$uncompressed; + is $uncompressed, $hello1; +} + +{ + title "streamzip" ; + + my ($infile, $outfile); + my $lex = new LexFile $infile, $outfile ; + + writeFile($infile, $hello1) ; + check "$Perl ${binDir}/streamzip -zipfile=$outfile <$infile"; + + my $uncompressed ; + unzip $outfile => \$uncompressed; + is $uncompressed, $hello1; +} diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/050interop-gzip.t b/gnu/usr.bin/perl/cpan/IO-Compress/t/050interop-gzip.t index f3cb1a39119..ae019c87acf 100755 --- a/gnu/usr.bin/perl/cpan/IO-Compress/t/050interop-gzip.t +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/050interop-gzip.t @@ -56,7 +56,7 @@ sub readWithGzip return 1 } - diag "'$comp' failed: $?"; + diag "'$comp' failed: \$?=$? \$!=$!"; return 0 ; } @@ -80,7 +80,7 @@ sub writeWithGzip return 1 if system($comp) == 0 ; - diag "'$comp' failed: $?"; + diag "'$comp' failed: \$?=$? \$!=$!"; return 0 ; } diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/105oneshot-zip-only.t b/gnu/usr.bin/perl/cpan/IO-Compress/t/105oneshot-zip-only.t index 94676eb5dd6..7611da3774e 100755 --- a/gnu/usr.bin/perl/cpan/IO-Compress/t/105oneshot-zip-only.t +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/105oneshot-zip-only.t @@ -24,7 +24,7 @@ BEGIN { $extra = 1 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - plan tests => 219 + $extra ; + plan tests => 227 + $extra ; #use_ok('IO::Compress::Zip', qw(zip $ZipError :zip_method)) ; use_ok('IO::Compress::Zip', qw(:all)) ; @@ -162,6 +162,55 @@ sub zipGetHeader is $hdr->{Name}, File::Spec->catfile("", "fred", "jim"), " Name is '/fred/jim'" ; } +{ + title "Detect encrypted zip file"; + + my $files = "./t/" ; + $files = "./" if $ENV{PERL_CORE} ; + $files .= "files/"; + + my $zipfile = "$files/encrypt-standard.zip" ; + my $output; + + ok ! unzip "$files/encrypt-standard.zip" => \$output ; + like $UnzipError, qr/Encrypted content not supported/ ; + + ok ! unzip "$files/encrypt-aes.zip" => \$output ; + like $UnzipError, qr/Encrypted content not supported/ ; +} + +{ + title "jar file with deflated directory"; + + # Create Jar as follow + # echo test > file && jar c file > jar.zip + + # Note the deflated directory META-INF with length 0 & size 2 + # + # $ unzip -vl t/files/jar.zip + # Archive: t/files/jar.zip + # Length Method Size Cmpr Date Time CRC-32 Name + # -------- ------ ------- ---- ---------- ----- -------- ---- + # 0 Defl:N 2 0% 2019-09-07 22:35 00000000 META-INF/ + # 54 Defl:N 53 2% 2019-09-07 22:35 934e49ff META-INF/MANIFEST.MF + # 5 Defl:N 7 -40% 2019-09-07 22:35 3bb935c6 file + # -------- ------- --- ------- + # 59 62 -5% 3 files + + + my $files = "./t/" ; + $files = "./" if $ENV{PERL_CORE} ; + $files .= "files/"; + + my $zipfile = "$files/jar.zip" ; + my $output; + + ok unzip $zipfile => \$output ; + + is $output, "" ; + +} + for my $stream (0, 1) { for my $zip64 (0, 1) diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/107multi-zip-only.t b/gnu/usr.bin/perl/cpan/IO-Compress/t/107multi-zip-only.t new file mode 100644 index 00000000000..40c7fef5e2a --- /dev/null +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/107multi-zip-only.t @@ -0,0 +1,102 @@ + +use strict; +use warnings; + +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = ("../lib", "lib/compress"); + } +} + +use lib qw(t t/compress); + + +use Test::More ; +use CompTestUtils; + +BEGIN { + # use Test::NoWarnings, if available + my $extra = 0 ; + $extra = 1 + if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; + + plan tests => 21 + $extra ; + + use_ok('IO::Compress::Zip', qw(zip $ZipError)) ; + + use_ok('IO::Uncompress::Unzip', qw($UnzipError)) ; + use_ok('IO::Uncompress::AnyUncompress', qw($AnyUncompressError)) ; + +} + + my @buffers ; + push @buffers, <<EOM ; +hello world +this is a test +some more stuff on this line +ad finally... +EOM + + push @buffers, <<EOM ; +some more stuff +line 2 +EOM + + push @buffers, <<EOM ; +even more stuff +EOM + + +my $name = "n1"; +my $lex = new LexFile my $zipfile ; + +my $x = new IO::Compress::Zip($zipfile, Name => $name++, AutoClose => 1); +isa_ok $x, 'IO::Compress::Zip', ' $x' ; + + +foreach my $buffer (@buffers) { + ok $x->write($buffer), " Write OK" ; + # this will add an extra "empty" stream + ok $x->newStream(Name => $name ++), " newStream OK" ; +} +ok $x->close, " Close ok" ; + +push @buffers, undef; + +{ + open F, ">>$zipfile"; + print F "trailing"; + close F; +} + +my $u = new IO::Uncompress::Unzip $zipfile, Transparent => 1, MultiStream => 0 + or die "Cannot open $zipfile: $UnzipError"; + +my @names ; +my $status; +my $expname = "n1"; +my $ix = 0; + +for my $ix (1 .. 4) +{ + local $/ ; + + my $n = $u->getHeaderInfo()->{Name}; + is $n, $expname , "name is $expname"; + is <$u>, $buffers[$ix-1], "payload ok"; + ++ $expname; + + $status = $u->nextStream() +} + +{ + local $/ ; + + my $n = $u->getHeaderInfo()->{Name}; + is $n, undef , "name is undef"; + is <$u>, "trailing", "payload ok"; +} + +die "Error processing $zipfile: $!\n" + if $status < 0 ;
\ No newline at end of file diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/112utf8-zip.t b/gnu/usr.bin/perl/cpan/IO-Compress/t/112utf8-zip.t new file mode 100644 index 00000000000..f90a3cb7d61 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/112utf8-zip.t @@ -0,0 +1,220 @@ +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = ("../lib", "lib/compress"); + } +} + +use lib qw(t t/compress); +use strict; +use warnings; +use bytes; + +use Test::More ; +use CompTestUtils; +use Data::Dumper; + +use IO::Compress::Zip qw($ZipError); +use IO::Uncompress::Unzip qw($UnzipError); + +BEGIN { + plan skip_all => "Encode is not available" + if $] < 5.006 ; + + eval { require Encode; Encode->import(); }; + + plan skip_all => "Encode is not available" + if $@ ; + + plan skip_all => "Encode not woking in perl $]" + if $] >= 5.008 && $] < 5.008004 ; + + # use Test::NoWarnings, if available + my $extra = 0 ; + $extra = 1 + if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; + + plan tests => 28 + $extra; +} + +{ + title "EFS set in zip: Create a simple zip - language encoding flag set"; + + my $lex = new LexFile my $file1; + + my @names = ( 'alpha \N{GREEK SMALL LETTER ALPHA}', + 'beta \N{GREEK SMALL LETTER BETA}', + 'gamma \N{GREEK SMALL LETTER GAMMA}', + 'delta \N{GREEK SMALL LETTER DELTA}' + ) ; + + my @encoded = map { Encode::encode_utf8($_) } @names; + + my @n = @names; + + my $zip = new IO::Compress::Zip $file1, + Name => $names[0], Efs => 1; + + my $content = 'Hello, world!'; + ok $zip->print($content), "print"; + $zip->newStream(Name => $names[1], Efs => 1); + ok $zip->print($content), "print"; + $zip->newStream(Name => $names[2], Efs => 1); + ok $zip->print($content), "print"; + $zip->newStream(Name => $names[3], Efs => 1); + ok $zip->print($content), "print"; + ok $zip->close(), "closed"; + + { + my $u = new IO::Uncompress::Unzip $file1, Efs => 1 + or die "Cannot open $file1: $UnzipError"; + + my $status; + my @efs; + my @unzip_names; + for ($status = 1; $status > 0; $status = $u->nextStream(Efs => 1)) + { + push @efs, $u->getHeaderInfo()->{efs}; + push @unzip_names, $u->getHeaderInfo()->{Name}; + } + + die "Error processing $file1: $status $!\n" + if $status < 0; + + is_deeply \@efs, [1, 1, 1, 1], "language encoding flag set" + or diag "Got " . Dumper(\@efs); + is_deeply \@unzip_names, [@names], "Names round tripped" + or diag "Got " . Dumper(\@unzip_names); + } + + { + my $u = new IO::Uncompress::Unzip $file1, Efs => 0 + or die "Cannot open $file1: $UnzipError"; + + my $status; + my @efs; + my @unzip_names; + for ($status = 1; $status > 0; $status = $u->nextStream(Efs => 0)) + { + push @efs, $u->getHeaderInfo()->{efs}; + push @unzip_names, $u->getHeaderInfo()->{Name}; + } + + die "Error processing $file1: $status $!\n" + if $status < 0; + + is_deeply \@efs, [1, 1, 1, 1], "language encoding flag set" + or diag "Got " . Dumper(\@efs); + is_deeply \@unzip_names, [@names], "Names round tripped" + or diag "Got " . Dumper(\@unzip_names); + } +} + + +{ + title "Create a simple zip - language encoding flag not set"; + + my $lex = new LexFile my $file1; + + my @names = ( 'alpha \N{GREEK SMALL LETTER ALPHA}', + 'beta \N{GREEK SMALL LETTER BETA}', + 'gamma \N{GREEK SMALL LETTER GAMMA}', + 'delta \N{GREEK SMALL LETTER DELTA}' + ) ; + + my @n = @names; + + my $zip = new IO::Compress::Zip $file1, + Name => $names[0], Efs => 0; + + my $content = 'Hello, world!'; + ok $zip->print($content), "print"; + $zip->newStream(Name => $names[1], Efs => 0); + ok $zip->print($content), "print"; + $zip->newStream(Name => $names[2], Efs => 0); + ok $zip->print($content), "print"; + $zip->newStream(Name => $names[3]); + ok $zip->print($content), "print"; + ok $zip->close(), "closed"; + + my $u = new IO::Uncompress::Unzip $file1, Efs => 0 + or die "Cannot open $file1: $UnzipError"; + + my $status; + my @efs; + my @unzip_names; + for ($status = 1; $status > 0; $status = $u->nextStream()) + { + push @efs, $u->getHeaderInfo()->{efs}; + push @unzip_names, $u->getHeaderInfo()->{Name}; + } + + die "Error processing $file1: $status $!\n" + if $status < 0; + + is_deeply \@efs, [0, 0, 0, 0], "language encoding flag set" + or diag "Got " . Dumper(\@efs); + is_deeply \@unzip_names, [@names], "Names round tripped" + or diag "Got " . Dumper(\@unzip_names); +} + +{ + title "zip: EFS => 0 filename not valid utf8 - language encoding flag not set"; + + my $lex = new LexFile my $file1; + + # Invalid UTF8 + my $name = "a\xFF\x{100}"; + + my $zip = new IO::Compress::Zip $file1, + Name => $name, Efs => 0 ; + + ok $zip->print("abcd"), "print"; + ok $zip->close(), "closed"; + + my $u = new IO::Uncompress::Unzip $file1 + or die "Cannot open $file1: $UnzipError"; + + ok $u->getHeaderInfo()->{Name} eq $name, "got bad filename"; +} + +{ + title "unzip: EFS => 0 filename not valid utf8 - language encoding flag set"; + + my $filename = "t/files/bad-efs.zip" ; + my $name = "\xF0\xA4\xAD"; + + my $u = new IO::Uncompress::Unzip $filename, efs => 0 + or die "Cannot open $filename: $UnzipError"; + + ok $u->getHeaderInfo()->{Name} eq $name, "got bad filename"; +} + +{ + title "unzip: EFS => 1 filename not valid utf8 - language encoding flag set"; + + my $filename = "t/files/bad-efs.zip" ; + my $name = "\xF0\xA4\xAD"; + + eval { my $u = new IO::Uncompress::Unzip $filename, efs => 1 + or die "Cannot open $filename: $UnzipError" }; + + like $@, qr/Zip Filename not UTF-8/, + " Zip Filename not UTF-8" ; + +} + +{ + title "EFS => 1 - filename not valid utf8 - catch bad content writing to zip"; + + my $lex = new LexFile my $file1; + + # Invalid UTF8 + my $name = "a\xFF\x{100}"; + + eval { my $zip = new IO::Compress::Zip $file1, + Name => $name, Efs => 1 } ; + + like $@, qr/Wide character in zip filename/, + " wide characters in zip filename"; +}
\ No newline at end of file diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/compress/multi.pl b/gnu/usr.bin/perl/cpan/IO-Compress/t/compress/multi.pl index 4d587fbdd4a..48129a7c452 100644 --- a/gnu/usr.bin/perl/cpan/IO-Compress/t/compress/multi.pl +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/compress/multi.pl @@ -216,7 +216,8 @@ EOM ok $gz->eof(), " eof()"; is $gz->streamCount(), $stream, " streamCount is $stream" or diag "Stream count is " . $gz->streamCount(); - ok $un eq $buff, " expected output" ; + is $un, $buff, " expected output" + or diag "Stream count is " . $gz->streamCount(); ; #is $gz->tell(), length $buff, " tell is ok"; is $gz->nextStream(), 1, " nextStream ok"; is $gz->tell(), 0, " tell is 0"; diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/cz-14gzopen.t b/gnu/usr.bin/perl/cpan/IO-Compress/t/cz-14gzopen.t index 01d2d65a2bc..3d6a0626ee7 100755 --- a/gnu/usr.bin/perl/cpan/IO-Compress/t/cz-14gzopen.t +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/cz-14gzopen.t @@ -439,7 +439,7 @@ foreach my $stdio ( ['-', '-'], [*STDIN, *STDOUT]) # missing parameters eval ' $fil = gzopen() ' ; - like $@, mkEvalErr('Not enough arguments for Compress::Zlib::gzopen'), + like $@, mkEvalErr('Not enough arguments .*? Compress::Zlib::gzopen'), ' gzopen with missing mode fails' ; # unknown parameters diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/files/bad-efs.zip b/gnu/usr.bin/perl/cpan/IO-Compress/t/files/bad-efs.zip Binary files differnew file mode 100644 index 00000000000..642830e4bd6 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/files/bad-efs.zip diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/files/encrypt-aes.zip b/gnu/usr.bin/perl/cpan/IO-Compress/t/files/encrypt-aes.zip Binary files differnew file mode 100644 index 00000000000..7a303da87f2 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/files/encrypt-aes.zip diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/files/encrypt-standard.zip b/gnu/usr.bin/perl/cpan/IO-Compress/t/files/encrypt-standard.zip Binary files differnew file mode 100644 index 00000000000..ba07a08e587 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/files/encrypt-standard.zip diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/t/files/jar.zip b/gnu/usr.bin/perl/cpan/IO-Compress/t/files/jar.zip Binary files differnew file mode 100644 index 00000000000..e471d42c464 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/IO-Compress/t/files/jar.zip |