1 # Test this only iff we have an executable /usr/bin/gzip
2 # AND we have /usr/bin in our PATH
3 # AND we have a useable /usr/bin directory.
4 # This limits the testing to UNIX-like
5 # systems but that should be enough.
7 my $gzip = "/usr/bin/gzip";
10 ":$ENV{PATH}:" =~ m!:/usr/bin:! &&
11 -d "/usr/bin" && -x "/usr/bin") {
12 print "1..0 # Skip: no $gzip\n";
19 print "ok $no\n" if $ok ;
20 print "not ok $no\n" unless $ok ;
26 eval { require Compress::Zlib };
27 $hasCompressZlib = $@ ? 0 : 1;
34 # Other export functionality (none) is tested in import.t.
37 $hasCompressZlib == IO::Zlib::has_Compress_Zlib());
39 eval "use IO::Zlib qw(:gzip_external)";
41 $@ =~ /^IO::Zlib::import: ':gzip_external' requires an argument /);
47 $hasCompressZlib || IO::Zlib::gzip_used());
50 !defined IO::Zlib::gzip_external());
53 IO::Zlib::gzip_read_open() eq 'gzip -dc %s |');
56 IO::Zlib::gzip_write_open() eq '| gzip > %s');
59 ($hasCompressZlib && \&IO::Zlib::gzopen == \&Compress::Zlib::gzopen) ||
60 \&IO::Zlib::gzopen == \&IO::Zlib::gzopen_external);
62 eval "use IO::Zlib qw(:gzip_external 0)";
65 !IO::Zlib::gzip_external());
68 ($hasCompressZlib && \&IO::Zlib::gzopen == \&Compress::Zlib::gzopen) ||
70 $@ =~ /^IO::Zlib::import: no Compress::Zlib and no external gzip /));
72 eval "use IO::Zlib qw(:gzip_external 1)";
75 IO::Zlib::gzip_used());
78 IO::Zlib::gzip_external());
81 \&IO::Zlib::gzopen == \&IO::Zlib::gzopen_external);
83 eval 'IO::Zlib->new("foo", "xyz")';
84 ok(14, $@ =~ /^IO::Zlib::gzopen_external: mode 'xyz' is illegal /);
86 # The following is a copy of the basic.t, shifted up by 14 tests,
87 # the difference being that now we should be using the external gzip.
96 ok(15, $file = IO::Zlib->new($name, "wb"));
97 ok(16, $file->print($hello));
98 ok(17, $file->opened());
99 ok(18, $file->close());
100 ok(19, !$file->opened());
102 ok(20, $file = IO::Zlib->new());
103 ok(21, $file->open($name, "rb"));
104 ok(22, !$file->eof());
105 ok(23, $file->read($uncomp, 1024) == length($hello));
106 ok(24, $file->eof());
107 ok(25, $file->opened());
108 ok(26, $file->close());
109 ok(27, !$file->opened());
113 ok(28, $hello eq $uncomp);
115 ok(29, !defined(IO::Zlib->new($name, "rb")));
117 # Then finally test modifying the open commands.
119 my $new_read = 'gzip.exe /d /c %s |';
121 eval "use IO::Zlib ':gzip_read_open' => '$new_read'";
124 IO::Zlib::gzip_read_open() eq $new_read);
126 eval "use IO::Zlib ':gzip_read_open' => 'bad'";
129 $@ =~ /^IO::Zlib::import: ':gzip_read_open' 'bad' is illegal /);
131 my $new_write = '| gzip.exe %s';
133 eval "use IO::Zlib ':gzip_write_open' => '$new_write'";
136 IO::Zlib::gzip_write_open() eq $new_write);
138 eval "use IO::Zlib ':gzip_write_open' => 'bad'";
141 $@ =~ /^IO::Zlib::import: ':gzip_write_open' 'bad' is illegal /);