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";
18 print "ok $no\n" if $ok ;
19 print "not ok $no\n" unless $ok ;
25 eval { require Compress::Zlib };
26 $hasCompressZlib = $@ ? 0 : 1;
33 # Other export functionality (none) is tested in import.t.
36 $hasCompressZlib == IO::Zlib::has_Compress_Zlib());
38 eval "use IO::Zlib qw(:gzip_external)";
40 $@ =~ /^IO::Zlib::import: ':gzip_external' requires an argument /);
46 $hasCompressZlib || IO::Zlib::gzip_used());
49 !defined IO::Zlib::gzip_external());
52 IO::Zlib::gzip_read_open() eq 'gzip -dc %s |');
55 IO::Zlib::gzip_write_open() eq '| gzip > %s');
58 ($hasCompressZlib && \&IO::Zlib::gzopen == \&Compress::Zlib::gzopen) ||
59 \&IO::Zlib::gzopen == \&IO::Zlib::gzopen_external);
61 eval "use IO::Zlib qw(:gzip_external 0)";
64 !IO::Zlib::gzip_external());
67 ($hasCompressZlib && \&IO::Zlib::gzopen == \&Compress::Zlib::gzopen) ||
69 $@ =~ /^IO::Zlib::import: no Compress::Zlib and no external gzip /));
71 eval "use IO::Zlib qw(:gzip_external 1)";
74 IO::Zlib::gzip_used());
77 IO::Zlib::gzip_external());
80 \&IO::Zlib::gzopen == \&IO::Zlib::gzopen_external);
82 eval 'IO::Zlib->new("foo", "xyz")';
83 ok(14, $@ =~ /^IO::Zlib::gzopen_external: mode 'xyz' is illegal /);
85 # The following is a copy of the basic.t, shifted up by 14 tests,
86 # the difference being that now we should be using the external gzip.
95 ok(15, $file = IO::Zlib->new($name, "wb"));
96 ok(16, $file->print($hello));
97 ok(17, $file->opened());
98 ok(18, $file->close());
99 ok(19, !$file->opened());
101 ok(20, $file = IO::Zlib->new());
102 ok(21, $file->open($name, "rb"));
103 ok(22, !$file->eof());
104 ok(23, $file->read($uncomp, 1024) == length($hello));
105 ok(24, $file->eof());
106 ok(25, $file->opened());
107 ok(26, $file->close());
108 ok(27, !$file->opened());
112 ok(28, $hello eq $uncomp);
114 ok(29, !defined(IO::Zlib->new($name, "rb")));
116 # Then finally test modifying the open commands.
118 my $new_read = 'gzip.exe /d /c %s |';
120 eval "use IO::Zlib ':gzip_read_open' => '$new_read'";
123 IO::Zlib::gzip_read_open() eq $new_read);
125 eval "use IO::Zlib ':gzip_read_open' => 'bad'";
128 $@ =~ /^IO::Zlib::import: ':gzip_read_open' 'bad' is illegal /);
130 my $new_write = '| gzip.exe %s';
132 eval "use IO::Zlib ':gzip_write_open' => '$new_write'";
135 IO::Zlib::gzip_write_open() eq $new_write);
137 eval "use IO::Zlib ':gzip_write_open' => 'bad'";
140 $@ =~ /^IO::Zlib::import: ':gzip_write_open' 'bad' is illegal /);