tests: move all basenc tests to their own directory

* tests/misc/base64.pl: Move to tests/basenc/base64.pl
* tests/misc/basenc.pl: Move to tests/basenc/basenc.pl
* tests/local.mk: Adjust accordingly
This commit is contained in:
Pádraig Brady
2023-10-06 16:31:47 +01:00
parent 378dc38f48
commit caa716803a
3 changed files with 2 additions and 2 deletions

212
tests/basenc/base64.pl Executable file
View File

@@ -0,0 +1,212 @@
#!/usr/bin/perl
# Exercise base{32,64}.
# Copyright (C) 2006-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
use strict;
(my $program_name = $0) =~ s|.*/||;
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
# Return the encoding of a string of N 'a's.
sub enc64($)
{
my ($n) = @_;
my %remainder = ( 0 => '', 1 => 'YQ==', 2 => 'YWE=' );
return 'YWFh' x ($n / 3) . $remainder{$n % 3};
}
sub enc32($)
{
my ($n) = @_;
my %remainder = ( 0 => '', 1 => 'ME======', 2 => 'MFQQ====',
3 => 'MFQWC===', 4 => 'MFQWCYI=');
return 'MFQWCYLB' x ($n / 5) . $remainder{$n % 5};
}
# Function reference to appropriate encoder
my $enc;
# An encoded string of length 4KB, using 3K "a"s.
my $a3k;
my @a3k_nl;
# Return a copy of S, with newlines inserted every WIDTH bytes.
# Ensure that the result (if not the empty string) is newline-terminated.
sub wrap($$)
{
my ($s, $width) = @_;
$s =~ s/(.{$width})/$1\n/g;
substr ($s, -1, 1) ne "\n"
and $s .= "\n";
return $s;
}
my @Tests;
sub gen_tests($)
{
my ($prog) = @_;
my $try_help = "Try '$prog --help' for more information.\n";
@Tests=
(
['empty', {IN=>''}, {OUT=>""}],
['inout1', {IN=>'a'x1}, {OUT=>&$enc(1)."\n"}],
['inout2', {IN=>'a'x2}, {OUT=>&$enc(2)."\n"}],
['inout3', {IN=>'a'x3}, {OUT=>&$enc(3)."\n"}],
['inout4', {IN=>'a'x4}, {OUT=>&$enc(4)."\n"}],
['inout5', {IN=>'a'x5}, {OUT=>&$enc(5)."\n"}],
['wrap', '--wrap 0', {IN=>'a'}, {OUT=>&$enc(1)}],
['wrap-zero', '--wrap 08', {IN=>'a'}, {OUT=>&$enc(1)."\n"}],
['wrap5-39', '--wrap=5', {IN=>'a' x 39}, {OUT=>wrap &$enc(39),5}],
['wrap5-40', '--wrap=5', {IN=>'a' x 40}, {OUT=>wrap &$enc(40),5}],
['wrap5-41', '--wrap=5', {IN=>'a' x 41}, {OUT=>wrap &$enc(41),5}],
['wrap5-42', '--wrap=5', {IN=>'a' x 42}, {OUT=>wrap &$enc(42),5}],
['wrap5-43', '--wrap=5', {IN=>'a' x 43}, {OUT=>wrap &$enc(43),5}],
['wrap5-44', '--wrap=5', {IN=>'a' x 44}, {OUT=>wrap &$enc(44),5}],
['wrap5-45', '--wrap=5', {IN=>'a' x 45}, {OUT=>wrap &$enc(45),5}],
['wrap5-46', '--wrap=5', {IN=>'a' x 46}, {OUT=>wrap &$enc(46),5}],
['wrap-bad-1', '-w0x0', {IN=>''}, {OUT=>""},
{ERR_SUBST => 's/base..:/base..:/'},
{ERR => "base..: invalid wrap size: '0x0'\n"}, {EXIT => 1}],
['wrap-bad-2', '-w1k', {IN=>''}, {OUT=>""},
{ERR_SUBST => 's/base..:/base..:/'},
{ERR => "base..: invalid wrap size: '1k'\n"}, {EXIT => 1}],
['wrap-bad-3', '-w-1', {IN=>''}, {OUT=>""},
{ERR_SUBST => 's/base..:/base..:/'},
{ERR => "base..: invalid wrap size: '-1'\n"}, {EXIT => 1}],
['buf-1', '--decode', {IN=>&$enc(1)}, {OUT=>'a' x 1}],
['buf-2', '--decode', {IN=>&$enc(2)}, {OUT=>'a' x 2}],
['buf-3', '--decode', {IN=>&$enc(3)}, {OUT=>'a' x 3}],
['buf-4', '--decode', {IN=>&$enc(4)}, {OUT=>'a' x 4}],
# 4KB worth of input.
['buf-4k0', '--decode', {IN=>&$enc(3072+0)}, {OUT=>'a' x (3072+0)}],
['buf-4k1', '--decode', {IN=>&$enc(3072+1)}, {OUT=>'a' x (3072+1)}],
['buf-4k2', '--decode', {IN=>&$enc(3072+2)}, {OUT=>'a' x (3072+2)}],
['buf-4k3', '--decode', {IN=>&$enc(3072+3)}, {OUT=>'a' x (3072+3)}],
['buf-4km1','--decode', {IN=>&$enc(3072-1)}, {OUT=>'a' x (3072-1)}],
['buf-4km2','--decode', {IN=>&$enc(3072-2)}, {OUT=>'a' x (3072-2)}],
['buf-4km3','--decode', {IN=>&$enc(3072-3)}, {OUT=>'a' x (3072-3)}],
['buf-4km4','--decode', {IN=>&$enc(3072-4)}, {OUT=>'a' x (3072-4)}],
# Exercise the case in which the final base-64 byte is
# in a buffer all by itself.
['b4k-1', '--decode', {IN=>$a3k_nl[1]}, {OUT=>'a' x (3072+0)}],
['b4k-2', '--decode', {IN=>$a3k_nl[2]}, {OUT=>'a' x (3072+0)}],
['b4k-3', '--decode', {IN=>$a3k_nl[3]}, {OUT=>'a' x (3072+0)}],
['ext-op1', 'a b', {IN=>''}, {EXIT=>1},
{ERR => "$prog: extra operand 'b'\n" . $try_help}],
# Again, with more option arguments
['ext-op2', '-di --wrap=40 a b', {IN=>''}, {EXIT=>1},
{ERR => "$prog: extra operand 'b'\n" . $try_help}],
);
if ($prog eq "base64")
{
push @Tests, (
['baddecode', '--decode', {IN=>'a'}, {OUT=>""},
{ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}],
['paddecode2', '--decode', {IN=>'ab'}, {OUT=>"i"}],
['paddecode3', '--decode', {IN=>'Zzz'}, {OUT=>"g<"}],
['baddecode4', '--decode', {IN=>'Zz='}, {OUT=>"g"},
{ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}],
['baddecode5', '--decode', {IN=>'Z==='}, {OUT=>""},
{ERR_SUBST => 's/.*: invalid input//'}, {ERR => "\n"}, {EXIT => 1}]
);
}
# For each non-failing test, create a --decode test using the
# expected output as input. Also, add tests inserting newlines.
my @new;
foreach my $t (@Tests)
{
my $exit_val;
my $in;
my @out;
# If the test has a single option of "--decode", then skip it.
!ref $t->[1] && $t->[1] eq '--decode'
and next;
foreach my $e (@$t)
{
ref $e && ref $e eq 'HASH'
or next;
defined $e->{EXIT}
and $exit_val = $e->{EXIT};
defined $e->{IN}
and $in = $e->{IN};
if (defined $e->{OUT})
{
my $t = $e->{OUT};
push @out, $t;
my $len = length $t;
foreach my $i (0..$len)
{
my $u = $t;
substr ($u, $i, 0) = "\n";
push @out, $u;
10 <= $i
and last;
}
}
}
$exit_val
and next;
my $i = 0;
foreach my $o (@out)
{
push @new, ["d$i-$t->[0]", '--decode', {IN => $o}, {OUT => $in}];
++$i;
}
}
push @Tests, @new;
}
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
my $fail = 0;
foreach my $prog (qw(base32 base64))
{
$enc = $prog eq "base32" ? \&enc32 : \&enc64;
# Construct an encoded string of length 4KB, using 3K "a"s.
$a3k = &$enc(3072);
@a3k_nl = ();
# A few copies, each with different number of newlines at the start.
for my $k (0..3)
{
(my $t = $a3k) =~ s/^/"\n"x $k/e;
push @a3k_nl, $t;
}
gen_tests($prog);
$fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
if ($fail != 0)
{
last;
}
}
exit $fail;

292
tests/basenc/basenc.pl Executable file
View File

@@ -0,0 +1,292 @@
#!/usr/bin/perl
# Exercise basenc.
# Copyright (C) 2006-2023 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# This test exercises the various encoding (other than base64/32).
# It also does not test the general options (e.g. --wrap), as that code is
# shared and tested in base64.
use strict;
(my $program_name = $0) =~ s|.*/||;
my $prog = 'basenc';
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
my $base64_in = "\x54\x0f\xdc\xf0\x0f\xaf\x4a";
my $base64_out = "VA/c8A+vSg==";
my $base64url_out = $base64_out;
$base64url_out =~ y|+/|-_|;
my $base64url_out_nl = $base64url_out;
$base64url_out_nl =~ s/(..)/\1\n/g; # add newline every two characters
# Bug 49741:
# The input is 'abc' in base64, in an 8K buffer (larger than 1024*5,
# the buffer size which caused the bug).
my $base64_bug49741_in = "YWJj" x 2000 ;
my $base64_bug49741_out = "abc" x 2000 ;
my $base32_in = "\xfd\xd8\x07\xd1\xa5";
my $base32_out = "7XMAPUNF";
my $x = $base32_out;
$x =~ y|ABCDEFGHIJKLMNOPQRSTUVWXYZ234567|0123456789ABCDEFGHIJKLMNOPQRSTUV|;
my $base32hex_out = $x;
# base32 with padding and newline
my $base32_in2 = "\xFF\x00";
my $base32_out2 = "74AA====";
$x = $base32_out2;
$x =~ y|ABCDEFGHIJKLMNOPQRSTUVWXYZ234567|0123456789ABCDEFGHIJKLMNOPQRSTUV|;
my $base32hex_out2 = $x;
my $base32hex_out2_nl = $x;
$base32hex_out2_nl =~ s/(...)/\1\n/g; # Add newline every 3 characters
my $base16_in = "\xfd\xd8\x07\xd1\xa5";
my $base16_out = "FDD807D1A5";
my $z85_in = "\x86\x4F\xD2\x6F\xB5\x59\xF7\x5B";
my $z85_out = 'HelloWorld';
my $base2lsbf_ab = "1000011001000110";
my $base2lsbf_ab_nl = $base2lsbf_ab;
$base2lsbf_ab_nl =~ s/(...)/\1\n/g; # Add newline every 3 characters
my $base2msbf_ab = "0110000101100010";
my $base2msbf_ab_nl = $base2msbf_ab;
$base2msbf_ab_nl =~ s/(...)/\1\n/g; # Add newline every 3 characters
my $try_help = "Try '$prog --help' for more information.\n";
my @Tests =
(
# These are mainly for higher coverage
['help', '--help', {IN=>''}, {OUT=>""}, {OUT_SUBST=>'s/.*//sm'}],
# Typical message is " unrecognized option '--foobar'", but on
# Open/NetBSD it is " unknown option -- foobar".
['error', '--foobar', {IN=>''}, {OUT=>""}, {EXIT=>1},
{ERR=>"$prog: foobar\n" . $try_help },
{ERR_SUBST=>"s/(unrecognized|unknown) option [-' ]*foobar[' ]*/foobar/"}],
['noenc', '', {IN=>''}, {EXIT=>1},
{ERR=>"$prog: missing encoding type\n" . $try_help }],
['extra', '--base64 A B', {IN=>''}, {EXIT=>1},
{ERR=>"$prog: extra operand 'B'\n" . $try_help}],
['empty1', '--base64', {IN=>''}, {OUT=>""}],
['empty2', '--base64url', {IN=>''}, {OUT=>""}],
['empty3', '--base32', {IN=>''}, {OUT=>""}],
['empty4', '--base32hex', {IN=>''}, {OUT=>""}],
['empty5', '--base16', {IN=>''}, {OUT=>""}],
['empty6', '--base2msbf', {IN=>''}, {OUT=>""}],
['empty7', '--base2lsbf', {IN=>''}, {OUT=>""}],
['empty8', '--z85', {IN=>''}, {OUT=>""}],
['b64_1', '--base64', {IN=>$base64_in}, {OUT=>$base64_out}],
['b64_2', '--base64 -d', {IN=>$base64_out}, {OUT=>$base64_in}],
['b64_3', '--base64 -d -i', {IN=>'&'.$base64_out},{OUT=>$base64_in}],
['b64u_1', '--base64url', {IN=>$base64_in}, {OUT=>$base64url_out}],
['b64u_2', '--base64url -d', {IN=>$base64url_out}, {OUT=>$base64_in}],
['b64u_3', '--base64url -di', {IN=>'&'.$base64url_out} , {OUT=>$base64_in}],
['b64u_4', '--base64url -di', {IN=>'/'.$base64url_out.'+'},{OUT=>$base64_in}],
['b64u_5', '--base64url -d', {IN=>$base64url_out_nl}, {OUT=>$base64_in}],
['b64u_6', '--base64url -di', {IN=>$base64url_out_nl}, {OUT=>$base64_in}],
# ensure base64url fails to decode base64 input with "+" and "/"
['b64u_7', '--base64url -d', {IN=>$base64_out},
{EXIT=>1}, {ERR=>"$prog: invalid input\n"}],
['b64_bug49741', '--base64 -d', {IN=>$base64_bug49741_in},
{OUT=>$base64_bug49741_out}],
['b32_1', '--base32', {IN=>$base32_in}, {OUT=>$base32_out}],
['b32_2', '--base32 -d', {IN=>$base32_out}, {OUT=>$base32_in}],
['b32_3', '--base32 -d -i', {IN=>'&'.$base32_out},{OUT=>$base32_in}],
['b32_4', '--base32', {IN=>$base32_in2}, {OUT=>$base32_out2}],
['b32_5', '--base32 -d', {IN=>$base32_out2}, {OUT=>$base32_in2}],
['b32_6', '--base32 -d -i', {IN=>$base32_out2}, {OUT=>$base32_in2}],
['b32h_1', '--base32hex', {IN=>$base32_in}, {OUT=>$base32hex_out}],
['b32h_2', '--base32hex -d', {IN=>$base32hex_out}, {OUT=>$base32_in}],
['b32h_3', '--base32hex -d -i', {IN=>'/'.$base32hex_out}, {OUT=>$base32_in}],
['b32h_4', '--base32hex -d -i', {IN=>'W'.$base32hex_out}, {OUT=>$base32_in}],
['b32h_5', '--base32hex -d', {IN=>$base32hex_out.'W'}, , {OUT=>$base32_in},
{EXIT=>1}, {ERR=>"$prog: invalid input\n"}],
['b32h_6', '--base32hex -d', {IN=>$base32hex_out.'/'}, {OUT=>$base32_in},
{EXIT=>1}, {ERR=>"$prog: invalid input\n"}],
['b32h_7', '--base32hex', {IN=>$base32_in2}, {OUT=>$base32hex_out2}],
['b32h_8', '--base32hex -d', {IN=>$base32hex_out2}, {OUT=>$base32_in2}],
['b32h_9', '--base32hex -di', {IN=>$base32hex_out2}, {OUT=>$base32_in2}],
['b32h_10', '--base32hex -d', {IN=>$base32hex_out2_nl}, {OUT=>$base32_in2}],
['b32h_11', '--base32hex -di', {IN=>$base32hex_out2_nl}, {OUT=>$base32_in2}],
['b16_1', '--base16', {IN=>$base16_in}, {OUT=>$base16_out}],
['b16_2', '--base16 -d', {IN=>$base16_out}, {OUT=>$base16_in}],
['b16_3', '--base16 -d -i', {IN=>'&'. $base16_out}, {OUT=>$base16_in}],
['b16_4', '--base16 -d -i', {IN=>$base16_out.'G'}, {OUT=>$base16_in}],
['b16_5', '--base16 -d', {IN=>'.'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b16_6', '--base16 -d', {IN=>'='}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b16_7', '--base16 -d', {IN=>'G'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b16_8', '--base16 -d', {IN=>"AB\nCD"}, {OUT=>"\xAB\xCD"}],
['b2m_1', '--base2m', {IN=>"\xC1"}, {OUT=>"11000001"}],
['b2m_2', '--base2m -d', {IN=>'11000001'}, {OUT=>"\xC1"}],
['b2m_3', '--base2m -d', {IN=>"110\n00001"}, {OUT=>"\xC1"}],
['b2m_4', '--base2m -di', {IN=>"110x00001"}, {OUT=>"\xC1"}],
['b2m_5', '--base2m -d', {IN=>"110x00001"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b2m_6', '--base2m -d', {IN=>"11000001x"}, {OUT=>"\xC1"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b2m_7', '--base2m -d', {IN=>"1"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b2m_8', '--base2m -d', {IN=>"1000100"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b2m_9', '--base2m -d', {IN=>"100010000000000"}, {OUT=>"\x88"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b2m_10','--base2m', {IN=>"ab"}, {OUT=>$base2msbf_ab}],
['b2m_11','--base2m -d', {IN=>$base2msbf_ab}, {OUT=>"ab"}],
['b2m_12','--base2m -d', {IN=>$base2msbf_ab_nl}, {OUT=>"ab"}],
['b2l_1', '--base2l', {IN=>"\x83"}, {OUT=>"11000001"}],
['b2l_2', '--base2l -d', {IN=>'11000001'}, {OUT=>"\x83"}],
['b2l_3', '--base2l -d', {IN=>"110\n00001"}, {OUT=>"\x83"}],
['b2l_4', '--base2l -di', {IN=>"110x00001"}, {OUT=>"\x83"}],
['b2l_5', '--base2l -d', {IN=>"110x00001"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b2l_6', '--base2l -d', {IN=>"11000001x"}, {OUT=>"\x83"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b2l_7', '--base2l -d', {IN=>"1"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b2l_8', '--base2l -d', {IN=>"1000100"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b2l_9', '--base2l -d', {IN=>"100010000000000"}, {OUT=>"\x11"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['b2l_10','--base2l', {IN=>"ab"}, {OUT=>$base2lsbf_ab}],
['b2l_11','--base2l -d', {IN=>$base2lsbf_ab}, {OUT=>"ab"}],
['b2l_12','--base2l -d', {IN=>$base2lsbf_ab_nl}, {OUT=>"ab"}],
['z85_1', '--z85', {IN=>$z85_in}, {OUT=>$z85_out}],
['z85_2', '--z85 -d', {IN=>$z85_out}, {OUT=>$z85_in}],
['z85_3', '--z85 -d -i', {IN=>'~'. $z85_out}, {OUT=>$z85_in}],
['z85_4', '--z85 -d -i', {IN=>' '. $z85_out}, {OUT=>$z85_in}],
['z85_5', '--z85 -d', {IN=>'%j$qP'}, {OUT=>"\xFF\xDD\xBB\x99"}],
['z85_6', '--z85 -d -i', {IN=>'%j~$qP'}, {OUT=>"\xFF\xDD\xBB\x99"}],
# z85 encoding require input to be multiple of 5 octets
['z85_7', '--z85 -d', {IN=>'hello'}, {OUT=>"5jXu"}],
['z85_8', '--z85 -d', {IN=>'helloX'}, {OUT=>"5jXu"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_9', '--z85 -d', {IN=>"he\nl\nlo"}, {OUT=>"5jXu"}],
# Invalid input characters (space ~ ")
['z85_10', '--z85 -d', {IN=>' j$qP'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_11', '--z85 -d', {IN=>'%j$q~'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_12', '--z85 -d', {IN=>'%j$"P'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
# Invalid length (binary input must be a multiple of 4 octets,
# z85-encoded input must be a multiple of 5 octets)
['z85_20', '--z85', {IN=>'A'}, {EXIT=>1},
{ERR=>"$prog: invalid input (length must be multiple of 4 characters)\n"}],
['z85_21', '--z85', {IN=>'AB'}, {EXIT=>1},
{ERR=>"$prog: invalid input (length must be multiple of 4 characters)\n"}],
['z85_22', '--z85', {IN=>'ABC'}, {EXIT=>1},
{ERR=>"$prog: invalid input (length must be multiple of 4 characters)\n"}],
['z85_23', '--z85', {IN=>'ABCD'}, {OUT=>'k%^}b'}],
['z85_24', '--z85', {IN=>'ABCDE'}, {EXIT=>1},
{ERR=>"$prog: invalid input (length must be multiple of 4 characters)\n"}],
['z85_30', '--z85 -d', {IN=>'A'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_31', '--z85 -d', {IN=>'AB'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_32', '--z85 -d', {IN=>'ABC'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_33', '--z85 -d', {IN=>'ABCD'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_34', '--z85 -d', {IN=>'ABCDE'}, {OUT=>"\x71\x61\x9e\xb6"}],
['z85_35', '--z85 -d', {IN=>'ABCDEF'},{OUT=>"\x71\x61\x9e\xb6"},
{EXIT=>1}, {ERR=>"$prog: invalid input\n"}],
# largest possible value
['z85_40', '--z85', {IN=>"\xFF\xFF\xFF\xFF"},{OUT=>"%nSc0"}],
['z85_41', '--z85 -d', {IN=>"%nSc0"}, {OUT=>"\xFF\xFF\xFF\xFF"}],
# Invalid encoded data - will decode to more than 0xFFFFFFFF
['z85_42', '--z85 -d', {IN=>"%nSc1"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_43', '--z85 -d', {IN=>"%nSd0"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_44', '--z85 -d', {IN=>"%nTc0"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_45', '--z85 -d', {IN=>"%oSc0"}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_46', '--z85 -d', {IN=>'$nSc0'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
['z85_47', '--z85 -d', {IN=>'#0000'}, {EXIT=>1},
{ERR=>"$prog: invalid input\n"}],
);
# Prepend the command line argument and append a newline to end
# of each expected 'OUT' string.
my $t;
Test:
foreach $t (@Tests)
{
foreach my $e (@$t)
{
ref $e && ref $e eq 'HASH' && defined $e->{OUT_SUBST}
and next Test;
}
push @$t, {OUT_SUBST=>'s/\n$//s'};
}
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
exit $fail;